Kaydet (Commit) a74f430a authored tarafından Caolán McNamara's avatar Caolán McNamara

tweak the odk example to be equivalent to the standard template

üst d6fb1ee8
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <osl/interlck.h> #include <osl/interlck.h>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <rtl/uuid.h> #include <rtl/uuid.h>
#include <rtl/instance.hpp>
#include <cppuhelper/factory.hxx> #include <cppuhelper/factory.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
...@@ -172,24 +173,34 @@ Sequence< Type > MyService1Impl::getTypes() ...@@ -172,24 +173,34 @@ Sequence< Type > MyService1Impl::getTypes()
seq[ 2 ] = ::cppu::UnoType< Reference< ::my_module::XSomething > >::get(); seq[ 2 ] = ::cppu::UnoType< Reference< ::my_module::XSomething > >::get();
return seq; return seq;
} }
Sequence< sal_Int8 > MyService1Impl::getImplementationId() namespace
throw (RuntimeException)
{ {
static Sequence< sal_Int8 > * s_pId = 0; // class to create an unique id
if (! s_pId) class UniqueIdInit
{ {
// create unique id private:
Sequence< sal_Int8 > id( 16 ); ::com::sun::star::uno::Sequence< sal_Int8 > m_aSeq;
::rtl_createUuid( (sal_uInt8 *)id.getArray(), 0, sal_True ); public:
// guard initialization with some mutex UniqueIdInitIdInit() : m_aSeq(16)
::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
if (! s_pId)
{ {
static Sequence< sal_Int8 > s_id( id ); rtl_createUuid( (sal_uInt8*)m_aSeq.getArray(), 0, sal_True );
s_pId = &s_id;
} }
} const ::com::sun::star::uno::Sequence< sal_Int8 >& getSeq() const { return m_aSeq; }
return *s_pId; };
//A multi-thread safe UniqueIdInitIdInit singleton wrapper
class theService1ImplImplementationId
: public rtl::Static< UniqueIdInitIdInit,
theService1ImplImplementationId >
{
};
}
Sequence< sal_Int8 > MyService1Impl::getImplementationId()
throw (RuntimeException)
{
//create a singleton that generates a unique id on
//first initialization and returns the same one
//on subsequent calls.
return theService1ImplImplementationId::get().getSeq();
} }
// XSomething implementation // XSomething implementation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment