Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / resource-container / src / Configuration.h
1 //******************************************************************
2 //
3 // Copyright 2015 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 #ifndef CONFIGURATION_H_
22 #define CONFIGURATION_H_
23
24 #include <unistd.h>
25 #include <string.h>
26 #include <iostream>
27 #include <fstream>
28 #include <string>
29 #include <vector>
30 #include <map>
31
32 #include "rapidxml/rapidxml.hpp"
33 #include "rapidxml/rapidxml_print.hpp"
34
35 using namespace std;
36
37 namespace OIC
38 {
39     namespace Service
40     {
41         typedef vector< map< string, string > > configInfo;
42
43         struct resourceInfo
44         {
45             string name;
46             string uri;
47             string resourceType;
48             string address;
49             map< string, vector< map< string, string > > > resourceProperty;
50         };
51
52         class Configuration
53         {
54             public:
55                 Configuration();
56                 Configuration(string configFile);
57                 ~Configuration();
58
59                 bool isLoaded() const;
60                 bool isHasInput(std::string & bundleId) const;
61                 void getConfiguredBundles(configInfo *configOutput);
62                 void getBundleConfiguration(string bundleId, configInfo *configOutput);
63                 void getResourceConfiguration(string bundleId, vector< resourceInfo > *configOutput);
64                 void getResourceConfiguration(string bundleId, string resourceName, resourceInfo *resourceInfoOutput);
65
66             private:
67                 void getConfigDocument(string pathConfigFile);
68
69                 bool m_loaded;
70                 string m_pathConfigFile;
71                 string m_strConfigData;
72                 rapidxml::xml_document< char > m_xmlDoc;
73                 std::map<std::string, bool> m_mapisHasInput; // bundleId, isHasInput
74         };
75     }
76 }
77
78 #endif /* CONFIGURATION_H_ */