Change event sync to async
[platform/framework/native/appfw.git] / src / io / inc / FIo_ChannelManager.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 /**
18  * @file        FIo_ChannelManager.h
19  * @brief       This is the header file for the _ChannelManager class.
20  *
21  * This file contains the declarations of _ChannelManager.
22  */
23
24 #ifndef _FIO_INTERNAL_CHANNEL_MANAGER_H_
25 #define _FIO_INTERNAL_CHANNEL_MANAGER_H_
26
27 #include <FBaseResult.h>
28 #include <FBaseObject.h>
29 #include <FBaseString.h>
30 #include <FBaseColHashMapT.h>
31
32 namespace Tizen { namespace Io
33 {
34
35 class _Channel;
36 class _IChannelService;
37 class ClientChannel;
38 class ServerChannel;
39
40 /**
41  * @class _ChannelManager
42  * @brief This class provides methods for managing _Channels
43  * @since 2.1
44  */
45
46 class _ChannelManager
47 {
48 public:
49         static _ChannelManager* GetInstance(void);
50
51         _Channel* GetChannel(const Tizen::Base::String& channelId);
52
53         ClientChannel* GetClientChannel(const Tizen::Base::String& channelName);
54
55         ServerChannel* GetServerChannel(const Tizen::Base::String& channelName);
56
57         void AddClientChannel(const Tizen::Base::String& channelName, ClientChannel* pChannel);
58
59         void AddServerChannel(const Tizen::Base::String& channelName, ServerChannel* pChannel);
60
61 private:
62         _ChannelManager(void);
63
64         ~_ChannelManager(void);
65
66         result Construct(void);
67
68         _ChannelManager(const _ChannelManager& value);
69
70         _ChannelManager& operator =(const _ChannelManager& value);
71
72         class _StringHashProvider
73                 : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
74         {
75         public:
76                 virtual int GetHashCode(const Tizen::Base::String& value) const
77                 {
78                         return value.GetHashCode();
79                 }
80         };
81
82         class _StringComparer
83                 : public Tizen::Base::Collection::IComparerT<Tizen::Base::String>
84         {
85         public:
86                 virtual result Compare(const Tizen::Base::String& string1, const Tizen::Base::String& string2, int& cmp) const
87                 {
88                         cmp = string1.CompareTo(string2);
89                         return E_SUCCESS;
90                 }
91         };
92
93         static void InitSingleton(void);
94
95         static void DestroySingleton(void);
96
97 private:
98         Tizen::Base::Collection::HashMapT <Tizen::Base::String, _Channel*> __channels;
99         Tizen::Base::Collection::HashMapT <Tizen::Base::String, ClientChannel*> __clientChannels;
100         Tizen::Base::Collection::HashMapT <Tizen::Base::String, ServerChannel*> __serverChannels;
101         _IChannelService* __pIChannelService;
102         static _ChannelManager* __pChannelManagerInst;
103 }; // _ChannelManager
104
105 }} // Tizen::Io
106
107 #endif  // _FIO_INTERNAL_CHANNEL_MANAGER_H_