xc
ActionRelationships.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //ActionRelationships.hxx
22 
23 #ifndef RELACCIONES_H
24 #define RELACCIONES_H
25 
26 #include "utility/kernel/CommandEntity.h"
27 #include <set>
28 
31 namespace cmb_acc{
32 
33 class LoadCombinationVector;
34 class ActionsFamily;
35 
37 //
40  {
41  public:
42  typedef std::set<std::string> set_string;
43 
44  typedef std::deque<std::string> dq_string;
45 
46  static std::string limpia(const std::string &str);
47  static std::deque<std::string> get_combination_addends(const std::string &str);
48  static std::deque<std::string> get_combination_actions_names(const std::string &str);
49  private:
50  set_string incompatibles;
51  dq_string main_actions;
52  bool contiene_incomp;
53 
54  template<typename InputIterator>
55  std::string names(InputIterator, InputIterator) const;
56  void concat_incompatibles(const set_string &);
57  void concat_main_actions(const dq_string &);
58  bool match(const std::string &,const dq_string &) const;
59  bool match_any(const set_string &,const dq_string &) const;
60  bool match_all(const set_string &,const dq_string &) const;
61 
62  public:
63  ActionRelationships(void);
64 
66  inline void appendIncompatible(const std::string &str)
67  { incompatibles.insert(str); }
69  inline void appendMain(const std::string &str)
70  { main_actions.push_back(str); }
71 
72  bool matchIncompatibles(const dq_string &) const;
73  bool incompatible(const std::string &) const;
74 
75  bool esclavaDe(const std::string &) const;
76  bool esEsclava(void) const
77  { return !main_actions.empty(); }
78  bool tieneHuerfanas(void) const
79  { return !main_actions.empty(); }
80  void updateMainActions(const std::string &nmb);
81 
82  inline void setContieneIncomp(bool b)
83  { contiene_incomp= b; }
86  inline bool contieneIncomp(void) const
87  { return contiene_incomp; }
88 
89  void concat(const ActionRelationships &);
90 
91  boost::python::dict getPyDict(void) const;
92  void setPyDict(const boost::python::dict &);
93 
94  std::string incompatibleNames(void) const;
95  std::string masterNames(void) const;
96  void Print(std::ostream &os) const;
97  };
98 
99 std::ostream &operator<<(std::ostream &os,const ActionRelationships &acc);
100 
103 const LoadCombinationVector &must_contain(const LoadCombinationVector &, const ActionsFamily &);
104 
107 template<typename InputIterator>
108 std::string cmb_acc::ActionRelationships::names(InputIterator begin, InputIterator end) const
109  {
110  std::string retval;
111  if(begin!=end)
112  {
113  InputIterator i= begin;
114  retval= (*i); i++;
115  for(;i!= end;i++)
116  retval+= "," + (*i);
117  }
118  return retval;
119  }
120 
121 } //fin namespace nmb_acc.
122 
123 #endif
bool incompatible(const std::string &) const
Return true if the action which name is being passed as parameter is not compatible with this one...
Definition: ActionRelationships.cc:134
static std::string limpia(const std::string &str)
Elimina el factor que multiplica a la acción en la cadena de la forma "1.35*A" que se pasa como parám...
Definition: ActionRelationships.cc:32
bool esclavaDe(const std::string &) const
Return true if the action which name is being passed as parameter is a master of this one...
Definition: ActionRelationships.cc:145
Routines to generate combinations of actions.
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: ActionRelationships.cc:192
static std::deque< std::string > get_combination_addends(const std::string &str)
Return los sumandos de la text string que se pasa como parámetro.
Definition: ActionRelationships.cc:41
bool contieneIncomp(void) const
Return true if this combination contains incompatible actions.
Definition: ActionRelationships.h:86
void appendIncompatible(const std::string &str)
Append the regular expression argument to the list of incompatible actions.
Definition: ActionRelationships.h:66
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: ActionRelationships.cc:208
static std::deque< std::string > get_combination_actions_names(const std::string &str)
Return the names of the actions of the combinations.
Definition: ActionRelationships.cc:56
ActionRelationships(void)
Default constructor.
Definition: ActionRelationships.cc:65
Objet that can execute python scripts.
Definition: CommandEntity.h:40
bool matchIncompatibles(const dq_string &) const
Return verdadero si la text strings que se pasan como parámetro verifica alguna de las expresiones de...
Definition: ActionRelationships.cc:128
const LoadCombinationVector & get_compatibles(const LoadCombinationVector &)
Return the combinations filtering those that contain incompatible actions.
Definition: ActionRelationships.cc:233
void appendMain(const std::string &str)
Append the regular expression argument to the list of main actions.
Definition: ActionRelationships.h:69
void updateMainActions(const std::string &nmb)
Remove from the masters lists those which names match with the argument name.
Definition: ActionRelationships.cc:159
Combination container.
Definition: LoadCombinationVector.h:38
Relationship of an action with the other ones.
Definition: ActionRelationships.h:39
const LoadCombinationVector & filtraCombsEsclavasHuerfanas(const LoadCombinationVector &)
Filters the combinations where an slave actions appears without its master.
Definition: ActionRelationships.cc:258
Family of actions (permanent, variable, accidental,...)
Definition: ActionsFamily.h:44