00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef _TWEEK_CORBA_SERVICE_H_
00038 #define _TWEEK_CORBA_SERVICE_H_
00039
00040 #include <tweek/tweekConfig.h>
00041
00042 #include <string>
00043 #include <list>
00044 #include TWEEK_INCLUDE_CORBA_H
00045
00046 #include <vpr/vpr.h>
00047 #include <vpr/Thread/Thread.h>
00048 #include <tweek/CORBA/SubjectManager.h>
00049
00050
00051 namespace tweek
00052 {
00053
00058 class CorbaService
00059 {
00060 public:
00076 CorbaService(const std::string& nsHost, vpr::Uint16 nsPort = 2809,
00077 const std::string& iiopVersion = std::string("1.0"),
00078 const std::string& subContextId = std::string(""));
00079
00088 ~CorbaService()
00089 {
00090 shutdown();
00091
00092 if ( mOrbThread != NULL )
00093 {
00094 delete mOrbThread;
00095 mOrbThread = NULL;
00096 delete mOrbFunctor;
00097 mOrbFunctor = NULL;
00098 }
00099 }
00100
00101 vpr::ReturnStatus init(int& argc, char* argv[]);
00102
00113 void shutdown(bool waitForCompletion = true);
00114
00122 bool isValid() const
00123 {
00124 return ! (CORBA::is_nil(mORB) || CORBA::is_nil(mRootPOA));
00125 }
00126
00127 const std::string& getNameServiceURI() const
00128 {
00129 return mNameServiceURI;
00130 }
00131
00132 const CosNaming::NamingContext_var getLocalContext()
00133 {
00134 return mLocalContext;
00135 }
00136
00149 std::list<tweek::SubjectManager_var> getSubjectManagerList();
00150
00155 void setSubjectManager(tweek::SubjectManager_var mgr)
00156 {
00157 this->mSubjectManager = mgr;
00158 }
00159
00168 tweek::SubjectManager_var getSubjectManager() const
00169 {
00170 return mSubjectManager;
00171 }
00172
00184 PortableServer::ObjectId_var registerObject(PortableServer::ServantBase* servant,
00185 const std::string& name);
00186
00194 void unregisterObject(PortableServer::ObjectId_var id);
00195
00200 void run();
00201
00202 private:
00203 vpr::ReturnStatus initRootPOA();
00204
00214 void addSubjectManagers(const CosNaming::BindingList& bindingList,
00215 std::list<tweek::SubjectManager_var>& mgrList);
00216
00217 vpr::ThreadRunFunctor<tweek::CorbaService>* mOrbFunctor;
00218 vpr::Thread* mOrbThread;
00219
00220 std::string mNsHost;
00221 vpr::Uint16 mNsPort;
00222 std::string mNameServiceURI;
00223
00224 CORBA::ORB_var mORB;
00225 PortableServer::POA_var mRootPOA;
00226
00227
00228 std::string mSubContextId;
00229 CosNaming::NamingContext_var mRootContext;
00230 CosNaming::NamingContext_var mLocalContext;
00231
00232 tweek::SubjectManager_var mSubjectManager;
00233 };
00234
00235 }
00236
00237
00238 #endif