NCBI C++ ToolKit
Mim_date_.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id$
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  */
27 
28 /// @file Mim_date_.hpp
29 /// Data storage class.
30 ///
31 /// This file was generated by application DATATOOL
32 /// using the following specifications:
33 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/mim/mim.asn">mim.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/mim/mim.def">mim.def</a>
36 ///
37 /// ATTENTION:
38 /// Don't edit or commit this file into CVS as this file will
39 /// be overridden (by DATATOOL) without warning!
40 
41 #ifndef OBJECTS_MIM_MIM_DATE_BASE_HPP
42 #define OBJECTS_MIM_MIM_DATE_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
47 
48 #ifndef BEGIN_objects_SCOPE
49 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
50 # define END_objects_SCOPE END_SCOPE(objects)
51 #endif
52 BEGIN_objects_SCOPE // namespace ncbi::objects::
53 
54 
55 // generated classes
56 
57 
58 /** @addtogroup dataspec_NCBI_Mim
59  *
60  * @{
61  */
62 
63 /////////////////////////////////////////////////////////////////////////////
64 ///
65 /// CMim_date_Base --
66 ///
67 
69 {
71 public:
72  // constructor
73  CMim_date_Base(void);
74  // destructor
75  virtual ~CMim_date_Base(void);
76 
77  // type info
79 
80  // types
81  typedef int TYear;
82  typedef int TMonth;
83  typedef int TDay;
84 
85  // member index
86  enum class E_memberIndex {
87  e__allMandatory = 0,
88  e_year,
89  e_month,
90  e_day
91  };
93 
94  // getters
95  // setters
96 
97  /// Check if a value has been assigned to Year data member.
98  ///
99  /// Data member Year is mandatory;
100  /// its type is defined as 'typedef int TYear'
101  /// @return
102  /// - true, if a value has been assigned.
103  /// - false, otherwise.
104  bool IsSetYear(void) const;
105 
106  /// Check if it is safe to call GetYear method.
107  ///
108  /// @return
109  /// - true, if the data member is getatable.
110  /// - false, otherwise.
111  bool CanGetYear(void) const;
112 
113  /// Reset Year data member.
114  void ResetYear(void);
115 
116  /// Get the Year member data.
117  ///
118  /// @return
119  /// Copy of the member data.
120  TYear GetYear(void) const;
121 
122  /// Assign a value to Year data member.
123  ///
124  /// @param value
125  /// Value to assign
126  void SetYear(TYear value);
127 
128  /// Assign a value to Year data member.
129  ///
130  /// @return
131  /// Reference to the data value.
132  TYear& SetYear(void);
133 
134  /// Check if a value has been assigned to Month data member.
135  ///
136  /// Data member Month is optional;
137  /// its type is defined as 'typedef int TMonth'
138  /// @return
139  /// - true, if a value has been assigned.
140  /// - false, otherwise.
141  bool IsSetMonth(void) const;
142 
143  /// Check if it is safe to call GetMonth method.
144  ///
145  /// @return
146  /// - true, if the data member is getatable.
147  /// - false, otherwise.
148  bool CanGetMonth(void) const;
149 
150  /// Reset Month data member.
151  void ResetMonth(void);
152 
153  /// Get the Month member data.
154  ///
155  /// @return
156  /// Copy of the member data.
157  TMonth GetMonth(void) const;
158 
159  /// Assign a value to Month data member.
160  ///
161  /// @param value
162  /// Value to assign
163  void SetMonth(TMonth value);
164 
165  /// Assign a value to Month data member.
166  ///
167  /// @return
168  /// Reference to the data value.
169  TMonth& SetMonth(void);
170 
171  /// Check if a value has been assigned to Day data member.
172  ///
173  /// Data member Day is optional;
174  /// its type is defined as 'typedef int TDay'
175  /// @return
176  /// - true, if a value has been assigned.
177  /// - false, otherwise.
178  bool IsSetDay(void) const;
179 
180  /// Check if it is safe to call GetDay method.
181  ///
182  /// @return
183  /// - true, if the data member is getatable.
184  /// - false, otherwise.
185  bool CanGetDay(void) const;
186 
187  /// Reset Day data member.
188  void ResetDay(void);
189 
190  /// Get the Day member data.
191  ///
192  /// @return
193  /// Copy of the member data.
194  TDay GetDay(void) const;
195 
196  /// Assign a value to Day data member.
197  ///
198  /// @param value
199  /// Value to assign
200  void SetDay(TDay value);
201 
202  /// Assign a value to Day data member.
203  ///
204  /// @return
205  /// Reference to the data value.
206  TDay& SetDay(void);
207 
208  /// Reset the whole object
209  virtual void Reset(void);
210 
211 
212 private:
213  // Prohibit copy constructor and assignment operator
216 
217  // data
218  Uint4 m_set_State[1];
219  int m_Year;
220  int m_Month;
221  int m_Day;
222 };
223 
224 /* @} */
225 
226 
227 
228 
229 
230 ///////////////////////////////////////////////////////////
231 ///////////////////// inline methods //////////////////////
232 ///////////////////////////////////////////////////////////
233 inline
235 {
236  return ((m_set_State[0] & 0x3) != 0);
237 }
238 
239 inline
241 {
242  return IsSetYear();
243 }
244 
245 inline
247 {
248  m_Year = 0;
249  m_set_State[0] &= ~0x3;
250 }
251 
252 inline
254 {
255  if (!CanGetYear()) {
256  ThrowUnassigned(0);
257  }
258  return m_Year;
259 }
260 
261 inline
263 {
264  m_Year = value;
265  m_set_State[0] |= 0x3;
266 }
267 
268 inline
270 {
271 #ifdef _DEBUG
272  if (!IsSetYear()) {
273  memset(&m_Year,UnassignedByte(),sizeof(m_Year));
274  }
275 #endif
276  m_set_State[0] |= 0x1;
277  return m_Year;
278 }
279 
280 inline
282 {
283  return ((m_set_State[0] & 0xc) != 0);
284 }
285 
286 inline
288 {
289  return IsSetMonth();
290 }
291 
292 inline
294 {
295  m_Month = 0;
296  m_set_State[0] &= ~0xc;
297 }
298 
299 inline
301 {
302  if (!CanGetMonth()) {
303  ThrowUnassigned(1);
304  }
305  return m_Month;
306 }
307 
308 inline
310 {
311  m_Month = value;
312  m_set_State[0] |= 0xc;
313 }
314 
315 inline
317 {
318 #ifdef _DEBUG
319  if (!IsSetMonth()) {
320  memset(&m_Month,UnassignedByte(),sizeof(m_Month));
321  }
322 #endif
323  m_set_State[0] |= 0x4;
324  return m_Month;
325 }
326 
327 inline
328 bool CMim_date_Base::IsSetDay(void) const
329 {
330  return ((m_set_State[0] & 0x30) != 0);
331 }
332 
333 inline
335 {
336  return IsSetDay();
337 }
338 
339 inline
341 {
342  m_Day = 0;
343  m_set_State[0] &= ~0x30;
344 }
345 
346 inline
348 {
349  if (!CanGetDay()) {
350  ThrowUnassigned(2);
351  }
352  return m_Day;
353 }
354 
355 inline
357 {
358  m_Day = value;
359  m_set_State[0] |= 0x30;
360 }
361 
362 inline
364 {
365 #ifdef _DEBUG
366  if (!IsSetDay()) {
367  memset(&m_Day,UnassignedByte(),sizeof(m_Day));
368  }
369 #endif
370  m_set_State[0] |= 0x10;
371  return m_Day;
372 }
373 
374 ///////////////////////////////////////////////////////////
375 ////////////////// end of inline methods //////////////////
376 ///////////////////////////////////////////////////////////
377 
378 
379 
380 
381 
382 END_objects_SCOPE // namespace ncbi::objects::
383 
385 
386 
387 #endif // OBJECTS_MIM_MIM_DATE_BASE_HPP
CMim_date_Base –.
Definition: Mim_date_.hpp:69
Base class for all serializable objects.
Definition: serialbase.hpp:150
char value[7]
Definition: config.c:431
static char UnassignedByte(void)
Definition: serialbase.hpp:181
void ThrowUnassigned(TMemberIndex index) const
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_MIM_EXPORT
Definition: ncbi_export.h:608
bool IsSetDay(void) const
Check if a value has been assigned to Day data member.
Definition: Mim_date_.hpp:328
bool CanGetYear(void) const
Check if it is safe to call GetYear method.
Definition: Mim_date_.hpp:240
bool CanGetMonth(void) const
Check if it is safe to call GetMonth method.
Definition: Mim_date_.hpp:287
Tparent::CMemberIndex< E_memberIndex, 4 > TmemberIndex
Definition: Mim_date_.hpp:92
TMonth GetMonth(void) const
Get the Month member data.
Definition: Mim_date_.hpp:300
void ResetYear(void)
Reset Year data member.
Definition: Mim_date_.hpp:246
bool CanGetDay(void) const
Check if it is safe to call GetDay method.
Definition: Mim_date_.hpp:334
TYear & SetYear(void)
Assign a value to Year data member.
Definition: Mim_date_.hpp:269
TMonth & SetMonth(void)
Assign a value to Month data member.
Definition: Mim_date_.hpp:316
CMim_date_Base(const CMim_date_Base &)
TDay GetDay(void) const
Get the Day member data.
Definition: Mim_date_.hpp:347
bool IsSetMonth(void) const
Check if a value has been assigned to Month data member.
Definition: Mim_date_.hpp:281
void ResetMonth(void)
Reset Month data member.
Definition: Mim_date_.hpp:293
TYear GetYear(void) const
Get the Year member data.
Definition: Mim_date_.hpp:253
DECLARE_INTERNAL_TYPE_INFO()
TDay & SetDay(void)
Assign a value to Day data member.
Definition: Mim_date_.hpp:363
bool IsSetYear(void) const
Check if a value has been assigned to Year data member.
Definition: Mim_date_.hpp:234
Uint4 m_set_State[1]
Definition: Mim_date_.hpp:218
void ResetDay(void)
Reset Day data member.
Definition: Mim_date_.hpp:340
CMim_date_Base & operator=(const CMim_date_Base &)
CSerialObject Tparent
Definition: Mim_date_.hpp:70
Modified on Fri Dec 08 08:19:34 2023 by modify_doxy.py rev. 669887