|
UniSet
2.2.1
|
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 UniSetManager_H_ 00026 #define UniSetManager_H_ 00027 // -------------------------------------------------------------------------- 00028 #include <omniORB4/CORBA.h> 00029 #include <memory> 00030 #include "UniSetTypes.h" 00031 #include "UniSetObject.h" 00032 #include "UniSetManager_i.hh" 00033 //--------------------------------------------------------------------------- 00034 class UniSetActivator; 00035 00036 class UniSetManager; 00037 typedef std::list< std::shared_ptr<UniSetManager> > UniSetManagerList; 00038 //--------------------------------------------------------------------------- 00057 class UniSetManager: 00058 public UniSetObject, 00059 public POA_UniSetManager_i 00060 { 00061 public: 00062 UniSetManager( UniSetTypes::ObjectId id); 00063 UniSetManager( const std::string& name, const std::string& section ); 00064 virtual ~UniSetManager(); 00065 00066 std::shared_ptr<UniSetManager> get_mptr() 00067 { 00068 return std::dynamic_pointer_cast<UniSetManager>(get_ptr()); 00069 } 00070 00071 virtual UniSetTypes::ObjectType getType() override 00072 { 00073 return UniSetTypes::ObjectType("UniSetManager"); 00074 } 00075 00076 // ------ функции объявленные в интерфейсе(IDL) ------ 00077 virtual void broadcast( const UniSetTypes::TransportMessage& msg) override; 00078 virtual UniSetTypes::SimpleInfoSeq* getObjectsInfo( CORBA::Long MaxLength = 300, CORBA::Long userparam = 0 ) override ; 00079 00080 // -------------------------- 00081 virtual bool add( const std::shared_ptr<UniSetObject>& obj ); 00082 virtual bool remove( const std::shared_ptr<UniSetObject>& obj ); 00083 // -------------------------- 00087 const std::shared_ptr<UniSetManager> itemM(const UniSetTypes::ObjectId id); 00088 00092 const std::shared_ptr<UniSetObject> itemO( const UniSetTypes::ObjectId id ); 00093 00094 // Функции для аботы со списками подчиненных объектов 00095 inline UniSetManagerList::const_iterator beginMList() 00096 { 00097 return mlist.begin(); 00098 } 00099 00100 inline UniSetManagerList::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 PortableServer::POA_ptr getPOA() 00118 { 00119 return PortableServer::POA::_duplicate(poa); 00120 } 00121 PortableServer::POAManager_ptr getPOAManager() 00122 { 00123 return PortableServer::POAManager::_duplicate(pman); 00124 } 00125 00126 protected: 00127 00128 UniSetManager(); 00129 00130 virtual bool addManager( const std::shared_ptr<UniSetManager>& mngr ); 00131 virtual bool removeManager( const std::shared_ptr<UniSetManager>& mngr ); 00132 virtual bool addObject( const std::shared_ptr<UniSetObject>& obj ); 00133 virtual bool removeObject( const std::shared_ptr<UniSetObject>& obj ); 00134 00135 enum OManagerCommand { deactiv, activ, initial, term }; 00136 friend std::ostream& operator<<(std::ostream& os, OManagerCommand& cmd ); 00137 00138 // работа со списком объектов 00139 void objects(OManagerCommand cmd); 00140 // работа со списком менеджеров 00141 void managers(OManagerCommand cmd); 00142 00143 virtual void sigterm( int signo ) override; 00144 00145 void initPOA( const std::weak_ptr<UniSetManager>& rmngr ); 00146 00148 virtual bool activateObject() override; 00150 virtual bool deactivateObject() override; 00151 00152 typedef UniSetManagerList::iterator MListIterator; 00153 00154 int getObjectsInfo(const std::shared_ptr<UniSetManager>& mngr, UniSetTypes::SimpleInfoSeq* seq, 00155 int begin, const long uplimit, CORBA::Long userparam ); 00156 00157 PortableServer::POA_var poa; 00158 PortableServer::POAManager_var pman; 00159 00160 private: 00161 00162 int sig; 00163 UniSetManagerList mlist; 00164 ObjectsList olist; 00165 00166 UniSetTypes::uniset_rwmutex olistMutex; 00167 UniSetTypes::uniset_rwmutex mlistMutex; 00168 }; 00169 00170 #endif
1.7.6.1