Debian Codegraph @

include/BALL/MOLMEC/COMMON/ruleEvaluator.h

raw symbols SCIP
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: ruleEvaluator.h,v 1.16 2005/12/23 17:01:52 amoll Exp $
5 //
6
7 // Molecular Mechanics: rule-based assignment of properties (typenames, charges, radii, etc.)
8
9 #ifndef BALL_MOLMEC_COMMON_RULEEVALUATOR_H
10 #define BALL_MOLMEC_COMMON_RULEEVALUATOR_H
11
12 #ifndef BALL_DATATYPE_STRINGHASHMAP_H
13 # include <BALL/DATATYPE/stringHashMap.h>
14 #endif
15
16 #ifndef BALL_KERNEL_EXPRESSION_H
17 # include <BALL/KERNEL/expression.h>
18 #endif
19
20 #include <list>
21 #include <utility>
22
23 namespace BALL
24 {
25 class INIFile;
26
27 /** Rule evaluator class.
28 This class provides means for evaluating rules on Atoms.
29 It is a helper class of RuleProcessors.
30 Rules define values depending on atom constellations.
31 They are defined in an INIFile. \par
32
33 @see RuleProcessor
34
35 \ingroup MolmecAssignment
36 */
37 class BALL_EXPORT RuleEvaluator
38 {
39 public:
40
41 BALL_CREATE(RuleEvaluator)
42
43 /** @name Type Definitions
44 */
45 //@{
46
47 /** Type definition for a list containing rules.
48 */
49 typedef std::list<std::pair<Expression, String> > RuleList;
50
51 /** Type definition for a hashmap containing the lists of rules.
52 */
53 typedef StringHashMap<RuleList> RuleMap;
54
55 //@}
56 /** @name Constructors and Destructor
57 */
58 //@{
59
60 /** Default constructor
61 */
62 RuleEvaluator() ;
63
64 /** Detailed constructor
65 */
66 RuleEvaluator(INIFile& file, const String& prefix) ;
67
68 /** Copy constructor
69 */
70 RuleEvaluator(const RuleEvaluator& evaluator) ;
71
72 /** Destructor
73 */
74 virtual ~RuleEvaluator() ;
75
76 //@}
77 /** @name Accessors
78 */
79 //@{
80
81 /**
82 */
83 bool initialize(INIFile& file, const String& prefix) ;
84
85 /** Return the prefix of the INI file sections
86 */
87 const String& getPrefix() const ;
88
89 /** Set the prefix of the INI file sections
90 */
91 void setPrefix(const String& prefix) ;
92
93 //@}
94 /** @name Assignment
95 */
96 //@{
97
98 /** Assignment operator
99 */
100 const RuleEvaluator& operator = (const RuleEvaluator& evaluator)
101 ;
102
103 /** Clear method
104 */
105 virtual void clear() ;
106
107 //@}
108 /** @name Predicates
109 */
110 //@{
111
112 /** Rule evaluation.
113 Evaluate all matching rules (in the correct order) and return
114 the corresponding value. If no rule matches, an empty string is
115 returned.
116 */
117 String operator () (const Atom& atom) const ;
118
119 /** Equality operator */
120 bool operator == (const RuleEvaluator& evaluator) const ;
121
122 //@}
123 /** @name Debugging and Diagnostics
124 */
125 //@{
126
127 /**
128 */
129 bool isValid() const ;
130
131 /**
132 */
133 void dump(std::ostream& s = std::cout, Size indent_depth = 0) const
134 ;
135
136 //@}
137
138 protected:
139
140 //_ parse the section with name: predicate_ + ":" + symbol of file
141 void extractSection_(INIFile& file, const String& symbol) ;
142
143 //_ The INI file section prefix
144 String prefix_;
145
146 //_ The map relating an element name and the corresponding list of expressions
147 RuleMap rule_map_;
148
149 //_
150 bool valid_;
151
152 };
153 } // namespace BALL
154
155
156 #endif // BALL_MOLMEC_COMMON_RULEEVALUATOR_H