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

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS_FORMAT_ITEMS___ITEM_BASE_ITEM__HPP
2 #define OBJTOOLS_FORMAT_ITEMS___ITEM_BASE_ITEM__HPP
3 
4 /* $Id: item_base.hpp 85041 2019-01-09 19:44:56Z kans $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Aaron Ucko, NCBI
30 * Mati Shomrat
31 *
32 * File Description:
33 * Base class for the various item objects
34 *
35 */
36 #include <corelib/ncbistd.hpp>
37 #include <serial/serialbase.hpp>
38 
40 //#include <objtools/format/context.hpp>
41 
42 
45 
46 class CBioseqContext;
47 
48 
50 {
51 public:
52  virtual void Format(IFormatter& formatter,
53  IFlatTextOStream& text_os) const = 0;
54 
55  bool IsSetObject(void) const;
56  const CSerialObject* GetObject(void) const;
57 
59  CBioseqContext* GetContext(void) const;
60 
61  // should this item be skipped during formatting?
62  bool Skip(void) const;
63  // is feature on external Seq-annot?
64  bool IsExternal(void) const;
65 
66  ~CFlatItem(void);
67 
68 protected:
70 
71  virtual void x_GatherInfo(CBioseqContext&) {}
72 
73  void x_SetObject(const CSerialObject& obj);
75 
76  void x_SetSkip(void);
77  void x_SetExternal(void);
78 
79 private:
80 
81  // The underlying CSerialObject from the information is obtained.
83  // a context associated with this item
85  // should this item be skipped?
86  bool m_Skip;
87  // is feature on external Seq-annot?
88  bool m_External;
89 };
90 
91 
92 ///////////////////////////////////////////////////////////
93 ///////////////////// inline methods //////////////////////
94 ///////////////////////////////////////////////////////////
95 
96 // public methods
97 
98 inline
100 {
101  return m_Object;
102 }
103 
104 
105 inline
106 bool CFlatItem::IsSetObject(void) const
107 {
108  return m_Object.NotEmpty();
109 }
110 
111 
112 inline
114 {
115  return m_Context;
116 }
117 
118 
119 inline
121 {
122  return m_Context;
123 }
124 
125 
126 inline
127 bool CFlatItem::Skip(void) const
128 {
129  return m_Skip;
130 }
131 
132 
133 inline
134 bool CFlatItem::IsExternal(void) const
135 {
136  return m_External;
137 }
138 
139 
140 inline
142 {
143 }
144 
145 // protected methods:
146 
147 // constructor
148 inline
150  m_Object(0),
151  m_Context(ctx),
152  m_Skip(false),
153  m_External(false)
154 {
155 }
156 
157 
158 // Shared utility functions
159 inline
161 {
162  m_Object.Reset(&obj);
163 }
164 
165 
166 inline
168 {
169  m_Skip = true;
170  m_Object.Reset();
171  m_Context = 0;
172 }
173 
174 
175 inline
177 {
178  m_External = true;
179 }
180 
181 
182 ///////////////////////////////////////////////////////////
183 ////////////////// end of inline methods //////////////////
184 ///////////////////////////////////////////////////////////
185 
186 
189 
190 #endif /* OBJTOOLS_FORMAT_ITEMS___ITEM_BASE_ITEM__HPP */
bool m_Skip
Definition: item_base.hpp:86
CBioseqContext * m_Context
Definition: item_base.hpp:84
bool m_External
Definition: item_base.hpp:88
bool IsExternal(void) const
Definition: item_base.hpp:134
CConstRef< CSerialObject > m_Object
Definition: item_base.hpp:82
void x_SetExternal(void)
Definition: item_base.hpp:176
bool IsSetObject(void) const
Definition: item_base.hpp:106
CBioseqContext * GetContext(void)
Definition: item_base.hpp:113
void x_SetObject(const CSerialObject &obj)
Definition: item_base.hpp:160
CFlatItem(CBioseqContext *ctx=0)
Definition: item_base.hpp:149
void x_SetSkip(void)
Definition: item_base.hpp:167
const CSerialObject * GetObject(void) const
Definition: item_base.hpp:99
~CFlatItem(void)
Definition: item_base.hpp:141
void x_SetContext(CBioseqContext &ctx)
virtual void Format(IFormatter &formatter, IFlatTextOStream &text_os) const =0
bool Skip(void) const
Definition: item_base.hpp:127
virtual void x_GatherInfo(CBioseqContext &)
Definition: item_base.hpp:71
Base class for all serializable objects.
Definition: serialbase.hpp:150
virtual bool Skip(void) const =0
virtual const CSerialObject * GetObject(void) const =0
Include a standard set of the NCBI C++ Toolkit most basic headers.
CS_CONTEXT * ctx
Definition: t0006.c:12
#define false
Definition: bool.h:36
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
bool NotEmpty(void) const THROWS_NONE
Check if CConstRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:1392
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_FORMAT_EXPORT
Definition: ncbi_export.h:496
static wxString GetContext(const wxString &str, int pos)
Modified on Fri Sep 20 14:58:04 2024 by modify_doxy.py rev. 669887