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 
30 namespace cmb_acc{
31 
32 class LoadCombinationVector;
33 
35 //
38  {
39  public:
40  typedef std::deque<std::string> dq_string;
41  typedef dq_string::iterator iterator;
42  typedef dq_string::const_iterator const_iterator;
43 
44  static std::string limpia(const std::string &str);
45  static std::deque<std::string> get_combination_addends(const std::string &str);
46  static std::deque<std::string> get_combination_actions_names(const std::string &str);
47  private:
48  dq_string incompatibles;
49  dq_string main_actions;
50  bool contiene_incomp;
51 
52  std::string names(const dq_string &) const;
53  void concat_incompatibles(const dq_string &);
54  void concat_main_actions(const dq_string &);
55  bool match(const std::string &,const dq_string &) const;
56  bool match_any(const dq_string &,const dq_string &) const;
57  bool match_all(const dq_string &,const dq_string &) const;
58 
59  public:
60  ActionRelationships(void);
61 
63  inline void appendIncompatible(const std::string &str)
64  { incompatibles.push_back(str); }
66  inline void appendMain(const std::string &str)
67  { main_actions.push_back(str); }
68 
69  bool matchIncompatibles(const dq_string &) const;
70  bool incompatible(const std::string &) const;
71 
72  bool esclavaDe(const std::string &) const;
73  bool esEsclava(void) const
74  { return !main_actions.empty(); }
75  bool tieneHuerfanas(void) const
76  { return !main_actions.empty(); }
77  void updateMainActions(const std::string &nmb);
78 
79  inline void setContieneIncomp(bool b)
80  { contiene_incomp= b; }
83  inline bool contieneIncomp(void) const
84  { return contiene_incomp; }
85 
86  void concat(const ActionRelationships &);
87 
88  boost::python::dict getPyDict(void) const;
89  void setPyDict(const boost::python::dict &);
90 
91  std::string incompatibleNames(void) const;
92  std::string masterNames(void) const;
93  void Print(std::ostream &os) const;
94  };
95 
96 std::ostream &operator<<(std::ostream &os,const ActionRelationships &acc);
97 
100 
101 } //fin namespace nmb_acc.
102 
103 #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:148
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:159
Routines to generate combinations of actions.
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: ActionRelationships.cc:205
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:83
void appendIncompatible(const std::string &str)
Append the regular expression argument to the list of incompatible actions.
Definition: ActionRelationships.h:63
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: ActionRelationships.cc:221
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:142
const LoadCombinationVector & get_compatibles(const LoadCombinationVector &)
Return the combinations filtering those that contain incompatible actions.
Definition: ActionRelationships.cc:243
void appendMain(const std::string &str)
Append the regular expression argument to the list of main actions.
Definition: ActionRelationships.h:66
void updateMainActions(const std::string &nmb)
Remove from the masters lists those which names match with the argument name.
Definition: ActionRelationships.cc:173
Combination container.
Definition: LoadCombinationVector.h:36
Relationship of an action with the other ones.
Definition: ActionRelationships.h:37
const LoadCombinationVector & filtraCombsEsclavasHuerfanas(const LoadCombinationVector &)
Filters the combinations where an slave actions appears without its master.
Definition: ActionRelationships.cc:268