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

Go to the repository for this file.

1 /* $Id: GBProject.cpp 28756 2013-08-23 17:44:43Z wuliangs $
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  * 'gui_project.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 
40 #include <corelib/ncbitime.hpp>
41 
42 #include <gui/objutils/label.hpp>
44 
45 // generated includes
52 #include <objects/general/Date.hpp>
54 #include <serial/iterator.hpp>
55 
56 #include <algorithm>
57 
58 // generated classes
59 
61 
62 BEGIN_objects_SCOPE // namespace ncbi::objects::
63 
64 
65 
66 
68 {
69 public:
70  void GetLabel(const CObject& obj, string* str,
72  objects::CScope* scope) const
73  {
74  const CGBProject* proj = dynamic_cast<const CGBProject*>(&obj);
75  if (proj) {
76  switch (type) {
77  case CLabel::eUserType:
79  break;
80 
83  break;
84 
85  case CLabel::eType:
86  *str += "Project (ver.1)";
87  break;
88 
90  case CLabel::eContent:
91  {{
92  string title;
93  if (proj->IsSetDescr() && proj->GetDescr().IsSetTitle()) {
94  title = proj->GetDescr().GetTitle();
95  }
96 
97  if ( !title.empty() ) {
98  *str += title;
99  } else if (proj->IsSetCore()) {
101 
102  string s;
103  for ( ; iter; ++iter) {
104  if ( !s.empty() ) {
105  s += ", ";
106  }
107  CLabel::GetLabel(*iter, &s, type, scope);
108  }
109  *str += s;
110  }
111  }}
112  break;
113 
116  {{
117  string type_str;
118  GetLabel(obj, &type_str, CLabel::eType, scope);
119  string content_str;
120  GetLabel(obj, &content_str, CLabel::eType, scope);
121  *str += type_str;
122  if ( !type_str.empty() && !content_str.empty() ) {
123  *str += ": ";
124  }
125  if ( !content_str.empty() ) {
126  *str += content_str;
127  }
128  }}
129  break;
130 
131  default:
132  break;
133  }
134  }
135  }
136 };
137 
138 
140 {
141  if ( !CLabel::HasHandler(*CGBProject::GetTypeInfo()) ) {
142  CLabel::RegisterLabelHandler(*CGBProject::GetTypeInfo(),
143  *new CGBProjectLabelHandler());
144  }
145 
146  CRef<CProjectFolder> folder(new CProjectFolder());
147  CFolderInfo& info = folder->SetInfo();
148  info.SetTitle("Supplementary Data");
149  info.SetCreate_date(SetDescr().SetCreate_date());
150 
151  SetExtra(*folder);
152 }
153 
154 
156 {
157 }
158 
159 
161 {
162  m_Mutex.Lock();
163 }
164 
165 
167 {
168  m_Mutex.Unlock();
169 }
170 
171 
173 {
175  m_Scope.Reset(scope);
176 }
177 
178 
180 {
181  return m_Scope.GetPointer();
182 }
183 
184 
185 /// retrieve the folders containing our project items
187 {
188  if ( !m_Folders ) {
191  info.SetTitle("Data");
192  info.SetComment("Default folder for Project Items");
193  info.SetCreateDate(CTime(CTime::eCurrent));
194 
195  CRef<CProjectItem> item
196  (const_cast<CProjectItem*>(&GetCore()));
197  m_Folders->SetItems().push_back(item);
198 
199  if (IsSetExtra() && GetExtra().IsSetFolders()) {
200  const CProjectFolder& extra = GetExtra();
201  ITERATE (CProjectFolder::TFolders, iter, extra.GetFolders()) {
202  CRef<CProjectFolder> f = *iter;
203  m_Folders->SetFolders().push_back(f);
204  }
205  }
206 
207  if (IsSetExtra() && GetExtra().IsSetItems()) {
208  const CProjectFolder& extra = GetExtra();
209  ITERATE (CProjectFolder::TItems, iter, extra.GetItems()) {
210  CRef<CProjectItem> i = *iter;
211  m_Folders->SetItems().push_back(i);
212  }
213  }
214  }
215  return *m_Folders;
216 }
217 
218 
220 {
221  GetData();
222  return *m_Folders;
223 }
224 
225 
226 
227 /// retrieve the descriptor set for this project
229 {
230  return Tparent::IsSetDescr();
231 }
232 
233 
235 {
236  return Tparent::GetDescr();
237 }
238 
239 
241 {
242  return Tparent::SetDescr();
243 }
244 
245 
246 /// retrieve the descriptor set for this project
248 {
249  return Tparent::IsSetAnnot();
250 }
251 
252 
254 {
255  return Tparent::GetAnnot();
256 }
257 
258 
260 {
261  return Tparent::SetAnnot();
262 }
263 
264 
266 {
267  return Tparent::IsSetLoaders();
268 }
269 
270 
272 {
273  return Tparent::GetLoaders();
274 }
275 
276 
278 {
279  return Tparent::SetLoaders();
280 }
281 
282 
283 /// retrieve the descriptor set for this project
285 {
286  return Tparent::IsSetViews();
287 }
288 
289 
291 {
292  return Tparent::GetViews();
293 }
294 
295 
297 {
298  return Tparent::SetViews();
299 }
300 
301 
302 
304 {
305  // first, set the ID to the next available
306  item.SetId(GetCounter());
307  SetCounter(GetCounter() + 1);
308 
309  folder.AddChildItem(item);
310 }
311 
312 
314  CProjectItem& item)
315 {
317  if(it->GetPointer() == &item) {
318  return &root;
319  }
320  }
321  // recursively looking child folders
323  CProjectFolder& folder = **it;
324  CProjectFolder* res = x_GetContainingFolder(folder, item);
325  if(res) {
326  return res;
327  }
328  }
329  return NULL;
330 }
331 
332 
333 /*void CGBProject::RemoveItem(CProjectItem& item)
334 {
335  CRef<CProjectItem> del_item(&item);
336 
337  //TODO do we need to look in Extra
338  CProjectFolder* parent_folder = x_GetContainingFolder(SetData(), item);
339  if (parent_folder) {
340  parent_folder->RemoveChildItem(item);
341  CProjectFolder::TItems& items = parent_folder->SetItems();
342  } else {
343  NCBI_THROW(CException, eUnknown, "Failed to find project item in project");
344  }
345 }
346 */
347 
349 {
350  SetDescr().SetCreate_date().Assign(date);
351 }
352 
353 
355 {
356  SetDescr().SetModified_date().Assign(date);
357 }
358 
359 
360 
361 END_objects_SCOPE // namespace ncbi::objects::
362 
364 
365 /* Original file checksum: lines: 65, chars: 1888, CRC32: 92b5da2 */
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
Definition: Date.hpp:53
void GetLabel(const CObject &obj, string *str, CLabel::ELabelType type, objects::CScope *scope) const
Definition: GBProject.cpp:70
CProjectFolder & SetData()
Definition: GBProject.cpp:219
CMutex m_Mutex
mutex for controlling access to the current workspace
Definition: GBProject.hpp:142
const IGBProject::TAnnot & GetAnnot() const
Definition: GBProject.cpp:253
bool IsSetAnnot() const
retrieve the descriptor set for this project
Definition: GBProject.cpp:247
virtual void Lock()
Definition: GBProject.cpp:160
virtual TDataLoaders & SetDataLoaders()
Definition: GBProject.cpp:277
virtual void Unlock()
Definition: GBProject.cpp:166
virtual void AddItem(CProjectItem &item, CProjectFolder &folder)
Add an item to the current project.
Definition: GBProject.cpp:303
CRef< CProjectFolder > m_Folders
mutable project folder this is for compliance with the IGBProject interface
Definition: GBProject.hpp:146
IGBProject::TViews & SetViews()
Definition: GBProject.cpp:296
CProjectFolder * x_GetContainingFolder(CProjectFolder &root, CProjectItem &item)
Definition: GBProject.cpp:313
virtual const TDataLoaders & GetDataLoaders() const
Definition: GBProject.cpp:271
bool IsSetViews() const
retrieve the view descriptor set for this project
Definition: GBProject.cpp:284
CGBProject(void)
Definition: GBProject.cpp:139
IGBProject::TAnnot & SetAnnot()
Definition: GBProject.cpp:259
bool IsSetDescr() const
retrieve the descriptor set for this project
Definition: GBProject.cpp:228
const CProjectDescr & GetDescr() const
Definition: GBProject.cpp:234
virtual CScope * GetScope()
Definition: GBProject.cpp:179
virtual bool IsSetDataLoaders() const
retrieve the data loader descriptor set for this project
Definition: GBProject.cpp:265
~CGBProject(void)
Definition: GBProject.cpp:155
virtual void SetScope(CScope *scope)
scope manipulators
Definition: GBProject.cpp:172
void SetModifiedDate(const CDate &date)
SetModifiedDate() will add a descriptor for the update date.
Definition: GBProject.cpp:354
const CProjectFolder & GetData() const
retrieve the folders containing our project items
Definition: GBProject.cpp:186
CProjectDescr & SetDescr()
Definition: GBProject.cpp:240
void SetCreateDate(const CDate &date)
SetCreateDate() will add a descriptor for creation date.
Definition: GBProject.cpp:348
CRef< CScope > m_Scope
Definition: GBProject.hpp:149
const IGBProject::TViews & GetViews() const
Definition: GBProject.cpp:290
CObject –.
Definition: ncbiobj.hpp:180
void AddChildItem(CProjectItem &child_item)
CScope –.
Definition: scope.hpp:92
CTime –.
Definition: ncbitime.hpp:303
Template class for iteration on objects of class C (non-medifiable version)
Definition: iterator.hpp:767
list< CRef< CLoaderDescriptor > > TDataLoaders
Definition: igbproject.hpp:70
list< CRef< CViewDescriptor > > TViews
Definition: igbproject.hpp:69
list< CRef< CProjectAnnot > > TAnnot
Definition: igbproject.hpp:68
ILabelHandler interface.
Definition: label.hpp:136
static const char * str(char *buf, int n)
Definition: stats.c:84
static FILE * f
Definition: readconf.c:23
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:914
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:921
#define NULL
Definition: ncbistd.hpp:225
static void RegisterLabelHandler(const string &type, ILabelHandler &handler)
Definition: label.cpp:229
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
static bool HasHandler(const CTypeInfo &type)
Definition: label.cpp:243
static const string sm_SbTp_ProjectVer1
Definition: user_type.hpp:108
ELabelType
Definition: label.hpp:60
static const string sm_Tp_Project
Definition: user_type.hpp:73
@ eType
Definition: label.hpp:65
@ eUserSubtype
Definition: label.hpp:64
@ eUserTypeAndContent
Definition: label.hpp:66
@ eContent
Definition: label.hpp:62
@ eDescription
Definition: label.hpp:68
@ eUserType
Definition: label.hpp:63
@ eDescriptionBrief
Definition: label.hpp:67
TObjectType * GetPointer(void) noexcept
Get pointer,.
Definition: ncbiobj.hpp:994
void Reset(void) noexcept
Reset reference object.
Definition: ncbiobj.hpp:769
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:104
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:101
void Lock(void)
Lock mutex.
void Unlock(void)
Unlock mutex.
@ eCurrent
Use current time. See also CCurrentTime.
Definition: ncbitime.hpp:307
list< CRef< CProjectItem > > TItems
void SetCreate_date(TCreate_date &value)
Assign a value to Create_date data member.
const TTitle & GetTitle(void) const
Get the Title member data.
TFolders & SetFolders(void)
Assign a value to Folders data member.
void SetId(TId value)
Assign a value to Id data member.
bool IsSetTitle(void) const
user-defined title for the workspace Check if a value has been assigned to Title data member.
const TFolders & GetFolders(void) const
Get the Folders member data.
list< CRef< CProjectFolder > > TFolders
void SetInfo(TInfo &value)
Assign a value to Info data member.
void SetModified_date(TModified_date &value)
Assign a value to Modified_date data member.
const TItems & GetItems(void) const
Get the Items member data.
TItems & SetItems(void)
Assign a value to Items data member.
bool IsSetLoaders(void) const
a set of data sources including data loader and data Check if a value has been assigned to Loaders da...
Definition: GBProject_.hpp:868
bool IsSetAnnot(void) const
arbitrary annotations Check if a value has been assigned to Annot data member.
Definition: GBProject_.hpp:843
TLoaders & SetLoaders(void)
Assign a value to Loaders data member.
Definition: GBProject_.hpp:886
TDescr & SetDescr(void)
Assign a value to Descr data member.
Definition: GBProject_.hpp:643
const TViews & GetViews(void) const
Get the Views member data.
Definition: GBProject_.hpp:905
const TLoaders & GetLoaders(void) const
Get the Loaders member data.
Definition: GBProject_.hpp:880
bool IsSetDescr(void) const
standard descriptors Check if a value has been assigned to Descr data member.
Definition: GBProject_.hpp:622
TCounter GetCounter(void) const
Get the Counter member data.
Definition: GBProject_.hpp:597
const TDescr & GetDescr(void) const
Get the Descr member data.
Definition: GBProject_.hpp:634
const TAnnot & GetAnnot(void) const
Get the Annot member data.
Definition: GBProject_.hpp:855
TExtra & SetExtra(void)
Assign a value to Extra data member.
Definition: GBProject_.cpp:96
bool IsSetViews(void) const
Definition: GBProject_.hpp:893
bool IsSetExtra(void) const
a set of extra analyses perfromed by the user each of these may have descriptors Check if a value has...
Definition: GBProject_.hpp:682
TAnnot & SetAnnot(void)
Assign a value to Annot data member.
Definition: GBProject_.hpp:861
TCounter & SetCounter(void)
Assign a value to Counter data member.
Definition: GBProject_.hpp:610
const TCore & GetCore(void) const
Get the Core member data.
Definition: GBProject_.hpp:664
const TExtra & GetExtra(void) const
Get the Extra member data.
Definition: GBProject_.hpp:694
TViews & SetViews(void)
Assign a value to Views data member.
Definition: GBProject_.hpp:911
bool IsSetCore(void) const
the core item we wrap Check if a value has been assigned to Core data member.
Definition: GBProject_.hpp:652
int i
static MDB_envinfo info
Definition: mdb_load.c:37
Defines: CTimeFormat - storage class for time format.
Definition: type.c:6
#define _ASSERT
Modified on Sun Nov 08 14:00:44 2026 by modify_doxy.py rev. 717554