UniSet  2.6.0
ProxyManager.h
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 // --------------------------------------------------------------------------
00020 // --------------------------------------------------------------------------
00021 #ifndef ProxyManager_H_
00022 #define ProxyManager_H_
00023 //---------------------------------------------------------------------------
00024 #include <unordered_map>
00025 #include <memory>
00026 #include "UniSetObject.h"
00027 
00028 //----------------------------------------------------------------------------
00029 namespace uniset
00030 {
00031 //----------------------------------------------------------------------------
00032 class PassiveObject;
00033 //----------------------------------------------------------------------------
00034 
00038 class ProxyManager:
00039     public UniSetObject
00040 {
00041 
00042     public:
00043         ProxyManager( uniset::ObjectId id );
00044         ~ProxyManager();
00045 
00046         void attachObject( PassiveObject* po, uniset::ObjectId id );
00047         void detachObject( uniset::ObjectId id );
00048 
00049         std::shared_ptr<UInterface> uin;
00050 
00051     protected:
00052         ProxyManager();
00053         virtual void processingMessage( const uniset::VoidMessage* msg ) override;
00054         virtual void allMessage( const uniset::VoidMessage* msg );
00055 
00056         virtual bool activateObject() override;
00057         virtual bool deactivateObject() override;
00058 
00059     private:
00060         typedef std::unordered_map<uniset::ObjectId, PassiveObject*> PObjectMap;
00061         PObjectMap omap;
00062 };
00063 // -------------------------------------------------------------------------
00064 } // end of uniset namespace
00065 //----------------------------------------------------------------------------------------
00066 #endif // ProxyManager
00067 //----------------------------------------------------------------------------------------