1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef LITEREMOTING_H_
22 #define LITEREMOTING_H_
24 // ============================================================================
26 // ============================================================================
27 #include <boost/shared_ptr.hpp>
28 #include <boost/thread.hpp>
33 using namespace Intel::STC;
35 #include "LiteSessionImpl.h"
36 #include "LiteUUIDLess.hpp"
37 #include "LiteTargetDevice.hpp"
38 #include "LiteTargetDeviceProxy.h"
40 // ============================================================================
42 // ============================================================================
45 // ==========================================================================
47 // ==========================================================================
49 // ============================================================
51 // ============================================================
53 static const std::string APPLICATION_UUID_STRING;
55 // ============================================================
57 // ============================================================
59 typedef boost::shared_ptr<LiteRemoting> Ptr;
61 // ============================================================
63 // ============================================================
65 static boost::shared_ptr<LiteRemoting> getInstance();
67 // ============================================================
68 // Private key for Singleton with shared_ptr
69 // LiteRemoting ctor must be public for make_ptr.
70 // But since we are a singleton, we don't want to allow clients
71 // to call the ctor. Since client can't access
72 // PrivateConstructKey, it can't call the public ctor.
73 // ============================================================
75 struct PrivateConstructKey {};
77 // ============================================================
78 // Constructor and Destructor
79 // ============================================================
81 LiteRemoting(PrivateConstructKey key);
82 virtual ~LiteRemoting();
84 // ============================================================
86 // ============================================================
90 // ============================================================
91 // Private copy constructor for Singleton
92 // ============================================================
94 LiteRemoting(const LiteRemoting&);
96 // ============================================================
98 // ============================================================
101 API::Service::SharedPtr pCCFService_;
102 API::Context::SharedPtr pCCFContext_;
105 std::map <UUID_t, boost::shared_ptr<LiteSessionImpl>, LiteUUIDLess> sessionMap_;
106 std::map <UUID_t, boost::shared_ptr<LiteTargetDeviceProxy>, LiteUUIDLess> targetDeviceProxyMap_;
107 boost::condition_variable cond_;
109 bool apiResultReady_;
111 // ============================================================
113 // ============================================================
116 void queryMySessionId();
117 void queryMySessionInfo();
118 void addSessionToMap(UUID_t sessionId);
119 boost::shared_ptr<LiteSessionImpl> getSessionFromMap(UUID_t sessionId);
120 void addTargetDeviceToMap(UUID_t targetDeviceId);
121 boost::shared_ptr<LiteTargetDeviceProxy> getTargetDeviceFromMap(UUID_t targetDeviceId);
122 void handleNewConnection(UUID_t sessionId, int socket);
123 void handleNewTargetDevice(UUID_t targetDeviceId);
125 // ============================================================
127 // ============================================================
129 void sessionObserver(const API::SessionEvent& sessionEvent);
133 #endif /* LITEREMOTING_H_ */