Scopira  20080306
project.h
1 
2 /*
3  * Copyright (c) 2005 National Research Council
4  *
5  * All rights reserved.
6  *
7  * This material is confidential and proprietary information of
8  * National Research Council Canada ("Confidential Information").
9  * This Confidential Information may only be used and reproduced
10  * in accordance with the terms of the license agreement.
11  *
12  */
13 
14 #ifndef __INCLUDED_SCOPIRA_CORE_MODELGROUP_H__
15 #define __INCLUDED_SCOPIRA_CORE_MODELGROUP_H__
16 
17 #include <map>
18 
19 #include <scopira/core/model.h>
20 #include <scopira/tool/export.h>
21 
22 namespace scopira
23 {
24  namespace core
25  {
26  class project_i;
27  class project_base;
28  }
29 }
30 
39 {
40  public:
43 
44  public:
46  virtual bool is_project(void) const { return true; }
47 
53  SCOPIRA_EXPORT virtual void add_model(model_i *parent, model_i *rec) = 0;
59  SCOPIRA_EXPORT virtual void remove_model(model_i *parent, model_i *rec) = 0;
65  SCOPIRA_EXPORT virtual bool contains_model(model_i *parent, model_i *rec) = 0;
70  SCOPIRA_EXPORT virtual bool contains_model(model_i *rec) = 0;
71 
77  SCOPIRA_EXPORT virtual model_i * get_parent(model_i *child) = 0;
78 
79  // future functions
80  // something about properties
81  // named-models? (or is that what find_model is for?)
82  // rename get_parent to get_parent_model
83 
91  SCOPIRA_EXPORT virtual model_i * find_model(model_i *parent, const std::string &title) const = 0;
92 
94  SCOPIRA_EXPORT virtual model_iterator get_model_iterator(model_i *parent) const = 0;
95 
101  SCOPIRA_EXPORT virtual bool is_project_empty(void) const = 0;
102 
108  SCOPIRA_EXPORT virtual void clear_project(void) = 0;
109 
115  SCOPIRA_EXPORT virtual void move_project(scopira::core::project_i *rhs) = 0;
116 
118  SCOPIRA_EXPORT virtual bool get_tagged_model_from_project(model_i *parent, const std::string &name,
120 
121  protected:
123  SCOPIRA_EXPORT project_i(void);
125  SCOPIRA_EXPORT project_i(const std::string &title);
126 };
127 
136 {
137  protected:
138  // this is a MULTI map of parents->children
139  typedef std::multimap< tool::count_ptr<core::model_i>, tool::count_ptr<core::model_i> > model_set_t;
140  typedef std::pair<model_set_t::const_iterator, model_set_t::const_iterator> const_iterator_pair;
141  typedef std::pair<model_set_t::iterator, model_set_t::iterator> iterator_pair;
142 
143  // this is a map of children, parent (reverse of the above)
144  typedef std::map<core::model_i*, core::model_i*> child_map;
145 
146  // in the future, there will be a child->optional properties set
147  // map here
148 
149  model_set_t dm_models;
150  child_map dm_child;
151 
152  public:
154  SCOPIRA_EXPORT project_base(void);
156  SCOPIRA_EXPORT project_base(const std::string &title);
157 
159  SCOPIRA_EXPORT virtual ~project_base();
160 
161  SCOPIRA_EXPORT virtual bool load(tool::iobjflow_i& in);
162  SCOPIRA_EXPORT virtual void save(tool::oobjflow_i& out) const;
163 
169  SCOPIRA_EXPORT virtual void add_model(model_i *parent, model_i *rec);
175  SCOPIRA_EXPORT virtual void remove_model(model_i *parent, model_i *rec);
181  SCOPIRA_EXPORT virtual bool contains_model(model_i *parent, model_i *rec);
186  SCOPIRA_EXPORT virtual bool contains_model(model_i *rec);
187 
193  SCOPIRA_EXPORT virtual model_i * get_parent(model_i *child);
194 
202  SCOPIRA_EXPORT virtual model_i * find_model(model_i *parent, const std::string &title) const;
203 
205  SCOPIRA_EXPORT virtual model_iterator get_model_iterator(model_i *parent) const;
206 
207  SCOPIRA_EXPORT virtual bool is_project_empty(void) const;
208  SCOPIRA_EXPORT virtual void clear_project(void);
209  SCOPIRA_EXPORT virtual void move_project(scopira::core::project_i *rhs);
210 
212  SCOPIRA_EXPORT virtual bool get_tagged_model_from_project(model_i *parent, const std::string &name,
214 
215  private:
219  void remove_by_range(model_set_t::iterator _begin, model_set_t::iterator _last);
220 
221  class project_iterator;
222 };
223 
224 #endif
225 
virtual void clear_project(void)=0
virtual model_i * get_parent(model_i *child)=0
virtual bool load(scopira::tool::iobjflow_i &in)
for title, mostly
Definition: archiveflow.h:20
Definition: flow.h:352
Definition: project.h:135
virtual model_i * find_model(model_i *parent, const std::string &title) const =0
project_i(void)
Default initing ctor.
Definition: model.h:216
Definition: iterator.h:26
virtual void move_project(scopira::core::project_i *rhs)=0
Definition: object.h:42
virtual bool get_tagged_model_from_project(model_i *parent, const std::string &name, scopira::tool::count_ptr< scopira::core::model_i > &out)=0
used by model_i
scopira::core::model_iterator model_iterator
the model iterator type
Definition: project.h:42
virtual model_iterator get_model_iterator(model_i *parent) const =0
gets a listing of all the sub models
Definition: flow.h:421
virtual bool contains_model(model_i *parent, model_i *rec)=0
virtual void add_model(model_i *parent, model_i *rec)=0
virtual void remove_model(model_i *parent, model_i *rec)=0
Definition: project.h:38
virtual void save(scopira::tool::oobjflow_i &out) const
for title, mostly
virtual bool is_project(void) const
I AM a project!
Definition: project.h:46
virtual bool is_project_empty(void) const =0