• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

maciContainerServices.h

Go to the documentation of this file.
00001 
00002 #ifndef maciContainerServices_h
00003 #define maciContainerServices_h
00004 /*******************************************************************************
00005  *    ALMA - Atacama Large Millimiter Array
00006  *    (c) European Southern Observatory, 2002
00007  *    Copyright by ESO (in the framework of the ALMA collaboration)
00008  *    and Cosylab 2002, All rights reserved
00009  *
00010  *    This library is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 2.1 of the License, or (at your option) any later version.
00014  *
00015  *    This library is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with this library; if not, write to the Free Software
00022  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00023  *
00024  *
00025  * "@(#) $Id: maciContainerServices.h,v 1.40 2012/05/18 06:54:45 bjeram Exp $"
00026  *
00027  * who       when      what
00028  * --------  --------  ----------------------------------------------
00029  * rcirami   27/11/03  created 
00030  */
00031 
00032 #include <acsutil.h>
00033 #ifndef MAKE_VXWORKS
00034 #include <AlarmSourceImpl.h>
00035 #include <acsContainerServices.h>
00036 #endif
00037 #include <maciComponentStateManager.h>
00038 #include <acscomponentImpl.h>
00039 #include <logging.h>
00040 #include <maciContainerImpl.h>
00041 #include <cdbDALS.h>
00042 #include <acscomponentS.h>
00043 #include <acscommonS.h>
00044 #include <acsErrTypeContainerServices.h>
00045 #include <acsErrTypeLifeCycle.h>
00046 #include <vector>
00047 #include <string>
00048 #include <iterator>
00049 
00050 #include <ace/Synch.h>
00051 #include <ace/Hash_Map_Manager.h>
00052 
00053 namespace maci {
00054         
00055 class ContainerImpl;
00056 class MACIContainerServices;
00057 class ComponentReleaseCallback;
00058 
00059 //Dummy CBlong Callback implementation
00060 class MyCBlongImpl: public POA_ACS::CBlong {
00061 public:
00062     MyCBlongImpl(ComponentReleaseCallback *cb);
00063     virtual ~MyCBlongImpl();
00064     void working(::CORBA::Long value, const ::ACSErr::Completion & c,
00065             const ::ACS::CBDescOut & desc);
00066     void done(::CORBA::Long value, const ::ACSErr::Completion & c,
00067             const ::ACS::CBDescOut & desc);
00068     ::CORBA::Boolean negotiate(::ACS::TimeInterval time_to_transmit,
00069             const ::ACS::CBDescOut & desc);
00070 private:
00071     ComponentReleaseCallback *callback;
00072 };
00073 
00074 class ComponentReleaseCallback {
00075     friend class MACIContainerServices;
00076     friend class MyCBlongImpl;
00077 
00078 public:
00079     ComponentReleaseCallback();
00080     virtual ~ComponentReleaseCallback();
00084     virtual void errorNoPermission(std::string message);
00089     virtual void componentReleased(maciErrType::ComponentDeactivationUncleanEx deactivationUncleanEx);
00090     virtual void componentReleased();
00095     virtual void errorComponentReleaseFailed(maciErrType::ComponentDeactivationUncleanEx deactivationFailureEx);
00096 
00113     bool awaitComponentRelease(unsigned long timeout);
00114 
00115 private:
00116     MyCBlongImpl myCBlong;
00117     ACE_Mutex mutex;
00118 
00119     void callOver();
00120 };
00121 
00125 class MACIContainerServices: public ContainerServices
00126 
00127 {
00128   public:
00129   
00133   MACIContainerServices(
00134     const maci::Handle componentHandle, 
00135     ACE_CString& name,
00136     ACE_CString& type,
00137     PortableServer::POA_ptr poa
00138 #ifndef MAKE_VXWORKS
00139     ,const acsalarm::AlarmSourceThread* alarmSourceThread_p
00140 #endif
00141     );
00142 
00146   MACIContainerServices(
00147                   const maci::Handle componentHandle,
00148                   ACE_CString& name,
00149                   PortableServer::POA_ptr poa,
00150                   Manager_ptr manager);
00151 
00155   virtual ~MACIContainerServices();
00156  
00157   public:
00158  
00159     void test(const char* txt);
00164     CORBA::Object* getCORBAComponent(const char* name);
00165 
00170     CORBA::Object* getCORBAComponentNonSticky(const char* name);
00171     
00180     CORBA::Object* getCORBADynamicComponent(maci::ComponentSpec compSpec, bool markAsDefault);
00181     
00190     CORBA::Object* getCORBACollocatedComponent(maci::ComponentSpec compSpec, bool markAsDefault, const char* targetComponent);
00191     
00198     CORBA::Object* getCORBADefaultComponent(const char* idlType);
00199   
00200  public:
00201 
00209   ComponentInfo getComponentDescriptor(const char* componentName);
00210 
00225   ACE_CString_Vector findComponents(const char *nameWilcard, const char *typeWildcard);
00226 
00237     void releaseComponent(const char *name);
00238     
00250     void releaseComponent(std::string &name, ComponentReleaseCallback *callback);
00251 
00257     void releaseAllComponents();
00258 
00268   CDB::DAL_ptr getCDB();
00269   
00272   PortableServer::POA_var getOffShootPOA() { return m_offShootPOA; }
00273 
00283   ACS::OffShoot_ptr activateOffShoot(PortableServer::Servant cbServant);
00284   
00291   void deactivateOffShoot(PortableServer::Servant cbServant);
00292   
00297   PortableServer::POA_var createOffShootPOA();
00298   
00312    maci::ComponentStateManager* getComponentStateManager();
00313 
00321 #ifndef MAKE_VXWORKS
00322    acsalarm::AlarmSource* getAlarmSource() {
00323            if (m_alarmSource==NULL) {
00324                    m_alarmSource = new acsalarm::AlarmSourceImpl(m_alarmSourceThread_p);
00325                    m_alarmSource->start();
00326            }
00327            return m_alarmSource;
00328    }
00329 #endif
00330     void fireComponentsUnavailable(ACE_CString_Vector& compNames);
00331     void fireComponentsAvailable(ACE_CString_Vector& compNames);
00332 
00333  private:
00334 
00336   maci::Manager_var m_manager;
00337 
00339   maci::ContainerImpl *m_containerImpl;
00340   
00342   PortableServer::POA_var m_offShootPOA; 
00343   
00345   maci::Handle m_componentHandle;
00346   
00348   typedef ACE_Hash_Map_Manager <ACE_CString, maci::Handle, ACE_Recursive_Thread_Mutex> COMPONENT_HASH_MAP;
00349   typedef ACE_Hash_Map_Iterator <ACE_CString, maci::Handle, ACE_Recursive_Thread_Mutex> COMPONENT_HASH_MAP_ITER;
00350   typedef ACE_Hash_Map_Entry <ACE_CString, maci::Handle> COMPONENT_HASH_MAP_ENTRY;
00351 
00353   COMPONENT_HASH_MAP m_usedComponents;
00354 
00356   maci::ComponentStateManager* componentStateManager_mp;
00357 
00358   // The thread to update the alarm sources
00359   const acsalarm::AlarmSourceThread* m_alarmSourceThread_p;
00360 
00361 #ifndef MAKE_VXWORKS
00362   acsalarm::AlarmSource* m_alarmSource;
00363 #endif
00364 
00365 };
00366 
00367 } // end namespace maci
00368 
00369 #endif // maciContainerServices_h
00370 

Generated on Mon May 4 2015 08:27:43 for ACS-2015.4 C++ API by  doxygen 1.7.0