Scopira  20080306
objecttype.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_OBJECTTYPE_H__
15 #define __INCLUDED_SCOPIRA_CORE_OBJECTTYPE_H__
16 
17 #include <vector>
18 
19 #include <scopira/tool/object.h>
20 #include <scopira/tool/objflowloader.h>
21 #include <scopira/tool/iterator.h>
22 #include <scopira/tool/export.h>
23 #include <scopira/core/register.h>
24 
25 namespace scopira
26 {
27  namespace core
28  {
29  class objecttype;
30  }
31 }
32 
39 {
40  private:
41  typedef std::vector<objecttype*> parents_t;
42  typedef std::vector<scopira::tool::count_ptr<objecttype> > childs_t; // bad english, yeah :)
43 
44  public:
46 
47  private:
48  parents_t dm_parents;
49  childs_t dm_childs; // parents and children
50  std::string dm_name; // name of the type
51  copyfunc_t dm_copyfunc;
52 
53  public:
55  SCOPIRA_EXPORT objecttype(const std::string &name, copyfunc_t cp);
56 
62  const std::string &get_name(void) const { return dm_name; }
63 
69  bool has_copyfunc(void) const { return dm_copyfunc != 0; }
70 
75  SCOPIRA_EXPORT void add_child(objecttype *d);
76 
81  SCOPIRA_EXPORT objecttype_iterator get_parent_iterator(void);
86  SCOPIRA_EXPORT objecttype_iterator get_child_iterator(void);
87 
95  SCOPIRA_EXPORT objecttype * find(const std::string & _name);
96 
103  SCOPIRA_EXPORT bool is_base(const objecttype *d) const;
104 
110  SCOPIRA_EXPORT int base_depth(const objecttype *d) const;
111 
117  SCOPIRA_EXPORT void print_tree(int indent = 0);
118 
120  template <class CT>
121  CT * load_copy(const scopira::tool::object *src) const { return dynamic_cast<CT*>(load_copy_impl(src)); }
122 
123  protected:
125  SCOPIRA_EXPORT virtual void print_tree_this(int indent);
126 
127  private:
128  SCOPIRA_EXPORT object * load_copy_impl(const scopira::tool::object *srco) const;
129 };
130 
131 #endif
132 
Definition: objecttype.h:38
Definition: archiveflow.h:20
objecttype_iterator get_child_iterator(void)
Definition: object.h:71
void add_child(objecttype *d)
Definition: iterator.h:26
bool is_base(const objecttype *d) const
objecttype_iterator get_parent_iterator(void)
objecttype(const std::string &name, copyfunc_t cp)
ctor
bool has_copyfunc(void) const
Definition: objecttype.h:69
int base_depth(const objecttype *d) const
CT * load_copy(const scopira::tool::object *src) const
internal
Definition: objecttype.h:121
virtual void print_tree_this(int indent)
internal
objecttype * find(const std::string &_name)
void print_tree(int indent=0)
const std::string & get_name(void) const
Definition: objecttype.h:62