UniSet  2.6.0
ProxyManager.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 // --------------------------------------------------------------------------
20 // --------------------------------------------------------------------------
21 #ifndef ProxyManager_H_
22 #define ProxyManager_H_
23 //---------------------------------------------------------------------------
24 #include <unordered_map>
25 #include <memory>
26 #include "UniSetObject.h"
27 
28 //----------------------------------------------------------------------------
29 namespace uniset
30 {
31  //----------------------------------------------------------------------------
32  class PassiveObject;
33  //----------------------------------------------------------------------------
34 
38  class ProxyManager:
39  public UniSetObject
40  {
41 
42  public:
44  ~ProxyManager();
45 
46  void attachObject( PassiveObject* po, uniset::ObjectId id );
47  void detachObject( uniset::ObjectId id );
48 
49  std::shared_ptr<UInterface> uin;
50 
51  protected:
52  ProxyManager();
53  virtual void processingMessage( const uniset::VoidMessage* msg ) override;
54  virtual void allMessage( const uniset::VoidMessage* msg );
55 
56  virtual bool activateObject() override;
57  virtual bool deactivateObject() override;
58 
59  private:
60  typedef std::unordered_map<uniset::ObjectId, PassiveObject*> PObjectMap;
61  PObjectMap omap;
62  };
63  // -------------------------------------------------------------------------
64 } // end of uniset namespace
65 //----------------------------------------------------------------------------------------
66 #endif // ProxyManager
67 //----------------------------------------------------------------------------------------