Merge "Revert "Fix N_SE-46938 for tz list."" into devel_3.0_main
[platform/framework/native/appfw.git] / src / io / inc / FIo_MessagePortManagerImpl.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  * @file                FIo_MessagePortManagerImpl.h
18  * @brief               This is the header file for the %_MessagePortManagerImpl class.
19  *
20  * This header file contains the declarations of the %_MessagePortManagerImpl class.
21  */
22 #ifndef _FIO_INTERNAL_MESSAGE_PORT_MANAGER_H_
23 #define _FIO_INTERNAL_MESSAGE_PORT_MANAGER_H_
24
25 #include <FBaseResult.h>
26 #include <FBaseObject.h>
27 #include <FBaseDataType.h>
28 #include <FBaseColHashMapT.h>
29 #include <FAppTypes.h>
30
31 namespace Tizen { namespace Io
32 {
33
34 class LocalMessagePort;
35 class RemoteMessagePort;
36
37 class _OSP_EXPORT_ _MessagePortManagerImpl
38 {
39 public:
40         virtual ~_MessagePortManagerImpl(void);
41
42         static _MessagePortManagerImpl* GetInstance(void);
43
44         LocalMessagePort* RequestLocalMessagePort(const Tizen::Base::String& localPort);
45         RemoteMessagePort* RequestRemoteMessagePort(const Tizen::App::AppId& remoteAppId, const Tizen::Base::String& remotePort);
46
47         LocalMessagePort* RequestTrustedLocalMessagePort(const Tizen::Base::String& localPort);
48         RemoteMessagePort* RequestTrustedRemoteMessagePort(const Tizen::App::AppId& remoteAppId, const Tizen::Base::String& remotePort);
49
50         RemoteMessagePort* GetRemoteMessagePort(const Tizen::App::AppId& remoteAppId, const Tizen::Base::String& remotePort, bool isTrusted);
51
52 private:
53         _MessagePortManagerImpl(void);
54         _MessagePortManagerImpl(const _MessagePortManagerImpl& channelManagerImpl);
55         _MessagePortManagerImpl& operator =(const _MessagePortManagerImpl& channelManagerImpl);
56
57         result Construct(void);
58
59         static void InitSingleton(void);
60
61         static void DestroySingleton(void);
62
63 private:
64         class _StringHashProvider
65                 : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
66         {
67         public:
68                 virtual int GetHashCode(const Tizen::Base::String& value) const
69                 {
70                         return value.GetHashCode();
71                 }
72         };
73
74         class _StringComparer
75                 : public Tizen::Base::Collection::IComparerT<Tizen::Base::String>
76         {
77         public:
78                 virtual result Compare(const Tizen::Base::String& string1, const Tizen::Base::String& string2, int& cmp) const
79                 {
80                         cmp = string1.CompareTo(string2);
81                         return E_SUCCESS;
82                 }
83         };
84
85 private:
86         Tizen::Base::Collection::HashMapT<Tizen::Base::String, LocalMessagePort*> __localPorts;
87         Tizen::Base::Collection::HashMapT<Tizen::Base::String, LocalMessagePort*> __trustLocalPorts;
88         Tizen::Base::Collection::HashMapT<Tizen::Base::String, RemoteMessagePort*> __remotePorts;
89         Tizen::Base::Collection::HashMapT<Tizen::Base::String, RemoteMessagePort*> __trustRemotePorts;
90         static _MessagePortManagerImpl* __pMessagePortMgrImplInst;
91
92 }; // _MessagePortManagerImpl
93
94 } } // Tizen::Io
95
96 #endif //_FIO_INTERNAL_MESSAGE_PORT_MANAGER_H_