UniSet 2.32.1
UniSetManager.h
1/*
2 * Copyright (c) 2015 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Lesser Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16// --------------------------------------------------------------------------
21// --------------------------------------------------------------------------
22#ifndef UniSetManager_H_
23#define UniSetManager_H_
24// --------------------------------------------------------------------------
25#include <omniORB4/CORBA.h>
26#include <memory>
27#include "UniSetTypes.h"
28#include "UniSetObject.h"
29#include "UniSetManager_i.hh"
30//---------------------------------------------------------------------------
31namespace uniset
32{
33 //---------------------------------------------------------------------------
34 class UniSetActivator;
35
36 class UniSetManager;
37 typedef std::list< std::shared_ptr<UniSetManager> > UniSetManagerList;
38 //---------------------------------------------------------------------------
58 public UniSetObject,
59 public POA_UniSetManager_i
60 {
61 public:
63 UniSetManager( const std::string& name, const std::string& section );
64 virtual ~UniSetManager();
65
66 virtual uniset::ObjectType getType() override
67 {
68 return uniset::ObjectType("UniSetManager");
69 }
70
71 // ------ функции объявленые в интерфейсе(IDL) ------
72 virtual void broadcast( const uniset::TransportMessage& msg) override;
73 virtual uniset::SimpleInfoSeq* getObjectsInfo( CORBA::Long MaxLength = 300, const char* userparam = 0 ) override ;
74
75 // --------------------------
76 virtual bool add( const std::shared_ptr<UniSetObject>& obj );
77 virtual bool remove( const std::shared_ptr<UniSetObject>& obj );
78 // --------------------------
79 size_t objectsCount() const; // количество подчинённых объектов
80 // ---------------
81
82 PortableServer::POA_ptr getPOA();
83 PortableServer::POAManager_ptr getPOAManager();
84 std::shared_ptr<UniSetManager> get_mptr();
85
86 protected:
87
89
90 virtual bool addManager( const std::shared_ptr<UniSetManager>& mngr );
91 virtual bool removeManager( const std::shared_ptr<UniSetManager>& mngr );
92 virtual bool addObject( const std::shared_ptr<UniSetObject>& obj );
93 virtual bool removeObject( const std::shared_ptr<UniSetObject>& obj );
94
95 enum OManagerCommand { deactiv, activ, initial };
96 friend std::ostream& operator<<( std::ostream& os, OManagerCommand& cmd );
97
98 // работа со списком объектов
99 void objects(OManagerCommand cmd);
100 // работа со списком менеджеров
101 void managers(OManagerCommand cmd);
102
103 void initPOA( const std::weak_ptr<UniSetManager>& rmngr );
104
106 virtual bool activateObject() override;
108 virtual bool deactivateObject() override;
109
110 const std::shared_ptr<UniSetObject> findObject( const std::string& name ) const;
111 const std::shared_ptr<UniSetManager> findManager( const std::string& name ) const;
112
113 // рекурсивный поиск по всем объектам
114 const std::shared_ptr<UniSetObject> deepFindObject( const std::string& name ) const;
115
116 // рекурсивное наполнение списка объектов
117 void getAllObjectsList(std::vector<std::shared_ptr<UniSetObject> >& vec, size_t lim = 1000 );
118
119 typedef UniSetManagerList::iterator MListIterator;
120
121 int getObjectsInfo(const std::shared_ptr<UniSetManager>& mngr, uniset::SimpleInfoSeq* seq,
122 int begin, const long uplimit, const char* userparam );
123
124 PortableServer::POA_var poa;
125 PortableServer::POAManager_var pman;
126
127 // Функции для работы со списками подчинённых объектов
128 // ---------------
129 typedef std::function<void(const std::shared_ptr<UniSetObject>&)> OFunction;
130 void apply_for_objects( OFunction f );
131
132 typedef std::function<void(const std::shared_ptr<UniSetManager>&)> MFunction;
133 void apply_for_managers( MFunction f );
134
135 private:
136
137 UniSetManagerList mlist;
138 ObjectsList olist;
139
140 mutable uniset::uniset_rwmutex olistMutex;
141 mutable uniset::uniset_rwmutex mlistMutex;
142 };
143 // -------------------------------------------------------------------------
144} // end of uniset namespace
145#endif
Definition UniSetManager.h:60
void managers(OManagerCommand cmd)
Definition UniSetManager.cc:250
void objects(OManagerCommand cmd)
Definition UniSetManager.cc:348
virtual bool deactivateObject() override
Definition UniSetManager.cc:460
virtual bool activateObject() override
Definition UniSetManager.cc:447
Definition UniSetObject.h:80
Definition Mutex.h:32
Definition Calibration.h:27
std::list< std::shared_ptr< UniSetObject > > ObjectsList
Definition UniSetObject.h:55
string< SizeOfObjectType > ObjectType
Definition UniSetTypes_i.idl:33
long ObjectId
Definition UniSetTypes_i.idl:30
Definition UniSetTypes_i.idl:45