NCBI C++ ToolKit
Seq_descr.cpp
Go to the documentation of this file.

Go to the repository for this file.

1 /* $Id: Seq_descr.cpp 64744 2014-10-07 14:40:49Z gotvyans $
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  * Author: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'seq.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 #include <objects/seq/Seqdesc.hpp>
40 
41 // generated includes
43 
44 #include <corelib/ncbi_param.hpp>
45 
46 // generated classes
47 
49 
50 BEGIN_objects_SCOPE // namespace ncbi::objects::
51 
52 // destructor
54 {
55 }
56 
57 NCBI_PARAM_DECL(bool, OBJECTS, SEQ_DESCR_ALLOW_EMPTY);
58 NCBI_PARAM_DEF_EX(bool, OBJECTS, SEQ_DESCR_ALLOW_EMPTY, false,
59  eParam_NoThread, OBJECTS_SEQ_DESCR_ALLOW_EMPTY);
60 static CSafeStatic<NCBI_PARAM_TYPE(OBJECTS, SEQ_DESCR_ALLOW_EMPTY)> s_SeqDescrAllowEmpty;
61 
62 void CSeq_descr::PostRead(void) const
63 {
64  if ( !s_SeqDescrAllowEmpty->Get() && Get().empty() ) {
65  NCBI_THROW(CSerialException, eInvalidData,
66  "empty Seq-descr is not allowed");
67  }
68 }
69 
70 void CSeq_descr::PreWrite(void) const
71 {
72  static NCBI_PARAM_TYPE(OBJECTS, SEQ_DESCR_ALLOW_EMPTY) sx_Value;
73  if ( !s_SeqDescrAllowEmpty->Get() && Get().empty() ) {
74  NCBI_THROW(CSerialException, eInvalidData,
75  "empty Seq-descr is not allowed");
76  }
77 }
78 
80 {
81  if (m_desc.IsNull())
83  return (m_desc.IsNull());
84 }
85 
87 {
88  if (m_desc.IsNull())
90  return *m_desc;
91 }
92 
93 CSeqdesc& CAutoAddDesc::Set(bool skip_lookup)
94 {
95  if (!skip_lookup && m_desc.IsNull())
97  if (m_desc.IsNull())
98  {
99  m_desc.Reset(new CSeqdesc);
100  m_descr->Set().push_back(m_desc);
101  }
102  return *m_desc;
103 }
104 
105 // update-date should go only to top-level bioseq-set or bioseq
107 {
108  ITERATE(CSeq_descr::Tdata, it, descr.Get())
109  {
110  if ((**it).Which() == which)
111  return *it;
112  }
113 
114  return CRef<CSeqdesc>();
115 }
116 
118 {
119  if (!IsNull())
120  m_descr->Set().remove(CRef<CSeqdesc>(&Set()));
121 }
122 
124 {
125  bool erased = false;
126  for (CSeq_descr::Tdata::iterator it = descr.Set().begin(); it!= descr.Set().end(); )
127  {
128  if ((**it).Which() == which)
129  {
130  erased = true;
131  descr.Set().erase(it++);
132  }
133  else
134  ++it;
135  }
136 
137  return erased;
138 }
139 
140 END_objects_SCOPE // namespace ncbi::objects::
141 
143 
144 /* Original file checksum: lines: 65, chars: 1883, CRC32: ed475d39 */
static CSafeStatic< NCBI_PARAM_TYPE(OBJECTS, SEQ_DESCR_ALLOW_EMPTY)> s_SeqDescrAllowEmpty
Definition: Seq_descr.cpp:60
NCBI_PARAM_DEF_EX(bool, OBJECTS, SEQ_DESCR_ALLOW_EMPTY, false, eParam_NoThread, OBJECTS_SEQ_DESCR_ALLOW_EMPTY)
NCBI_PARAM_DECL(bool, OBJECTS, SEQ_DESCR_ALLOW_EMPTY)
CRef< CSeqdesc > m_desc
Definition: Seq_descr.hpp:109
CRef< CSeq_descr > m_descr
Definition: Seq_descr.hpp:108
bool IsNull() const
Definition: Seq_descr.cpp:79
CSeqdesc & Set(bool skip_lookup=false)
Definition: Seq_descr.cpp:93
void Erase()
Definition: Seq_descr.cpp:117
const CSeqdesc & Get() const
Definition: Seq_descr.cpp:86
static CRef< CSeqdesc > LocateDesc(const CSeq_descr &descr, CSeqdesc::E_Choice which)
Definition: Seq_descr.cpp:106
CSeqdesc::E_Choice m_which
Definition: Seq_descr.hpp:107
static bool EraseDesc(CSeq_descr &descr, CSeqdesc::E_Choice which)
Definition: Seq_descr.cpp:123
CSafeStatic<>::
@Seq_descr.hpp User-defined methods of the data storage class.
Definition: Seq_descr.hpp:55
~CSeq_descr(void)
Definition: Seq_descr.cpp:53
void PreWrite(void) const
Definition: Seq_descr.cpp:70
void PostRead(void) const
Definition: Seq_descr.cpp:62
Root class for all serialization exceptions.
Definition: exception.hpp:50
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:914
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
bool IsNull(void) const noexcept
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:731
void Reset(void) noexcept
Reset reference object.
Definition: ncbiobj.hpp:769
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
Definition: ncbi_param.hpp:149
@ eParam_NoThread
Do not use per-thread values.
Definition: ncbi_param.hpp:418
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:104
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:101
list< CRef< CSeqdesc > > Tdata
Definition: Seq_descr_.hpp:91
const Tdata & Get(void) const
Get the member data.
Definition: Seq_descr_.hpp:166
E_Choice
Choice variants.
Definition: Seqdesc_.hpp:109
Tdata & Set(void)
Assign a value to data member.
Definition: Seq_descr_.hpp:172
constexpr bool empty(list< Ts... >) noexcept
Modified on Sat Nov 07 14:11:27 2026 by modify_doxy.py rev. 717554