RDK Documentation (Open Sourced RDK Components)
Executors.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18 */
19 
20 
21 /**
22 * @defgroup trm
23 * @{
24 * @defgroup qtapp
25 * @{
26 **/
27 
28 
29 #include <vector>
30 #include <iostream>
31 
32 #include "trm/TRM.h"
33 #include "trm/Messages.h"
34 #include "trm/JsonEncoder.h"
35 #include "trm/Header.h"
36 
37 #include "Connection.h"
38 
39 #ifndef TRM_EXECUTORS_H_
40 #define TRM_EXECUTORS_H_
41 
42 TRM_BEGIN_NAMESPACE
43 template<class InT>
44 class Executor
45 {
46  friend void Execute(Executor<InT> &);
47  friend void Execute(Executor<ReserveTuner> &, const std::string &);
48 
49 public:
50  typedef typename InT::ResponseType OutT;
51  Executor(const InT & messageIn, uint32_t clientId) : messageIn(messageIn), messageOut(messageIn.getUUID()), clientId(clientId) {}
52  const InT & getRequest (void) const {return messageIn;}
53  const OutT & getResponse(void) const {
54  if (messageOut.getClassName().compare(NoResponse::klassName())) {
55  throw InvalidOperationException();
56  }
57  return messageOut;
58  }
59  void operator() (void) {
60  std::cout << "[EXEC]-" << clientId << "|" << messageIn.getClassName() << std::endl;
61  Execute(*this);
62  }
63 
64  uint32_t getClientId(void) const {return clientId;}
65 private:
66  const InT &messageIn;
67  OutT messageOut;
68  uint32_t clientId;
69 };
70 
71 void Execute(Executor<ReserveTuner> &);
72 void Execute(Executor<ReleaseTunerReservation> &);
74 void Execute(Executor<CancelRecording> &);
75 void Execute(Executor<CancelRecordingResponse> &);
76 void Execute(Executor<GetAllTunerIds> &);
77 void Execute(Executor<GetAllTunerStates> &);
78 void Execute(Executor<GetAllReservations> &);
79 void Execute(Executor<ReserveTuner> &, const std::string &);
80 void Execute(Executor<GetVersion> &exec);
81 void Execute(Executor<CancelLive> &exec);
82 void Execute(Executor<CancelLiveResponse> &exec);
83 void Execute(Executor<UpdateTunerActivityStatus> &exec);
84 
85 TRM_END_NAMESPACE
86 
87 #endif
88 
89 
90 /** @} */
91 /** @} */
Header.h
Messages.h
Executor
Definition: Executors.h:44