[Release] livebox.web-provider-1.9
[platform/framework/web/web-provider.git] / src / Core / BoxManager.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Flora License, Version 1.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://floralicense.org/license/
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file    BoxManager.h
18  * @author  Yunchan Cho (yunchan.cho@samsung.com)
19  */
20 #ifndef BOX_MANAGER_H
21 #define BOX_MANAGER_H
22
23 #include <map>
24 #include <string>
25 #include <memory>
26 #include <Plugin/box_plugin_interface.h>
27 #include <Plugin/IBoxPluginFactory.h>
28 #include "BoxData.h"
29 #include "IBox.h"
30 #include "IBoxManager.h"
31
32 #define EXPORT_CLASS    __attribute__ ((visibility("default"))
33
34 class EXPORT_CLASS BoxManager: public IBoxManager {
35     public:
36         static IBoxManagerPtr create(IBoxPluginFactoryPtr factory) 
37         { 
38             return IBoxManagerPtr(new BoxManager(factory)); 
39         };
40         virtual bool doCommand(const request_cmd_type type, const BoxInfoPtr& boxInfo);
41         virtual ~BoxManager();
42
43     protected:
44         virtual bool requestAddBox(BoxInfoPtr boxInfo, EwkContextPtr ewkContext);
45         virtual bool requestRemoveBox(std::string& instanceId);
46         virtual bool requestResizeBox(std::string& instanceId, int width, int height);
47         virtual bool requestResumeBox(std::string& instanceId);
48         virtual bool requestPauseBox(std::string& instanceId);
49         virtual bool requestResumeAll();
50         virtual bool requestPauseAll();
51         virtual bool requestOpenPd(std::string& instanceId, int width, int height);
52         virtual bool requestClosePd(std::string& instanceId);
53         virtual bool requestChangePeriod(std::string& instanceId, float period);
54         // ewk context deleter 
55         struct EwkContextDeleter {
56             void operator()(Ewk_Context* ptr);
57         };
58
59         explicit BoxManager(IBoxPluginFactoryPtr factory);
60
61     private:
62         // map operations
63         void insertBoxMap(std::string& instanceId, IBoxPtr box);
64         void eraseBoxMap(std::string& instanceId);
65         void updateBoxMap(std::string& instanceId, IBoxPtr box);
66         IBoxPtr searchBoxMap(std::string& instanceId);
67         void clearBoxMap();
68
69         typedef std::map<std::string, IBoxPtr> BoxMap;
70         typedef std::pair<std::string, IBoxPtr> BoxMapPair;
71         BoxMap m_boxMap;
72         IBoxPluginFactoryPtr m_boxFactory;
73         EwkContextPtr m_defaultContext;
74 };
75
76 #endif // BOX_MANAGER_H