Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / examples / OICMiddle / OICMiddle.h
1 #ifndef OICMIDDLE_H
2 #define OICMIDDLE_H
3
4 //******************************************************************
5 //
6 // Copyright 2014 Intel Corporation.
7 //
8 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 //      http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 //
22 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23
24 #include <string>
25 #include <cstdlib>
26 #include "OCPlatform.h"
27 #include "OCApi.h"
28
29 class MiddleClient;
30 class MiddleServer;
31 class LineInput;
32 class RestInput;
33 class WrapResource;
34 class HueResources;
35
36 using namespace OC;
37 using namespace std;
38
39 enum AppType {
40     AT_None = 0,
41     AT_Server = 1,
42     AT_Client = 2,
43     AT_Both = 3
44 };
45
46 enum LineResult {
47     LR_OK,
48     LR_NoCommand,
49     LR_NoClient,
50     LR_NoResource,
51     LR_Timeout,
52     LR_Param,
53     LR_Unrecognized,
54     LR_Quit,
55     LR_Syntax,
56     LR_Error
57 };
58
59 class HueResource;
60
61 typedef int token_t;
62 typedef map<string, string> stringmap_t;
63
64 class Middle
65 {
66 public:
67     Middle();
68     ~Middle();
69     void init();
70     void run(int argc, char* argv[]);
71
72 protected:
73     friend class MiddleClient;
74     friend class MiddleServer;
75     friend class RestInput;
76     friend class HueResources;
77
78     AppType m_appType;
79     bool m_useLineInput;
80     bool m_useRestInput;
81     string m_hueAddr;
82     MiddleClient *m_client;
83     MiddleServer *m_server;
84     LineInput *m_lineInput;
85     RestInput *m_restInput;
86
87 protected:
88     void startPlatform();
89     bool parseCommandLineOptions(int argc, char *argv[]);
90     void provideHelp();
91 };
92
93 extern Middle middle;
94
95 #endif // OICMIDDLE_H