UniSet  2.0.0
UniSetManager.h
См. документацию.
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 "UniSetTypes.h"
00030 #include "UniSetObject.h"
00031 #include "UniSetManager_i.hh"
00032 //---------------------------------------------------------------------------
00033 class UniSetActivator;
00034 
00035 class UniSetManager;
00036 typedef std::list<UniSetManager*> UniSetManagerList;        
00037 //---------------------------------------------------------------------------
00056 class UniSetManager: 
00057     public UniSetObject,
00058     public POA_UniSetManager_i
00059 {
00060     public:
00061         UniSetManager( UniSetTypes::ObjectId id);
00062         UniSetManager( const std::string& name, const std::string& section );
00063         virtual ~UniSetManager();
00064 
00065         virtual UniSetTypes::ObjectType getType() override { return UniSetTypes::ObjectType("UniSetManager"); }
00066 
00067         // ------  функции объявленные в интерфейсе(IDL) ------
00068         virtual void broadcast( const UniSetTypes::TransportMessage& msg) override;
00069         virtual UniSetTypes::SimpleInfoSeq* getObjectsInfo( CORBA::Long MaxLength=300 ) override ;
00070 
00071         // --------------------------
00072         void initPOA(UniSetManager* rmngr);
00073 
00074         virtual bool addObject(UniSetObject *obj);
00075         virtual bool removeObject(UniSetObject *obj);
00076 
00077         virtual bool addManager( UniSetManager *mngr );
00078         virtual bool removeManager( UniSetManager *mngr );
00079 
00080 
00084         const UniSetManager* itemM(const UniSetTypes::ObjectId id);
00085 
00086 
00090         const UniSetObject* itemO( const UniSetTypes::ObjectId id );
00091 
00092 
00093         // Функции для аботы со списками подчиненных объектов
00094         inline UniSetManagerList::const_iterator beginMList()
00095         {
00096             return mlist.begin();
00097         }
00098 
00099         inline UniSetManagerList::const_iterator endMList()
00100         {
00101             return mlist.end();
00102         }
00103 
00104         inline ObjectsList::const_iterator beginOList()
00105         {
00106             return olist.begin();
00107         }
00108 
00109         inline ObjectsList::const_iterator endOList()
00110         {
00111             return olist.end();
00112         }
00113 
00114         int objectsCount();    // количество подчиненных объектов
00115 
00116         PortableServer::POA_ptr getPOA(){ return PortableServer::POA::_duplicate(poa); }
00117         PortableServer::POAManager_ptr getPOAManager(){ return  PortableServer::POAManager::_duplicate(pman); }
00118 
00119     protected:
00120 
00121         UniSetManager();
00122 
00123         enum OManagerCommand{ deactiv, activ, initial, term };
00124         friend std::ostream& operator<<(std::ostream& os, OManagerCommand& cmd );
00125 
00126         // работа со списком объектов
00127         void objects(OManagerCommand cmd);
00128         // работа со списком менеджеров
00129         void managers(OManagerCommand cmd);
00130 
00131         virtual void sigterm( int signo ) override;
00132 
00134         virtual bool activateObject() override;
00136         virtual bool deactivateObject() override;
00137 
00138         typedef UniSetManagerList::iterator MListIterator;
00139 
00140         int getObjectsInfo( UniSetManager* mngr, UniSetTypes::SimpleInfoSeq* seq, 
00141                             int begin, const long uplimit );
00142 
00143         PortableServer::POA_var poa;    
00144         PortableServer::POAManager_var pman;
00145 
00146     private:
00147 
00148         friend class UniSetActivator;
00149 
00150         int sig;
00151         UniSetManagerList mlist;
00152         ObjectsList olist;
00153 
00154         UniSetTypes::uniset_rwmutex olistMutex;
00155         UniSetTypes::uniset_rwmutex mlistMutex;
00156 };
00157 
00158 #endif