File: ruleEvaluator.h

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 239,888 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 95
file content (156 lines) | stat: -rw-r--r-- 2,980 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: ruleEvaluator.h,v 1.16 2005/12/23 17:01:52 amoll Exp $
//

// Molecular Mechanics: rule-based assignment of properties (typenames, charges, radii, etc.)

#ifndef BALL_MOLMEC_COMMON_RULEEVALUATOR_H
#define BALL_MOLMEC_COMMON_RULEEVALUATOR_H

#ifndef BALL_DATATYPE_STRINGHASHMAP_H
#	include <BALL/DATATYPE/stringHashMap.h>
#endif

#ifndef BALL_KERNEL_EXPRESSION_H
#	include <BALL/KERNEL/expression.h>
#endif

#include <list>
#include <utility>

namespace BALL 
{
	class INIFile;

	/**	Rule evaluator class.
			This class provides means for evaluating rules on Atoms. 
			It is a helper class of RuleProcessors. 
			Rules define values depending on atom constellations. 
			They are defined in an INIFile.  \par
			
			@see RuleProcessor

    	\ingroup  MolmecAssignment
	*/
	class BALL_EXPORT RuleEvaluator
	{
		public:

		BALL_CREATE(RuleEvaluator)

		/**	@name Type Definitions 
		*/
		//@{

		/** Type definition for a list containing rules.
		*/
		typedef std::list<std::pair<Expression, String> > RuleList;

		/**	Type definition for a hashmap containing the lists of rules.
		*/
		typedef StringHashMap<RuleList> RuleMap;

		//@}
		/**	@name Constructors and Destructor
		*/
		//@{

		/**	Default constructor
		*/
		RuleEvaluator() ;
			
		/**	Detailed constructor
		*/
		RuleEvaluator(INIFile& file, const String& prefix) ;
			
		/**	Copy constructor
		*/
		RuleEvaluator(const RuleEvaluator& evaluator) ;

		/**	Destructor
		*/
		virtual ~RuleEvaluator() ;

		//@}
		/**	@name	Accessors
		*/
		//@{

		/**
		*/
		bool initialize(INIFile& file, const String& prefix) ;

		/**	Return the prefix of the INI file sections
		*/
		const String& getPrefix() const ;
			
		/**	Set the prefix of the INI file sections
		*/
		void setPrefix(const String& prefix) ;
			
		//@}
		/**	@name	Assignment
		*/
		//@{
			
		/** Assignment operator
		*/
		const RuleEvaluator& operator = (const RuleEvaluator& evaluator)
		;

		/** Clear method
		*/
		virtual void clear() ;

		//@}
		/**	@name Predicates
		*/
		//@{
			
		/**	Rule evaluation.
				Evaluate all matching rules (in the correct order) and return
				the corresponding value. If no rule matches, an empty string is
				returned.
		*/
		String operator () (const Atom& atom) const ;

		/** Equality operator */
		bool operator == (const RuleEvaluator& evaluator) const ;

		//@}
		/**	@name Debugging and Diagnostics
		*/
		//@{

		/**	
		*/
		bool isValid() const ;

		/**	
		*/
		void dump(std::ostream& s = std::cout, Size indent_depth = 0) const
		;

		//@}

		protected:

		//_ parse the section with name: predicate_ + ":" + symbol of file
		void extractSection_(INIFile& file, const String& symbol) ;

		//_ The INI file section prefix
		String		prefix_;

		//_ The map relating an element name and the corresponding list of expressions
		RuleMap		rule_map_;

		//_ 
		bool			valid_;
		
	};
} // namespace BALL


#endif // BALL_MOLMEC_COMMON_RULEEVALUATOR_H