tizen 2.3 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / MessagePort / EventLocalMessagePortListener.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        EventLocalMessagePortListener.h
20  * @version     0.1
21  * @brief
22  * ##
23  */
24
25 #ifndef _API_MESSAGE_PORT_EVENT_LOCAL_MESSAGE_PORT_LISTENER_H_
26 #define _API_MESSAGE_PORT_EVENT_LOCAL_MESSAGE_PORT_LISTENER_H_
27
28 #include <string>
29 #include <dpl/shared_ptr.h>
30 #include <Commons/IEvent.h>
31 #include <Commons/ListenerEvent.h>
32 #include <Commons/ListenerEventEmitter.h>
33 #include "IRemoteMessagePort.h"
34 #include "MessagePortDataItem.h"
35
36 namespace DeviceAPI {
37 namespace MessagePort {
38
39 class IRemoteMessagePort;
40 typedef DPL::SharedPtr<IRemoteMessagePort> RemoteMessagePortPtr;
41
42 class EventLocalMessagePortListener : public WrtDeviceApis::Commons::ListenerEvent<EventLocalMessagePortListener>
43 {
44 private:
45     /* result */
46     MessagePortDataItemMapPtr m_data;
47     RemoteMessagePortPtr m_remoteMessagePort;
48
49     bool m_dataIsSet;
50     bool m_remoteMessagePortIsSet;
51
52 public:
53     EventLocalMessagePortListener() :
54         m_dataIsSet(false),
55         m_remoteMessagePortIsSet(false)
56     {
57     }
58
59     void setData(const MessagePortDataItemMapPtr &data)
60     {
61         m_data = data;
62         m_dataIsSet = true;
63     }
64
65     MessagePortDataItemMapPtr getData() const
66     {
67         return m_data;
68     }
69
70     bool getDataIsSet() const
71     {
72         return m_dataIsSet;
73     }
74
75     void setRemoteMessagePort(const RemoteMessagePortPtr &remoteMessagePort)
76     {
77         m_remoteMessagePort = remoteMessagePort;
78         m_remoteMessagePortIsSet = true;
79     }
80
81     RemoteMessagePortPtr getRemoteMessagePort() const
82     {
83         return m_remoteMessagePort;
84     }
85
86     bool getRemoteMessagePortIsSet() const
87     {
88         return m_remoteMessagePortIsSet;
89     }
90 };
91 typedef DPL::SharedPtr<EventLocalMessagePortListener> EventLocalMessagePortListenerPtr;
92
93 typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventLocalMessagePortListener> EventLocalMessagePortListenerEmitter;
94 typedef DPL::SharedPtr<EventLocalMessagePortListenerEmitter> EventLocalMessagePortListenerEmitterPtr;
95
96 } // MessagePort
97 } // DeviceAPI
98
99 #endif // _API_MESSAGE_PORT_EVENT_LOCAL_MESSAGE_PORT_LISTENER_H_