BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: ruleEvaluator.h,v 1.16 2005/12/23 17:01:52 amoll Exp $ 00005 // 00006 00007 // Molecular Mechanics: rule-based assignment of properties (typenames, charges, radii, etc.) 00008 00009 #ifndef BALL_MOLMEC_COMMON_RULEEVALUATOR_H 00010 #define BALL_MOLMEC_COMMON_RULEEVALUATOR_H 00011 00012 #ifndef BALL_DATATYPE_STRINGHASHMAP_H 00013 # include <BALL/DATATYPE/stringHashMap.h> 00014 #endif 00015 00016 #ifndef BALL_KERNEL_EXPRESSION_H 00017 # include <BALL/KERNEL/expression.h> 00018 #endif 00019 00020 #include <list> 00021 #include <utility> 00022 00023 namespace BALL 00024 { 00025 class INIFile; 00026 00037 class BALL_EXPORT RuleEvaluator 00038 { 00039 public: 00040 00041 BALL_CREATE(RuleEvaluator) 00042 00043 00046 00049 typedef std::list<std::pair<Expression, String> > RuleList; 00050 00053 typedef StringHashMap<RuleList> RuleMap; 00054 00056 00059 00062 RuleEvaluator() ; 00063 00066 RuleEvaluator(INIFile& file, const String& prefix) ; 00067 00070 RuleEvaluator(const RuleEvaluator& evaluator) ; 00071 00074 virtual ~RuleEvaluator() ; 00075 00077 00080 00083 bool initialize(INIFile& file, const String& prefix) ; 00084 00087 const String& getPrefix() const ; 00088 00091 void setPrefix(const String& prefix) ; 00092 00094 00097 00100 const RuleEvaluator& operator = (const RuleEvaluator& evaluator) 00101 ; 00102 00105 virtual void clear() ; 00106 00108 00111 00117 String operator () (const Atom& atom) const ; 00118 00120 bool operator == (const RuleEvaluator& evaluator) const ; 00121 00123 00126 00129 bool isValid() const ; 00130 00133 void dump(std::ostream& s = std::cout, Size indent_depth = 0) const 00134 ; 00135 00137 00138 protected: 00139 00140 //_ parse the section with name: predicate_ + ":" + symbol of file 00141 void extractSection_(INIFile& file, const String& symbol) ; 00142 00143 //_ The INI file section prefix 00144 String prefix_; 00145 00146 //_ The map relating an element name and the corresponding list of expressions 00147 RuleMap rule_map_; 00148 00149 //_ 00150 bool valid_; 00151 00152 }; 00153 } // namespace BALL 00154 00155 00156 #endif // BALL_MOLMEC_COMMON_RULEEVALUATOR_H