NCBI C++ ToolKit
Dbtag_.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 Dbtag_.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/general/general.asn">general.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/general/general.def">general.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_GENERAL_DBTAG_BASE_HPP
42 #define OBJECTS_GENERAL_DBTAG_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 // forward declarations
60 class CObject_id;
61 
62 
63 // generated classes
64 
65 
66 /** @addtogroup dataspec_NCBI_General
67  *
68  * @{
69  */
70 
71 /////////////////////////////////////////////////////////////////////////////
72 /// Dbtag is generalized for tagging
73 /// eg. { "Social Security", str "023-79-8841" }
74 /// or { "member", id 8882224 }
75 ///
76 /// CDbtag_Base --
77 ///
78 
80 {
82 public:
83  // constructor
84  CDbtag_Base(void);
85  // destructor
86  virtual ~CDbtag_Base(void);
87 
88  // type info
90 
91  // types
92  typedef string TDb;
93  typedef CObject_id TTag;
94 
95  // member index
96  enum class E_memberIndex {
97  e__allMandatory = 0,
98  e_db,
99  e_tag
100  };
102 
103  // getters
104  // setters
105 
106  /// name of database or system
107  /// Check if a value has been assigned to Db data member.
108  ///
109  /// Data member Db is mandatory;
110  /// its type is defined as 'typedef string TDb'
111  /// @return
112  /// - true, if a value has been assigned.
113  /// - false, otherwise.
114  bool IsSetDb(void) const;
115 
116  /// Check if it is safe to call GetDb method.
117  ///
118  /// @return
119  /// - true, if the data member is getatable.
120  /// - false, otherwise.
121  bool CanGetDb(void) const;
122 
123  /// Reset Db data member.
124  void ResetDb(void);
125 
126  /// Get the Db member data.
127  ///
128  /// @return
129  /// Reference to the member data.
130  const TDb& GetDb(void) const;
131 
132  /// Assign a value to Db data member.
133  ///
134  /// @param value
135  /// Value to assign
136  void SetDb(const TDb& value);
137  void SetDb(TDb&& value);
138 
139  /// Assign a value to Db data member.
140  ///
141  /// @return
142  /// Reference to the data value.
143  TDb& SetDb(void);
144 
145  /// appropriate tag
146  /// Check if a value has been assigned to Tag data member.
147  ///
148  /// Data member Tag is mandatory;
149  /// its type is defined as 'typedef CObject_id TTag'
150  /// @return
151  /// - true, if a value has been assigned.
152  /// - false, otherwise.
153  bool IsSetTag(void) const;
154 
155  /// Check if it is safe to call GetTag method.
156  ///
157  /// @return
158  /// - true, if the data member is getatable.
159  /// - false, otherwise.
160  bool CanGetTag(void) const;
161 
162  /// Reset Tag data member.
163  void ResetTag(void);
164 
165  /// Get the Tag member data.
166  ///
167  /// @return
168  /// Reference to the member data.
169  const TTag& GetTag(void) const;
170 
171  /// Assign a value to Tag data member.
172  ///
173  /// @param value
174  /// Reference to value.
175  void SetTag(TTag& value);
176 
177  /// Assign a value to Tag data member.
178  ///
179  /// @return
180  /// Reference to the data value.
181  TTag& SetTag(void);
182 
183  /// Reset the whole object
184  virtual void Reset(void);
185 
186 
187 private:
188  // Prohibit copy constructor and assignment operator
191 
192  // data
193  Uint4 m_set_State[1];
194  string m_Db;
196 };
197 
198 /* @} */
199 
200 
201 
202 
203 
204 ///////////////////////////////////////////////////////////
205 ///////////////////// inline methods //////////////////////
206 ///////////////////////////////////////////////////////////
207 inline
208 bool CDbtag_Base::IsSetDb(void) const
209 {
210  return ((m_set_State[0] & 0x3) != 0);
211 }
212 
213 inline
214 bool CDbtag_Base::CanGetDb(void) const
215 {
216  return IsSetDb();
217 }
218 
219 inline
221 {
222  if (!CanGetDb()) {
223  ThrowUnassigned(0);
224  }
225  return m_Db;
226 }
227 
228 inline
230 {
231  m_Db = value;
232  m_set_State[0] |= 0x3;
233 }
234 
235 inline
237 {
238  m_Db = std::forward<CDbtag_Base::TDb>(value);
239  m_set_State[0] |= 0x3;
240 }
241 
242 inline
244 {
245 #ifdef _DEBUG
246  if (!IsSetDb()) {
248  }
249 #endif
250  m_set_State[0] |= 0x1;
251  return m_Db;
252 }
253 
254 inline
255 bool CDbtag_Base::IsSetTag(void) const
256 {
257  return m_Tag.NotEmpty();
258 }
259 
260 inline
261 bool CDbtag_Base::CanGetTag(void) const
262 {
263  return true;
264 }
265 
266 inline
268 {
269  if ( !m_Tag ) {
270  const_cast<CDbtag_Base*>(this)->ResetTag();
271  }
272  return (*m_Tag);
273 }
274 
275 inline
277 {
278  if ( !m_Tag ) {
279  ResetTag();
280  }
281  return (*m_Tag);
282 }
283 
284 ///////////////////////////////////////////////////////////
285 ////////////////// end of inline methods //////////////////
286 ///////////////////////////////////////////////////////////
287 
288 
289 
290 
291 
292 END_objects_SCOPE // namespace ncbi::objects::
293 
295 
296 
297 #endif // OBJECTS_GENERAL_DBTAG_BASE_HPP
Dbtag is generalized for tagging eg.
Definition: Dbtag_.hpp:80
CRef –.
Definition: ncbiobj.hpp:618
Base class for all serializable objects.
Definition: serialbase.hpp:150
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_GENERAL_EXPORT
Definition: ncbi_export.h:512
bool IsSetDb(void) const
name of database or system Check if a value has been assigned to Db data member.
Definition: Dbtag_.hpp:208
TTag & SetTag(void)
Assign a value to Tag data member.
Definition: Dbtag_.hpp:276
const TTag & GetTag(void) const
Get the Tag member data.
Definition: Dbtag_.hpp:267
CRef< TTag > m_Tag
Definition: Dbtag_.hpp:195
bool CanGetDb(void) const
Check if it is safe to call GetDb method.
Definition: Dbtag_.hpp:214
bool CanGetTag(void) const
Check if it is safe to call GetTag method.
Definition: Dbtag_.hpp:261
bool IsSetTag(void) const
appropriate tag Check if a value has been assigned to Tag data member.
Definition: Dbtag_.hpp:255
CDbtag_Base(const CDbtag_Base &)
string m_Db
Definition: Dbtag_.hpp:194
const TDb & GetDb(void) const
Get the Db member data.
Definition: Dbtag_.hpp:220
void ResetTag(void)
Reset Tag data member.
Definition: Dbtag_.cpp:57
TDb & SetDb(void)
Assign a value to Db data member.
Definition: Dbtag_.hpp:243
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
Definition: Dbtag_.hpp:101
CSerialObject Tparent
Definition: Dbtag_.hpp:81
Uint4 m_set_State[1]
Definition: Dbtag_.hpp:193
CDbtag_Base & operator=(const CDbtag_Base &)
DECLARE_INTERNAL_TYPE_INFO()
CObject_id TTag
Definition: Dbtag_.hpp:93
string TDb
Definition: Dbtag_.hpp:92
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Thu Apr 25 08:21:11 2024 by modify_doxy.py rev. 669887