UniSet
1.4.0
|
00001 /* This file is part of the UniSet project 00002 * Copyright (c) 2002 Free Software Foundation, Inc. 00003 * Copyright (c) 2002 Pavel Vainerman 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 // -------------------------------------------------------------------------- 00024 // -------------------------------------------------------------------------- 00025 #ifndef ObjectsManager_H_ 00026 #define ObjectsManager_H_ 00027 // -------------------------------------------------------------------------- 00028 #include <omniORB4/CORBA.h> 00029 #include "UniSetTypes.h" 00030 #include "UniSetObject.h" 00031 #include "ObjectsManager_i.hh" 00032 //--------------------------------------------------------------------------- 00033 class ObjectsActivator; 00034 00035 class ObjectsManager; 00036 typedef std::list<ObjectsManager*> ObjectsManagerList; 00037 //--------------------------------------------------------------------------- 00056 class ObjectsManager: 00057 public UniSetObject, 00058 public POA_ObjectsManager_i 00059 { 00060 public: 00061 ObjectsManager( UniSetTypes::ObjectId id); 00062 ObjectsManager( const std::string name, const std::string section ); 00063 virtual ~ObjectsManager(); 00064 00065 00066 virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::getObjectType("ObjectsManager"); } 00067 00068 // ------ функции объявленные в интерфейсе(IDL) ------ 00069 virtual void broadcast(const UniSetTypes::TransportMessage& msg); 00070 virtual UniSetTypes::SimpleInfoSeq* getObjectsInfo( CORBA::Long MaxLength=300 ); 00071 00072 // -------------------------- 00073 void initPOA(ObjectsManager* rmngr); 00074 00075 virtual bool addObject(UniSetObject *obj); 00076 virtual bool removeObject(UniSetObject *obj); 00077 00078 virtual bool addManager( ObjectsManager *mngr ); 00079 virtual bool removeManager( ObjectsManager *mngr ); 00080 00081 00085 const ObjectsManager* itemM(const UniSetTypes::ObjectId id); 00086 00087 00091 const UniSetObject* itemO( const UniSetTypes::ObjectId id ); 00092 00093 00094 // Функции для аботы со списками подчиненных объектов 00095 inline ObjectsManagerList::const_iterator beginMList() 00096 { 00097 return mlist.begin(); 00098 } 00099 00100 inline ObjectsManagerList::const_iterator endMList() 00101 { 00102 return mlist.end(); 00103 } 00104 00105 inline ObjectsList::const_iterator beginOList() 00106 { 00107 return olist.begin(); 00108 } 00109 00110 inline ObjectsList::const_iterator endOList() 00111 { 00112 return olist.end(); 00113 } 00114 00115 int objectsCount(); // количество подчиненных объектов 00116 00117 00118 PortableServer::POA_ptr getPOA(){ return PortableServer::POA::_duplicate(poa); } 00119 PortableServer::POAManager_ptr getPOAManager(){ return PortableServer::POAManager::_duplicate(pman); } 00120 00121 protected: 00122 00123 ObjectsManager(); 00124 00125 enum OManagerCommand{deactiv, activ, initial, term}; 00126 00127 // работа со списком объектов 00128 void objects(OManagerCommand cmd); 00129 // работа со списком менеджеров 00130 void managers(OManagerCommand cmd); 00131 00132 virtual void sigterm( int signo ); 00133 00135 virtual bool activateObject(); 00137 virtual bool disactivateObject(); 00138 00139 00140 typedef ObjectsManagerList::iterator MListIterator; 00141 00142 int getObjectsInfo( ObjectsManager* mngr, UniSetTypes::SimpleInfoSeq* seq, 00143 int begin, const long uplimit ); 00144 00145 PortableServer::POA_var poa; 00146 PortableServer::POAManager_var pman; 00147 00148 private: 00149 00150 friend class ObjectsActivator; 00151 00152 int sig; 00153 ObjectsManagerList mlist; 00154 ObjectsList olist; 00155 00156 UniSetTypes::uniset_mutex olistMutex; 00157 UniSetTypes::uniset_mutex mlistMutex; 00158 00159 }; 00160 00161 #endif