Go to the documentation of this file.00001 #ifndef maciContainerServices_h
00002 #define maciContainerServices_h
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 #include <acsutil.h>
00032 #include <acsContainerServices.h>
00033 #include <maciComponentStateManager.h>
00034 #include <acscomponentImpl.h>
00035 #include <logging.h>
00036 #include <maciContainerImpl.h>
00037 #include <cdbDALS.h>
00038 #include <acscomponentS.h>
00039 #include <acscommonS.h>
00040 #include <acsErrTypeContainerServices.h>
00041 #include <acsErrTypeLifeCycle.h>
00042 #include <vector>
00043 #include <string>
00044 #include <iterator>
00045
00046 #include <ace/Synch.h>
00047 #include <ace/Hash_Map_Manager.h>
00048
00049 namespace maci {
00050
00051 class ContainerImpl;
00052 class MACIContainerServices;
00053 class ComponentReleaseCallback;
00054
00055
00056 class MyCBlongImpl: public POA_ACS::CBlong {
00057 public:
00058 MyCBlongImpl(ComponentReleaseCallback *cb);
00059 virtual ~MyCBlongImpl();
00060 void working(::CORBA::Long value, const ::ACSErr::Completion & c,
00061 const ::ACS::CBDescOut & desc);
00062 void done(::CORBA::Long value, const ::ACSErr::Completion & c,
00063 const ::ACS::CBDescOut & desc);
00064 ::CORBA::Boolean negotiate(::ACS::TimeInterval time_to_transmit,
00065 const ::ACS::CBDescOut & desc);
00066 private:
00067 ComponentReleaseCallback *callback;
00068 };
00069
00070 class ComponentReleaseCallback {
00071 friend class MACIContainerServices;
00072 friend class MyCBlongImpl;
00073
00074 public:
00075 ComponentReleaseCallback();
00076 virtual ~ComponentReleaseCallback();
00080 virtual void errorNoPermission(std::string message);
00085 virtual void componentReleased(maciErrType::ComponentDeactivationUncleanEx deactivationUncleanEx);
00086 virtual void componentReleased();
00091 virtual void errorComponentReleaseFailed(maciErrType::ComponentDeactivationUncleanEx deactivationFailureEx);
00092
00109 bool awaitComponentRelease(unsigned long timeout);
00110
00111 private:
00112 MyCBlongImpl myCBlong;
00113 ACE_Mutex mutex;
00114
00115 void callOver();
00116 };
00117
00121 class MACIContainerServices: public ContainerServices
00122
00123 {
00124 public:
00125
00129 MACIContainerServices(
00130 const maci::Handle componentHandle,
00131 ACE_CString& name,
00132 ACE_CString& type,
00133 PortableServer::POA_ptr poa);
00134
00138 MACIContainerServices(
00139 const maci::Handle componentHandle,
00140 ACE_CString& name,
00141 PortableServer::POA_ptr poa,
00142 Manager_ptr manager);
00143
00147 virtual ~MACIContainerServices();
00148
00149 public:
00150
00151 void test(const char* txt);
00156 CORBA::Object* getCORBAComponent(const char* name);
00157
00162 CORBA::Object* getCORBAComponentNonSticky(const char* name);
00163
00172 CORBA::Object* getCORBADynamicComponent(maci::ComponentSpec compSpec, bool markAsDefault);
00173
00182 CORBA::Object* getCORBACollocatedComponent(maci::ComponentSpec compSpec, bool markAsDefault, const char* targetComponent);
00183
00190 CORBA::Object* getCORBADefaultComponent(const char* idlType);
00191
00192 public:
00193
00201 ComponentInfo getComponentDescriptor(const char* componentName);
00202
00217 ACE_CString_Vector findComponents(const char *nameWilcard, const char *typeWildcard);
00218
00229 void releaseComponent(const char *name);
00230
00242 void releaseComponent(std::string &name, ComponentReleaseCallback *callback);
00243
00249 void releaseAllComponents();
00250
00260 CDB::DAL_ptr getCDB();
00261
00264 PortableServer::POA_var getOffShootPOA() { return m_offShootPOA; }
00265
00275 ACS::OffShoot_ptr activateOffShoot(PortableServer::Servant cbServant);
00276
00283 void deactivateOffShoot(PortableServer::Servant cbServant);
00284
00289 PortableServer::POA_var createOffShootPOA();
00290
00304 maci::ComponentStateManager* getComponentStateManager();
00305
00313 acsalarm::AlarmSource* getAlarmSource() { return m_alarmSource; }
00314
00315 void fireComponentsUnavailable(ACE_CString_Vector& compNames);
00316 void fireComponentsAvailable(ACE_CString_Vector& compNames);
00317
00318 private:
00319
00321 maci::Manager_var m_manager;
00322
00324 maci::ContainerImpl *m_containerImpl;
00325
00327 PortableServer::POA_var m_offShootPOA;
00328
00330 maci::Handle m_componentHandle;
00331
00333 typedef ACE_Hash_Map_Manager <ACE_CString, maci::Handle, ACE_Recursive_Thread_Mutex> COMPONENT_HASH_MAP;
00334 typedef ACE_Hash_Map_Iterator <ACE_CString, maci::Handle, ACE_Recursive_Thread_Mutex> COMPONENT_HASH_MAP_ITER;
00335 typedef ACE_Hash_Map_Entry <ACE_CString, maci::Handle> COMPONENT_HASH_MAP_ENTRY;
00336
00338 COMPONENT_HASH_MAP m_usedComponents;
00339
00341 maci::ComponentStateManager* componentStateManager_mp;
00342
00344 acsalarm::AlarmSource* m_alarmSource;
00345
00346 };
00347
00348 }
00349
00350 #endif // maciContainerServices_h
00351