Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / scene-manager / src / SceneCommons.h
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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  * @file
23  *
24  * This file contains the declaration of SceneUtils class and constant variables.
25  */
26
27 #ifndef SCENE_COMMONS_H
28 #define SCENE_COMMONS_H
29
30 #include <string>
31 #include <vector>
32
33 #include "OCApi.h"
34 #include "RCSRemoteResourceObject.h"
35
36 namespace OIC
37 {
38     namespace Service
39     {
40         const std::string SCENE_LIST_DEFAULT_NAME = "list of scene Collections";
41
42         const std::string SCENE_KEY_LAST_SCENE = "lastScene";
43         const std::string SCENE_KEY_SCENEVALUES = "sceneValues";
44         const std::string SCENE_KEY_NAME = "n";
45         const std::string SCENE_KEY_ID = "id";
46         const std::string SCENE_KEY_RTS = "rts";
47         const std::string SCENE_KEY_RT = "rt";
48         const std::string SCENE_KEY_IF = "if";
49         const std::string SCENE_KEY_PAYLOAD_LINK = "link";
50         const std::string SCENE_KEY_SCENEMAPPINGS = "sceneMappings";
51         const std::string SCENE_KEY_HREF = "href";
52         const std::string SCENE_KEY_SCENE = "scene";
53         const std::string SCENE_KEY_MEMBERPROPERTY = "memberProperty";
54         const std::string SCENE_KEY_MEMBERVALUE = "memberValue";
55         const std::string SCENE_KEY_CREATEDLINK = "createdlink";
56
57         const std::string SCENE_KEY_URI = "uri";
58         const std::string SCENE_KEY_CHILD = "child";
59
60         const std::string SCENE_LIST_RT = "oic.wk.scenelist";
61         const std::string SCENE_MEMBER_RT = "oic.wk.scenemember";
62         const std::string SCENE_COLLECTION_RT = "oic.wk.scenecollection";
63
64         const std::string COAP_TAG = "coap://";
65         const std::string SCENE_LIST_URI = "/SceneListResURI";
66         const std::string PREFIX_SCENE_COLLECTION_URI = "/a/sceneCollection";
67         const std::string PREFIX_SCENE_MEMBER_URI = "/a/sceneMember";
68
69         const std::string LINK_BATCH = "oic.if.lb";
70         const std::string BASELINE_IF = "oic.if.baseline";
71
72         const OCConnectivityType SCENE_CONNECTIVITY = CT_ADAPTER_IP;
73         const std::string SCENE_CLIENT_REQ_IF = BASELINE_IF;
74         const std::string SCENE_CLIENT_CREATE_REQ_IF = OC::BATCH_INTERFACE;
75
76         const int SCENE_RESPONSE_SUCCESS = 200;
77         const int SCENE_CLIENT_BADREQUEST = 400;
78         const int SCENE_SERVER_INTERNALSERVERERROR = 500;
79
80         class SceneUtils
81         {
82         public:
83             /**
84              * Returns UUID for Scene collection resource and members ID.
85              *
86              * @throw RCSException
87              */
88             static std::string OICGenerateUUIDStr();
89
90             /**
91              * Returns host resource's address and uri from coap address.
92              *
93              * @param address uri of host resource (e.g. coap://192.168.0.2:12345/a/light)
94              * @param[out] host host resource's address (e.g. 192.168.0.2:12345)
95              * @param[out] uri host resource's uri (e.g. /a/light)
96              *
97              * @throw RCSInvalidParameterException
98              */
99             static void getHostUriString(
100                     const std::string address, std::string *host, std::string *uri);
101
102             /**
103              * Returns information of my own network address.
104              *
105              * This functionality use the CA interface for getting network information.
106              * But It has design issue. So, It will should change to other interface.
107              *
108              * @throw RCSException
109              */
110             static std::string getNetAddress();
111
112             /**
113             * Returns RCSRemoteResourceObject pointer created with provided resource information.
114             *
115             * @param address uri of resource (e.g. coap://192.168.0.2:12345/a/light)
116             * @param ct OCConnectivityType type of connectivity indicating the interface
117             * @param vecRT a vector of resource types implemented by the resource
118             * @param vecIF a vector of interfaces that the resource supports/implements
119             *
120             * @throw RCSException
121             */
122             static RCSRemoteResourceObject::Ptr createRCSResourceObject(
123                 const std::string &address, const OCConnectivityType ct,
124                 const std::vector< std::string > &vecRT, const std::vector< std::string > &vecIF);
125         };
126     }
127 }
128
129 #endif // SCENE_COMMONS_H