Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / things-manager / sdk / inc / ActionSet.h
1 //******************************************************************
2 //
3 // Copyright 2014 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 __OC_ACTIONSET__
22 #define __OC_ACTIONSET__
23
24 #include <string>
25 #include <vector>
26 #include <cstdio>
27 #include <iostream>
28
29 #include <ctime>
30
31 #include <timer.h>
32
33 using namespace std;
34
35 namespace OIC
36 {
37 enum ACTIONSET_TYPE
38 {
39     NONE = 0, SCHEDULED, RECURSIVE
40 };
41
42 typedef tm OCTime;
43
44 /**
45  * @class       Time
46  * @brief       This class provides time-related information used for scheduled/recursive group action
47  *          features. Along with time-related variables, it also provides various useful functionality
48  *          including translating time to second unit
49  */
50 class Time
51 {
52 public:
53     /**
54      * Constructor for Time
55      */
56     Time();
57     /**
58      * Virtual destructor for Time
59      */
60     ~Time();
61
62     /** @brief a unit of second.*/
63     long int mDelay;
64     /** @brief time information in structure tm.*/
65     OCTime mTime;
66     /** @brief flag to indicate group action type(NONE, SCHEDULED, RECURSIVE).*/
67     ACTIONSET_TYPE type;
68
69     void setTime(OCTime t);
70     void setTime(unsigned int yy, unsigned int mm, unsigned int dd,
71             unsigned int h, unsigned int m, unsigned int s,
72             int dayoftheweek);
73     void setDayOfWeekForRecursive(int day);
74     unsigned int getYear();
75     unsigned int getMonth();
76     unsigned int getDay();
77     unsigned int getHour();
78     unsigned int getMin();
79     unsigned int getSec();
80     long int getSecondsFromAbsoluteTime();
81     long int getSecAbsTime();
82     long int getSecondsForWeeklySchedule();
83     void setDelay(long int seconds);
84     std::string toString() const;
85 };
86
87 /**
88  * @class       Capability
89  * @brief       This class provides a structure to help developers to easily specify a unit of attribute
90  *          key-value pair which corresponds to action.
91  */
92 class Capability
93 {
94 public:
95     /** @brief This corresponds with attribute key.*/
96     std::string capability;
97     /** @brief This corresponds with attribute value.*/
98     std::string status;
99 };
100
101 /**
102  * @class       Action
103  * @brief       This class provides a structure to help developers to easily specify an action which a
104  *          target resource have to do for.
105  */
106 class Action
107 {
108 public:
109     /**
110      * Constructor for Action
111      */
112     Action();
113     /**
114      * Virtual destructor for Action
115      */
116     ~Action();
117
118     /** @brief This is a target URL of this action. It includes IP address, port, and resource URI.*/
119     std::string target;
120     /** @brief This is a list of capabilites.*/
121     std::vector<Capability*> listOfCapability;
122 };
123
124 /**
125  * @class       ActionSet
126  * @brief       This class provides a structure to help developers to easily specify group action.
127  */
128 class ActionSet: public Time
129 {
130 public:
131     /**
132      * Constructor for ActionSet
133      */
134     ActionSet();
135     /**
136      * Virtual destructor for ActionSet
137      */
138     ~ActionSet();
139
140     /** @brief a name of group action */
141     std::string actionsetName;
142     /** @brief a list of actions composing group action */
143     std::vector<Action*> listOfAction;
144 };
145 }
146 #endif