NCBI C++ ToolKit
PC_AtomInt_.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 PC_AtomInt_.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/pcsubstance/pcsubstance.asn">pcsubstance.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/pcsubstance/pcsubstance.def">pcsubstance.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_PCSUBSTANCE_PC_ATOMINT_BASE_HPP
42 #define OBJECTS_PCSUBSTANCE_PC_ATOMINT_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_PCSubstance
59  *
60  * @{
61  */
62 
63 /////////////////////////////////////////////////////////////////////////////
64 /// Specification of an Association between an Atom Identifier and an Integer Value
65 ///
66 /// CPC_AtomInt_Base --
67 ///
68 
70 {
72 public:
73  // constructor
74  CPC_AtomInt_Base(void);
75  // destructor
76  virtual ~CPC_AtomInt_Base(void);
77 
78  // type info
80 
81  // types
82  typedef int TAid;
83  typedef int TValue;
84 
85  // member index
86  enum class E_memberIndex {
87  e__allMandatory = 0,
88  e_aid,
89  e_value
90  };
92 
93  // getters
94  // setters
95 
96  /// Atom Identifier for the Value
97  /// Note: Atom ID's must be greater than "0"
98  /// Check if a value has been assigned to Aid data member.
99  ///
100  /// Data member Aid is mandatory;
101  /// its type is defined as 'typedef int TAid'
102  /// @return
103  /// - true, if a value has been assigned.
104  /// - false, otherwise.
105  bool IsSetAid(void) const;
106 
107  /// Check if it is safe to call GetAid method.
108  ///
109  /// @return
110  /// - true, if the data member is getatable.
111  /// - false, otherwise.
112  bool CanGetAid(void) const;
113 
114  /// Reset Aid data member.
115  void ResetAid(void);
116 
117  /// Get the Aid member data.
118  ///
119  /// @return
120  /// Copy of the member data.
121  TAid GetAid(void) const;
122 
123  /// Assign a value to Aid data member.
124  ///
125  /// @param value
126  /// Value to assign
127  void SetAid(TAid value);
128 
129  /// Assign a value to Aid data member.
130  ///
131  /// @return
132  /// Reference to the data value.
133  TAid& SetAid(void);
134 
135  /// Value Associated to the ID
136  /// Check if a value has been assigned to Value data member.
137  ///
138  /// Data member Value is mandatory;
139  /// its type is defined as 'typedef int TValue'
140  /// @return
141  /// - true, if a value has been assigned.
142  /// - false, otherwise.
143  bool IsSetValue(void) const;
144 
145  /// Check if it is safe to call GetValue method.
146  ///
147  /// @return
148  /// - true, if the data member is getatable.
149  /// - false, otherwise.
150  bool CanGetValue(void) const;
151 
152  /// Reset Value data member.
153  void ResetValue(void);
154 
155  /// Get the Value member data.
156  ///
157  /// @return
158  /// Copy of the member data.
159  TValue GetValue(void) const;
160 
161  /// Assign a value to Value data member.
162  ///
163  /// @param value
164  /// Value to assign
165  void SetValue(TValue value);
166 
167  /// Assign a value to Value data member.
168  ///
169  /// @return
170  /// Reference to the data value.
171  TValue& SetValue(void);
172 
173  /// Reset the whole object
174  virtual void Reset(void);
175 
176 
177 private:
178  // Prohibit copy constructor and assignment operator
181 
182  // data
183  Uint4 m_set_State[1];
184  int m_Aid;
185  int m_Value;
186 };
187 
188 /* @} */
189 
190 
191 
192 
193 
194 ///////////////////////////////////////////////////////////
195 ///////////////////// inline methods //////////////////////
196 ///////////////////////////////////////////////////////////
197 inline
199 {
200  return ((m_set_State[0] & 0x3) != 0);
201 }
202 
203 inline
205 {
206  return IsSetAid();
207 }
208 
209 inline
211 {
212  m_Aid = 0;
213  m_set_State[0] &= ~0x3;
214 }
215 
216 inline
218 {
219  if (!CanGetAid()) {
220  ThrowUnassigned(0);
221  }
222  return m_Aid;
223 }
224 
225 inline
227 {
228  m_Aid = value;
229  m_set_State[0] |= 0x3;
230 }
231 
232 inline
234 {
235 #ifdef _DEBUG
236  if (!IsSetAid()) {
237  memset(&m_Aid,UnassignedByte(),sizeof(m_Aid));
238  }
239 #endif
240  m_set_State[0] |= 0x1;
241  return m_Aid;
242 }
243 
244 inline
246 {
247  return ((m_set_State[0] & 0xc) != 0);
248 }
249 
250 inline
252 {
253  return IsSetValue();
254 }
255 
256 inline
258 {
259  m_Value = 0;
260  m_set_State[0] &= ~0xc;
261 }
262 
263 inline
265 {
266  if (!CanGetValue()) {
267  ThrowUnassigned(1);
268  }
269  return m_Value;
270 }
271 
272 inline
274 {
275  m_Value = value;
276  m_set_State[0] |= 0xc;
277 }
278 
279 inline
281 {
282 #ifdef _DEBUG
283  if (!IsSetValue()) {
284  memset(&m_Value,UnassignedByte(),sizeof(m_Value));
285  }
286 #endif
287  m_set_State[0] |= 0x4;
288  return m_Value;
289 }
290 
291 ///////////////////////////////////////////////////////////
292 ////////////////// end of inline methods //////////////////
293 ///////////////////////////////////////////////////////////
294 
295 
296 
297 
298 
299 END_objects_SCOPE // namespace ncbi::objects::
300 
302 
303 
304 #endif // OBJECTS_PCSUBSTANCE_PC_ATOMINT_BASE_HPP
Specification of an Association between an Atom Identifier and an Integer Value.
Definition: PC_AtomInt_.hpp:70
Base class for all serializable objects.
Definition: serialbase.hpp:150
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_PCSUBSTANCE_EXPORT
Definition: ncbi_export.h:688
void ResetAid(void)
Reset Aid data member.
CSerialObject Tparent
Definition: PC_AtomInt_.hpp:71
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
Definition: PC_AtomInt_.hpp:91
TAid GetAid(void) const
Get the Aid member data.
bool CanGetAid(void) const
Check if it is safe to call GetAid method.
bool IsSetValue(void) const
Value Associated to the ID Check if a value has been assigned to Value data member.
TAid & SetAid(void)
Assign a value to Aid data member.
CPC_AtomInt_Base(const CPC_AtomInt_Base &)
TValue & SetValue(void)
Assign a value to Value data member.
CPC_AtomInt_Base & operator=(const CPC_AtomInt_Base &)
void ResetValue(void)
Reset Value data member.
bool IsSetAid(void) const
Atom Identifier for the Value Note: Atom ID's must be greater than "0" Check if a value has been assi...
TValue GetValue(void) const
Get the Value member data.
Uint4 m_set_State[1]
bool CanGetValue(void) const
Check if it is safe to call GetValue method.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Sun Jun 23 05:18:07 2024 by modify_doxy.py rev. 669887