KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Elaboration_tree.h
Go to the documentation of this file.
1 #ifndef ELABORATION_TREE_H_
2 #define ELABORATION_TREE_H_
3 
12 #include <boost/make_shared.hpp>
13 #include <vector>
14 
15 namespace semantics
16 {
17 
24  {
25  public:
26  /*------------------------------------------------------------
27  * TYPEDEFS
28  *------------------------------------------------------------*/
29  typedef boost::shared_ptr<Elaboration_tree> Self_ptr;
35  typedef boost::shared_ptr<Object_elaboration> Obj_ptr;
36  typedef boost::shared_ptr<Binary_elaboration> Binary_ptr;
37  typedef boost::shared_ptr<Unary_elaboration> Unary_ptr;
38  typedef std::deque<Obj_ptr> Obj_queue;
39  typedef std::deque<Elab_ptr> Obj_parent_queue;
41  static const size_t TARGET;
42  static const size_t BASE;
43  static const size_t COLOR;
44  static const size_t SIZE;
45  public:
46  /*------------------------------------------------------------
47  * CONSTRUCTORS/DESTRUCTOR
48  *------------------------------------------------------------*/
49 
57  (
58  const Key_type& subject,
59  const Semantic_elaboration::Referent_code& subject_referent =
61  );
62 
63  /*------------------------------------------------------------
64  * ACCESSORS
65  *------------------------------------------------------------*/
66 
69  Elab_ptr_const root() const {return root_;}
70 
71  /*------------------------------------------------------------
72  * MANIPULATORS
73  *
74  * These are the functions that grow the tree
75  *------------------------------------------------------------*/
76 
83 
90 
100  (
101  const Key_type& relation,
102  const Key_type& base_object_class,
103  const Semantic_elaboration::Referent_code& base_referent_code =
105  );
106 
115  {
116  if(!live_objects_.empty()) pop_object_from_queue();
117  }
118 
119  /*------------------------------------------------------------
120  * DISPLAY FUNCTIONS
121  *------------------------------------------------------------*/
122 
126  void print(std::ostream& os) const {root_ -> print_subtree(os);}
127 
128  /*------------------------------------------------------------
129  * STATIC FUNCTIONS
130  *------------------------------------------------------------*/
131 
140  static Step_result take_a_step
141  (
142  const Elab_ptr_const curr,
143  const Step_code_t& step_code
144  );
145 
146  private:
147  Elab_ptr root_;
148  Obj_queue live_objects_;
149  Obj_parent_queue live_object_parents_;
150  Obj_ptr curr_object_;
151  Elab_ptr curr_parent_;
152  size_t curr_object_role_;
153 
158  void add_object_to_queue
159  (
160  const Elab_ptr parent,
161  const size_t& which_child
162  );
163 
166  void pop_object_from_queue();
167 
177  template<class T, class Traits>
178  Elab_ptr_const elaborate_attribute(const Semantic_data_base::Key_type& new_val);
179  };
180 
181 };
182 
183 
184 #endif
boost::tuple< size_t, size_t > Hash_pair
Definition: Semantic_elaboration.h:114
Elab_ptr_const root() const
get a shared pointer to the root elaboration node
Definition: Elaboration_tree.h:69
boost::shared_ptr< const Semantic_elaboration > Self_ptr_const
Definition: Semantic_elaboration.h:268
Semantic_elaboration::Step_result Step_result
Definition: Elaboration_tree.h:40
boost::shared_ptr< Binary_elaboration > Binary_ptr
Definition: Elaboration_tree.h:36
Semantic_data_base::Key_type Key_type
Definition: Elaboration_tree.h:31
static const size_t SIZE
Definition: Elaboration_tree.h:44
static const size_t COLOR
Definition: Elaboration_tree.h:43
void null_elaboration()
finish elaborating current object and move focus to next one
Definition: Elaboration_tree.h:114
void print(std::ostream &os) const
print the entire elaboration tree to ostream os
Definition: Elaboration_tree.h:126
Structure for returning results of a single sampling move.
Definition: sample_base.h:55
boost::shared_ptr< Semantic_elaboration > Self_ptr
Definition: Semantic_elaboration.h:267
the main "Semantic tree" object
Definition: Elaboration_tree.h:23
Semantic_data_base::Val_type Val_type
Definition: Elaboration_tree.h:30
static Step_result take_a_step(const Elab_ptr_const curr, const Step_code_t &step_code)
step down the tree using enumerated step type Step_code_t
Definition: Elaboration_tree.cpp:115
Semantic_elaboration::Self_ptr Elab_ptr
Definition: Elaboration_tree.h:33
std::deque< Elab_ptr > Obj_parent_queue
Definition: Elaboration_tree.h:39
Semantic_db::Key_type Key_type
Definition: Semantic_elaboration.h:112
Semantic_step_proposal::Elab_ptr Elab_ptr
Import typedefs from Semantic_step_propsal.
Definition: Semantic_step_proposal.cpp:34
boost::shared_ptr< Object_elaboration > Obj_ptr
Definition: Elaboration_tree.h:35
Elab_ptr_const elaborate_with_relation(const Key_type &relation, const Key_type &base_object_class, const Semantic_elaboration::Referent_code &base_referent_code=Semantic_elaboration::NULL_REFERENT)
elaborate description of object in focus via spatial relation
Definition: Elaboration_tree.cpp:73
Semantic_step_proposal::Elab_ptr_const Elab_ptr_const
Definition: Semantic_step_proposal.cpp:35
Elaboration_tree(const Key_type &subject, const Semantic_elaboration::Referent_code &subject_referent=Semantic_elaboration::NULL_REFERENT)
construct a new elaboration tree given an object as focus
Definition: Elaboration_tree.cpp:20
boost::tuple< Self_ptr_const, Semantic_data_base::Hash_pair > Step_result
Definition: Semantic_elaboration.h:271
std::deque< Obj_ptr > Obj_queue
Definition: Elaboration_tree.h:38
int Referent_code
Definition: Semantic_elaboration.h:272
boost::shared_ptr< Unary_elaboration > Unary_ptr
Definition: Elaboration_tree.h:37
boost::shared_ptr< Elaboration_tree > Self_ptr
Definition: Elaboration_tree.h:29
Elab_ptr_const elaborate_color(const Key_type &color)
add a color elaboration to the object currently in focus
Definition: Elaboration_tree.cpp:55
Elab_ptr_const elaborate_size(const Key_type &size)
add a size elaboration to the object currently in focus
Definition: Elaboration_tree.cpp:64
static const size_t BASE
Definition: Elaboration_tree.h:42
Semantic_data_base::Hash_pair Hash_pair
Definition: Elaboration_tree.h:32
static const Referent_code NULL_REFERENT
Definition: Semantic_elaboration.h:274
Semantic_elaboration::Self_ptr_const Elab_ptr_const
Definition: Elaboration_tree.h:34
Code
Definition: SemanticIO.h:54
Semantic_db::Val_type Val_type
Definition: Semantic_elaboration.h:111
static const size_t TARGET
Definition: Elaboration_tree.h:41