19 #ifndef INCLUDE_RCF_OBJECTFACTORYSERVICE_HPP
20 #define INCLUDE_RCF_OBJECTFACTORYSERVICE_HPP
22 #include <RCF/Config.hpp>
24 #if RCF_FEATURE_LEGACY==0
25 #error This header is only supported in builds with RCF_FEATURE_LEGACY=1.
32 #include <boost/cstdint.hpp>
33 #include <boost/noncopyable.hpp>
34 #include <boost/shared_ptr.hpp>
36 #include <RCF/Export.hpp>
37 #include <RCF/GetInterfaceName.hpp>
38 #include <RCF/RcfServer.hpp>
39 #include <RCF/Service.hpp>
40 #include <RCF/StubFactory.hpp>
41 #include <RCF/ThreadLibrary.hpp>
42 #include <RCF/Token.hpp>
43 #include <RCF/TypeTraits.hpp>
54 typedef boost::shared_ptr<StubEntry> StubEntryPtr;
55 typedef boost::shared_ptr<StubFactory> StubFactoryPtr;
56 typedef boost::shared_ptr<TokenMapped> TokenMappedPtr;
58 class RCF_EXPORT StubFactoryRegistry
62 StubFactoryRegistry();
66 template<
typename I1,
typename ImplementationT>
67 bool bind(
const std::string &name_ =
"")
69 return bind( (I1 *) NULL, (ImplementationT **) NULL, name_);
72 template<
typename I1,
typename ImplementationT>
73 bool bind(I1 *, ImplementationT **,
const std::string &name_ =
"")
75 const std::string &name = (name_ ==
"") ?
76 getInterfaceName((I1 *) NULL) :
79 StubFactoryPtr stubFactoryPtr(
80 new RCF::StubFactory_1<ImplementationT, I1>());
83 return insertStubFactory(name, desc, stubFactoryPtr);
88 bool insertStubFactory(
89 const std::string &objectName,
90 const std::string &desc,
91 StubFactoryPtr stubFactoryPtr);
93 bool removeStubFactory(
94 const std::string &objectName);
96 StubFactoryPtr getStubFactory(
97 const std::string &objectName);
103 StubFactoryPtr> StubFactoryMap;
105 ReadWriteMutex mStubFactoryMapMutex;
106 StubFactoryMap mStubFactoryMap;
110 class RCF_EXPORT ObjectFactoryService :
112 public StubFactoryRegistry,
117 ObjectFactoryService();
120 boost::int32_t CreateObject(
const std::string &objectName, Token &token);
121 boost::int32_t DeleteObject(
const Token &token);
123 boost::int32_t addObject(TokenMappedPtr tokenMappedPtr, Token &token);
125 boost::int32_t CreateSessionObject(
const std::string &objectName);
126 boost::int32_t DeleteSessionObject();
128 StubEntryPtr getStubEntryPtr(
const Token &token);
129 TokenMappedPtr getTokenMappedPtr(
const Token & token);
132 void onServiceAdded(RcfServer &server);
133 void onServiceRemoved(RcfServer &server);
134 void onServerStart(RcfServer &);
135 void onServerStop(RcfServer &);
137 void cycleCleanup(
int timeoutMs);
138 void cleanupStubMap(
unsigned int timeoutS);
144 TokenMappedPtr> > StubMap;
147 typedef boost::shared_ptr<TokenFactory> TokenFactoryPtr;
148 TokenFactoryPtr mTokenFactory;
150 unsigned int mClientStubTimeoutS;
151 Mutex mCleanupThresholdMutex;
152 Condition mCleanupThresholdCondition;
153 unsigned int mCleanupIntervalS;
154 float mCleanupThreshold;
156 ReadWriteMutex mStubMapMutex;
162 typedef boost::shared_ptr<ObjectFactoryService>
163 ObjectFactoryServicePtr;
167 #endif // ! INCLUDE_RCF_OBJECTFACTORYSERVICE_HPP