Difference between revisions of "HelperNotHelper"
From Apache OpenOffice Wiki
SergeMoutou (Talk | contribs) m (→Class without Helper) |
SergeMoutou (Talk | contribs) m (→Class with an Helper) |
||
Line 35: | Line 35: | ||
<source lang="cpp"> | <source lang="cpp"> | ||
− | class MyCounterImpl : public ::cppu::WeakImplHelper2< | + | class MyCounterImpl : public ::cppu::WeakImplHelper2< XCountable, XServiceInfo > |
− | + | ||
{ | { | ||
// to obtain other services if needed | // to obtain other services if needed | ||
Reference< XMultiServiceFactory > m_xServiceManager; | Reference< XMultiServiceFactory > m_xServiceManager; | ||
− | |||
sal_Int32 m_nRefCount; | sal_Int32 m_nRefCount; | ||
sal_Int32 m_nCount; | sal_Int32 m_nCount; | ||
Line 52: | Line 50: | ||
// XCountable implementation | // XCountable implementation | ||
− | virtual sal_Int32 SAL_CALL getCount() throw (RuntimeException) | + | virtual sal_Int32 SAL_CALL getCount() throw (RuntimeException); |
− | + | virtual void SAL_CALL setCount( sal_Int32 nCount ) throw (RuntimeException); | |
− | virtual void SAL_CALL setCount( sal_Int32 nCount ) throw (RuntimeException) | + | virtual sal_Int32 SAL_CALL increment() throw (RuntimeException); |
− | + | virtual sal_Int32 SAL_CALL decrement() throw (RuntimeException); | |
− | virtual sal_Int32 SAL_CALL increment() throw (RuntimeException | + | |
− | + | ||
− | virtual sal_Int32 SAL_CALL decrement() throw (RuntimeException | + | |
− | + | ||
}; | }; | ||
</source> | </source> |
Revision as of 11:54, 17 April 2008
It's important to figure out the difference beween class implementing component when you use or not an helper.
Class without Helper
Here is the C++ code
class MyCounterImpl : public XCountable, public XServiceInfo { sal_Int32 m_nRefCount; sal_Int32 m_nCount; public: MyCounterImpl( const Reference< XMultiServiceFactory > & xServiceManager ); ~MyCounterImpl(); // XInterface implementation virtual void SAL_CALL acquire() throw (); virtual void SAL_CALL release() throw (); virtual Any SAL_CALL queryInterface( const Type & rType ) throw (RuntimeException); // XServiceInfo implementation virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException); virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException); virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( ); // XCountable implementation virtual sal_Int32 SAL_CALL getCount() throw (RuntimeException); virtual void SAL_CALL setCount( sal_Int32 nCount ) throw (RuntimeException); virtual sal_Int32 SAL_CALL increment() throw (RuntimeException); virtual sal_Int32 SAL_CALL decrement() throw (RuntimeException); };
Class with an Helper
Here is the code
class MyCounterImpl : public ::cppu::WeakImplHelper2< XCountable, XServiceInfo > { // to obtain other services if needed Reference< XMultiServiceFactory > m_xServiceManager; sal_Int32 m_nRefCount; sal_Int32 m_nCount; public: // XServiceInfo implementation virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException); virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException); virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( ); // XCountable implementation virtual sal_Int32 SAL_CALL getCount() throw (RuntimeException); virtual void SAL_CALL setCount( sal_Int32 nCount ) throw (RuntimeException); virtual sal_Int32 SAL_CALL increment() throw (RuntimeException); virtual sal_Int32 SAL_CALL decrement() throw (RuntimeException); };