|
UniSet
2.6.0
|
00001 /* 00002 * Copyright (c) 2015 Pavel Vainerman. 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License as 00006 * published by the Free Software Foundation, version 2.1. 00007 * 00008 * This program is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Lesser General Lesser Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 */ 00016 // -------------------------------------------------------------------------- 00021 // -------------------------------------------------------------------------- 00022 #ifndef UniSetManager_H_ 00023 #define UniSetManager_H_ 00024 // -------------------------------------------------------------------------- 00025 #include <omniORB4/CORBA.h> 00026 #include <memory> 00027 #include "UniSetTypes.h" 00028 #include "UniSetObject.h" 00029 #include "UniSetManager_i.hh" 00030 //--------------------------------------------------------------------------- 00031 namespace uniset 00032 { 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( uniset::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 virtual uniset::ObjectType getType() override 00069 { 00070 return uniset::ObjectType("UniSetManager"); 00071 } 00072 00073 // ------ функции объявленные в интерфейсе(IDL) ------ 00074 virtual void broadcast( const uniset::TransportMessage& msg) override; 00075 virtual uniset::SimpleInfoSeq* getObjectsInfo( CORBA::Long MaxLength = 300, const char* userparam = 0 ) override ; 00076 00077 // -------------------------- 00078 virtual bool add( const std::shared_ptr<UniSetObject>& obj ); 00079 virtual bool remove( const std::shared_ptr<UniSetObject>& obj ); 00080 // -------------------------- 00084 const std::shared_ptr<UniSetManager> itemM(const uniset::ObjectId id); 00085 00089 const std::shared_ptr<UniSetObject> itemO( const uniset::ObjectId id ); 00090 00091 // Функции для работы со списками подчиненных объектов 00092 // --------------- 00093 UniSetManagerList::const_iterator beginMList(); 00094 UniSetManagerList::const_iterator endMList(); 00095 ObjectsList::const_iterator beginOList(); 00096 ObjectsList::const_iterator endOList(); 00097 00098 size_t objectsCount() const; // количество подчиненных объектов 00099 // --------------- 00100 00101 PortableServer::POA_ptr getPOA(); 00102 PortableServer::POAManager_ptr getPOAManager(); 00103 00104 protected: 00105 00106 UniSetManager(); 00107 00108 virtual bool addManager( const std::shared_ptr<UniSetManager>& mngr ); 00109 virtual bool removeManager( const std::shared_ptr<UniSetManager>& mngr ); 00110 virtual bool addObject( const std::shared_ptr<UniSetObject>& obj ); 00111 virtual bool removeObject( const std::shared_ptr<UniSetObject>& obj ); 00112 00113 enum OManagerCommand { deactiv, activ, initial, term }; 00114 friend std::ostream& operator<<(std::ostream& os, uniset::UniSetManager::OManagerCommand& cmd ); 00115 00116 // работа со списком объектов 00117 void objects(OManagerCommand cmd); 00118 // работа со списком менеджеров 00119 void managers(OManagerCommand cmd); 00120 00121 virtual void sigterm( int signo ) override; 00122 00123 void initPOA( const std::weak_ptr<UniSetManager>& rmngr ); 00124 00126 virtual bool activateObject() override; 00128 virtual bool deactivateObject() override; 00129 00130 const std::shared_ptr<UniSetObject> findObject( const std::string& name ); 00131 const std::shared_ptr<UniSetManager> findManager( const std::string& name ); 00132 00133 // рекурсивный поиск по всем объекам 00134 const std::shared_ptr<UniSetObject> deepFindObject( const std::string& name ); 00135 00136 // рекурсивное наполнение списка объектов 00137 void getAllObjectsList( std::vector<std::shared_ptr<UniSetObject>>& vec, size_t lim = 1000 ); 00138 00139 typedef UniSetManagerList::iterator MListIterator; 00140 00141 int getObjectsInfo(const std::shared_ptr<UniSetManager>& mngr, uniset::SimpleInfoSeq* seq, 00142 int begin, const long uplimit, const char* userparam ); 00143 00144 PortableServer::POA_var poa; 00145 PortableServer::POAManager_var pman; 00146 00147 private: 00148 00149 int sig; 00150 UniSetManagerList mlist; 00151 ObjectsList olist; 00152 00153 uniset::uniset_rwmutex olistMutex; 00154 uniset::uniset_rwmutex mlistMutex; 00155 }; 00156 // ------------------------------------------------------------------------- 00157 } // end of uniset namespace 00158 #endif
1.7.6.1