NCBI C++ ToolKit
PC_AtomString_.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_AtomString_.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_ATOMSTRING_BASE_HPP
42 #define OBJECTS_PCSUBSTANCE_PC_ATOMSTRING_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <string>
49 
51 
52 #ifndef BEGIN_objects_SCOPE
53 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
54 # define END_objects_SCOPE END_SCOPE(objects)
55 #endif
56 BEGIN_objects_SCOPE // namespace ncbi::objects::
57 
58 
59 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_PCSubstance
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 /// Specification of an Association between an Atom Identifier and a String Value
69 ///
70 /// CPC_AtomString_Base --
71 ///
72 
74 {
76 public:
77  // constructor
78  CPC_AtomString_Base(void);
79  // destructor
80  virtual ~CPC_AtomString_Base(void);
81 
82  // type info
84 
85  // types
86  typedef int TAid;
87  typedef string TValue;
88 
89  // member index
90  enum class E_memberIndex {
91  e__allMandatory = 0,
92  e_aid,
93  e_value
94  };
96 
97  // getters
98  // setters
99 
100  /// Atom Identifier for the Value
101  /// Note: Atom ID's must be greater than "0"
102  /// Check if a value has been assigned to Aid data member.
103  ///
104  /// Data member Aid is mandatory;
105  /// its type is defined as 'typedef int TAid'
106  /// @return
107  /// - true, if a value has been assigned.
108  /// - false, otherwise.
109  bool IsSetAid(void) const;
110 
111  /// Check if it is safe to call GetAid method.
112  ///
113  /// @return
114  /// - true, if the data member is getatable.
115  /// - false, otherwise.
116  bool CanGetAid(void) const;
117 
118  /// Reset Aid data member.
119  void ResetAid(void);
120 
121  /// Get the Aid member data.
122  ///
123  /// @return
124  /// Copy of the member data.
125  TAid GetAid(void) const;
126 
127  /// Assign a value to Aid data member.
128  ///
129  /// @param value
130  /// Value to assign
131  void SetAid(TAid value);
132 
133  /// Assign a value to Aid data member.
134  ///
135  /// @return
136  /// Reference to the data value.
137  TAid& SetAid(void);
138 
139  /// Value Associated to the ID
140  /// Check if a value has been assigned to Value data member.
141  ///
142  /// Data member Value is mandatory;
143  /// its type is defined as 'typedef string TValue'
144  /// @return
145  /// - true, if a value has been assigned.
146  /// - false, otherwise.
147  bool IsSetValue(void) const;
148 
149  /// Check if it is safe to call GetValue method.
150  ///
151  /// @return
152  /// - true, if the data member is getatable.
153  /// - false, otherwise.
154  bool CanGetValue(void) const;
155 
156  /// Reset Value data member.
157  void ResetValue(void);
158 
159  /// Get the Value member data.
160  ///
161  /// @return
162  /// Reference to the member data.
163  const TValue& GetValue(void) const;
164 
165  /// Assign a value to Value data member.
166  ///
167  /// @param value
168  /// Value to assign
169  void SetValue(const TValue& value);
170  void SetValue(TValue&& value);
171 
172  /// Assign a value to Value data member.
173  ///
174  /// @return
175  /// Reference to the data value.
176  TValue& SetValue(void);
177 
178  /// Reset the whole object
179  virtual void Reset(void);
180 
181 
182 private:
183  // Prohibit copy constructor and assignment operator
186 
187  // data
188  Uint4 m_set_State[1];
189  int m_Aid;
190  string m_Value;
191 };
192 
193 /* @} */
194 
195 
196 
197 
198 
199 ///////////////////////////////////////////////////////////
200 ///////////////////// inline methods //////////////////////
201 ///////////////////////////////////////////////////////////
202 inline
204 {
205  return ((m_set_State[0] & 0x3) != 0);
206 }
207 
208 inline
210 {
211  return IsSetAid();
212 }
213 
214 inline
216 {
217  m_Aid = 0;
218  m_set_State[0] &= ~0x3;
219 }
220 
221 inline
223 {
224  if (!CanGetAid()) {
225  ThrowUnassigned(0);
226  }
227  return m_Aid;
228 }
229 
230 inline
232 {
233  m_Aid = value;
234  m_set_State[0] |= 0x3;
235 }
236 
237 inline
239 {
240 #ifdef _DEBUG
241  if (!IsSetAid()) {
242  memset(&m_Aid,UnassignedByte(),sizeof(m_Aid));
243  }
244 #endif
245  m_set_State[0] |= 0x1;
246  return m_Aid;
247 }
248 
249 inline
251 {
252  return ((m_set_State[0] & 0xc) != 0);
253 }
254 
255 inline
257 {
258  return IsSetValue();
259 }
260 
261 inline
263 {
264  if (!CanGetValue()) {
265  ThrowUnassigned(1);
266  }
267  return m_Value;
268 }
269 
270 inline
272 {
273  m_Value = value;
274  m_set_State[0] |= 0xc;
275 }
276 
277 inline
279 {
280  m_Value = std::forward<CPC_AtomString_Base::TValue>(value);
281  m_set_State[0] |= 0xc;
282 }
283 
284 inline
286 {
287 #ifdef _DEBUG
288  if (!IsSetValue()) {
290  }
291 #endif
292  m_set_State[0] |= 0x4;
293  return m_Value;
294 }
295 
296 ///////////////////////////////////////////////////////////
297 ////////////////// end of inline methods //////////////////
298 ///////////////////////////////////////////////////////////
299 
300 
301 
302 
303 
304 END_objects_SCOPE // namespace ncbi::objects::
305 
307 
308 
309 #endif // OBJECTS_PCSUBSTANCE_PC_ATOMSTRING_BASE_HPP
Specification of an Association between an Atom Identifier and a String Value.
Base class for all serializable objects.
Definition: serialbase.hpp:150
static char UnassignedByte(void)
Definition: serialbase.hpp:181
void ThrowUnassigned(TMemberIndex index) const
static string UnassignedString(void)
Definition: serialbase.hpp:175
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
TValue & SetValue(void)
Assign a value to Value data member.
CPC_AtomString_Base(const CPC_AtomString_Base &)
CSerialObject Tparent
bool CanGetAid(void) const
Check if it is safe to call GetAid method.
TAid GetAid(void) const
Get the Aid member data.
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
const TValue & GetValue(void) const
Get the Value member data.
void ResetAid(void)
Reset Aid data member.
bool IsSetValue(void) const
Value Associated to the ID Check if a value has been assigned to 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...
CPC_AtomString_Base & operator=(const CPC_AtomString_Base &)
TAid & SetAid(void)
Assign a value to Aid data member.
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 Tue Apr 23 07:38:36 2024 by modify_doxy.py rev. 669887