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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/sg/search_action (Version 11.3.0) and /externals/g4tools/include/tools/sg/search_action (Version 11.2)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_sg_search_action                      4 #ifndef tools_sg_search_action
  5 #define tools_sg_search_action                      5 #define tools_sg_search_action
  6                                                     6 
  7 #include "action"                                   7 #include "action"
  8                                                     8 
  9 #include <vector>                                   9 #include <vector>
 10                                                    10 
 11 namespace tools {                                  11 namespace tools {
 12 namespace sg {                                     12 namespace sg {
 13   class node;                                      13   class node;
 14 }}                                                 14 }}
 15                                                    15 
 16 namespace tools {                                  16 namespace tools {
 17 namespace sg {                                     17 namespace sg {
 18                                                    18 
 19 class search_action : public action {              19 class search_action : public action {
 20   TOOLS_ACTION(search_action,tools::sg::search     20   TOOLS_ACTION(search_action,tools::sg::search_action,action)
 21 public:                                            21 public:
 22   search_action(std::ostream& a_out)               22   search_action(std::ostream& a_out)
 23   :parent(a_out)                                   23   :parent(a_out)
 24   ,m_what(search_node_of_class)                    24   ,m_what(search_node_of_class)
 25   ,m_stop_at_first(false)                          25   ,m_stop_at_first(false)
 26   ,m_node(0) //not owner                           26   ,m_node(0) //not owner
 27                                                    27 
 28   ,m_done(false)                                   28   ,m_done(false)
 29   {}                                               29   {}
 30   virtual ~search_action(){}                       30   virtual ~search_action(){}
 31 public:                                            31 public:
 32   search_action(const search_action& a_from)       32   search_action(const search_action& a_from)
 33   :parent(a_from)                                  33   :parent(a_from)
 34   ,m_what(a_from.m_what)                           34   ,m_what(a_from.m_what)
 35   ,m_stop_at_first(a_from.m_stop_at_first)         35   ,m_stop_at_first(a_from.m_stop_at_first)
 36   ,m_class(a_from.m_class)                         36   ,m_class(a_from.m_class)
 37   ,m_node(a_from.m_node)                           37   ,m_node(a_from.m_node)
 38                                                    38 
 39   ,m_done(false)                                   39   ,m_done(false)
 40   {}                                               40   {}
 41   search_action& operator=(const search_action     41   search_action& operator=(const search_action& a_from){
 42     parent::operator=(a_from);                     42     parent::operator=(a_from);
 43     if(&a_from==this) return *this;                43     if(&a_from==this) return *this;
 44     m_what = a_from.m_what;                        44     m_what = a_from.m_what;
 45     m_stop_at_first = a_from.m_stop_at_first;      45     m_stop_at_first = a_from.m_stop_at_first;
 46     m_class = a_from.m_class;                      46     m_class = a_from.m_class;
 47     m_node = a_from.m_node;                        47     m_node = a_from.m_node;
 48     reset();                                       48     reset();
 49     return *this;                                  49     return *this;
 50   }                                                50   }
 51 public:                                            51 public:
 52   void reset() {                                   52   void reset() {
 53     m_done = false;                                53     m_done = false;
 54     m_objs.clear();                                54     m_objs.clear();
 55     m_path.clear();                                55     m_path.clear();
 56     m_paths.clear();                               56     m_paths.clear();
 57   }                                                57   }
 58                                                    58 
 59   enum search_what {                               59   enum search_what {
 60     search_node_of_class = 0,                      60     search_node_of_class = 0,
 61     search_path_to_node = 1,                       61     search_path_to_node = 1,
 62     search_path_to_node_of_class = 2               62     search_path_to_node_of_class = 2
 63   };                                               63   };
 64   search_what what() const {return m_what;}        64   search_what what() const {return m_what;}
 65   void set_what(search_what a_v) {m_what = a_v     65   void set_what(search_what a_v) {m_what = a_v;}
 66                                                    66 
 67   void set_done(bool a_value) {m_done = a_valu     67   void set_done(bool a_value) {m_done = a_value;}
 68   bool done() const {return m_done;}               68   bool done() const {return m_done;}
 69                                                    69 
 70   bool stop_at_first() const {return m_stop_at     70   bool stop_at_first() const {return m_stop_at_first;}
 71   void set_stop_at_first(bool a_v) {m_stop_at_     71   void set_stop_at_first(bool a_v) {m_stop_at_first = a_v;}
 72                                                    72 
 73   ////////////////////////////////////////////     73   //////////////////////////////////////////////////////////
 74   /// search_node_of_class : /////////////////     74   /// search_node_of_class : ///////////////////////////////
 75   ////////////////////////////////////////////     75   //////////////////////////////////////////////////////////
 76   //NOTE : result of a search is not necessary     76   //NOTE : result of a search is not necessary a sg::node.
 77   //       (For exa in ioda::main, could be a      77   //       (For exa in ioda::main, could be a base_button).
 78   void add_obj(void* a_obj) {m_objs.push_back(     78   void add_obj(void* a_obj) {m_objs.push_back(a_obj);}
 79   const std::vector<void*>& objs() const {retu     79   const std::vector<void*>& objs() const {return m_objs;}
 80                                                    80 
 81   void set_class(const std::string& a_class) {     81   void set_class(const std::string& a_class) {m_class = a_class;}
 82   const std::string& sclass() const {return m_     82   const std::string& sclass() const {return m_class;}
 83                                                    83 
 84   ////////////////////////////////////////////     84   //////////////////////////////////////////////////////////
 85   /// search_path_to_node : //////////////////     85   /// search_path_to_node : ////////////////////////////////
 86   ////////////////////////////////////////////     86   //////////////////////////////////////////////////////////
 87   void set_node(sg::node* a_v) {m_node = a_v;}     87   void set_node(sg::node* a_v) {m_node = a_v;}
 88   sg::node* node() const {return m_node;}          88   sg::node* node() const {return m_node;}
 89                                                    89 
 90   void path_push(sg::node* a_v) {m_path.push_b     90   void path_push(sg::node* a_v) {m_path.push_back(a_v);}
 91   void path_pop() {m_path.pop_back();}             91   void path_pop() {m_path.pop_back();}
 92                                                    92 
 93   typedef std::vector<sg::node*> path_t;           93   typedef std::vector<sg::node*> path_t;
 94   const path_t& path() const {return m_path;}      94   const path_t& path() const {return m_path;}
 95   //path_t path() {return m_path;}                 95   //path_t path() {return m_path;}
 96   void clear_path() {m_path.clear();}              96   void clear_path() {m_path.clear();}
 97                                                    97 
 98   bool do_path() const {                           98   bool do_path() const {
 99     if(m_what==search_action::search_path_to_n     99     if(m_what==search_action::search_path_to_node) return true;
100     if(m_what==search_action::search_path_to_n    100     if(m_what==search_action::search_path_to_node_of_class) return true;
101     return false;                                 101     return false;
102   }                                               102   }
103                                                   103 
104   ////////////////////////////////////////////    104   //////////////////////////////////////////////////////////
105   /// search_path_to_node_of_class : /////////    105   /// search_path_to_node_of_class : ///////////////////////
106   ////////////////////////////////////////////    106   //////////////////////////////////////////////////////////
107   void add_path(const path_t& a_p) {m_paths.pu    107   void add_path(const path_t& a_p) {m_paths.push_back(a_p);}
108                                                   108 
109   typedef std::vector<path_t> paths_t;            109   typedef std::vector<path_t> paths_t;
110   const paths_t& paths() const {return m_paths    110   const paths_t& paths() const {return m_paths;}
111                                                   111 
112 protected:                                        112 protected:
113   search_what m_what;                             113   search_what m_what;
114   bool m_stop_at_first;                           114   bool m_stop_at_first;
115                                                   115 
116   //search_node_of_class :                        116   //search_node_of_class :
117   std::string m_class;                            117   std::string m_class;
118   std::vector<void*> m_objs;                      118   std::vector<void*> m_objs;
119                                                   119 
120   //search_path_to_node :                         120   //search_path_to_node :
121   sg::node* m_node; //not owner.                  121   sg::node* m_node; //not owner.
122   path_t m_path;                                  122   path_t m_path;
123                                                   123 
124   //search_path_to_node_of_class :                124   //search_path_to_node_of_class :
125   std::vector<path_t> m_paths;                    125   std::vector<path_t> m_paths;
126                                                   126 
127   bool m_done;                                    127   bool m_done;
128 };                                                128 };
129                                                   129 
130 }}                                                130 }}
131                                                   131 
132 #endif                                            132 #endif