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