37039174d41d88896069801770d1d85c4fbf6bc5
[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(
52                         std::string& instanceId,
53                         int width, int height, double x, double y);
54         virtual bool requestClosePd(std::string& instanceId);
55         virtual bool requestChangePeriod(std::string& instanceId, float period);
56         // ewk context deleter 
57         struct EwkContextDeleter {
58             void operator()(Ewk_Context* ptr);
59         };
60
61         explicit BoxManager(IBoxPluginFactoryPtr factory);
62
63     private:
64         // map operations
65         void insertBoxMap(std::string& instanceId, IBoxPtr box);
66         void eraseBoxMap(std::string& instanceId);
67         void updateBoxMap(std::string& instanceId, IBoxPtr box);
68         IBoxPtr searchBoxMap(std::string& instanceId);
69         void clearBoxMap();
70
71         typedef std::map<std::string, IBoxPtr> BoxMap;
72         typedef std::pair<std::string, IBoxPtr> BoxMapPair;
73         BoxMap m_boxMap;
74         IBoxPluginFactoryPtr m_boxFactory;
75         EwkContextPtr m_defaultContext;
76 };
77
78 #endif // BOX_MANAGER_H