• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef _CONSTRAINT_H
17 #define _CONSTRAINT_H
18 
19 #include <Drm2CommonTypes.h>
20 #include <ustring.h>
21 #include <uvector.h>
22 using namespace ustl;
23 
24 struct Context {
25     string id;
26     string version;
27 };
28 
29 const int INIT_VALUE = -1;
30 
31 class Constraint {
32 public:
33     enum MODE {NONE, MOVE, COPY}; /**< export mode type. */
34 
35     /**
36      * Construtor for constraint.
37      */
38     Constraint();
39 
40     /**
41      * Destructor for constraint.
42      */
43     ~Constraint();
44 
45 public:
46     /**
47      * Test whether constraint is valid or not
48      * @param time the specitic time to test.
49      * @return true/false to indicate the result.
50      */
51     bool isValid(long time) const;
52 
53     /**
54      * Test whether constraint is unconstraint or not
55      * @return true/false to indicate the result.
56      */
57     bool isUnConstraint() const;
58 
59     /**
60      * Test whether constraint is datetime related or not.
61      * @return true/false to indicate the result.
62      */
63     bool isDateTimeConstraint() const;
64 
65     /**
66      * Test whether constraint contain interval or not
67      * @return true/false to indicate the result.
68      */
69     bool isIntervalConstraint() const;
70 
71     /**
72      * Test whether constraint is timed count or not
73      * @return true/false to indicate the result.
74      */
75     bool isTimedCountConstraint() const;
76 
77     /**
78      * Set the start time value of constraint.
79      * @param time the specific time value.
80      */
81     void setStartTime(long time);
82 
83     /**
84      * Get the start time.
85      * @return value of start time.
86      */
87     long getStartTime() const;
88 
89     /**
90      * Set the end time.
91      * @param time the value of end time.
92      */
93     void setEndTime(long time);
94 
95     /**
96      * Get the end time.
97      * @param return the value of  end time.
98      */
99     long getEndTime() const;
100 
101     /**
102      * Set the accumulated .
103      * @param time the specific time.
104      */
105     void setAccumulated(long time);
106 
107     /**
108      * Get the accumulated.
109      * @return the value of accumulated
110      */
111     long getAccumulated() const;
112 
113     /**
114      * Set the count.
115      * @param count the value of count.
116      */
117     void setCount(int count);
118 
119     /**
120      * Get the count.
121      * @return value of count.
122      */
123     int getCount() const;
124 
125     /**
126      * Set the value of timer.
127      * @param timer the value of the timer.
128      */
129     void setTimer(int timer);
130 
131     /**
132      * Get the timer.
133      * @return value of time.
134      */
135     int getTimer() const;
136 
137     /**
138      * Set the timedCount.
139      * @param timedCount the value of timedCount.
140      */
141     void setTimedCount(int timedCount);
142 
143     /**
144      * Get the timedCount.
145      * @return the value of timedCount.
146      */
147     int getTimedCount() const;
148 
149     /**
150      * Set the interval.
151      * @param interval the value of interval.
152      */
153     void setInterval(int interval);
154 
155     /**
156      * Get the interval.
157      * @return the value of interval.
158      */
159     int getInterval() const;
160 
161     /**
162      * set export mode.
163      * @param mode the mode type of export.
164      */
165     void setExportMode(MODE mode);
166 
167     /**
168      * Get the export mode.
169      * @return the export mode.
170      */
171     MODE getExportMode() const;
172 
173     /**
174      * Consume the constraint.
175      * @return true/false to indicate whether consume succesfully or not.
176      */
177     bool consume();
178 
179 PRIVATE:
180     int mCount; /**< the count. */
181     int mTimedCount; /**< timed count. */
182     int mTimer; /**< timer for timed count. */
183     long mStart; /**< start time. */
184     long mEnd; /**< end time. */
185     int mInterval; /**< interval. */
186     long mAccumulated; /**< accumlated. */
187     vector<Context> mSystemList; /**< system list. */
188     MODE mExport; /**< export mode. */
189 };
190 #endif
191