ct_common
1.0.1
Common library for combinatorial testing
|
00001 //===----- ct_common/common/exp_a.h -----------------------------*- C++ -*-===// 00002 // 00003 // The ct_common Library 00004 // 00005 // This file is distributed under the MIT license. See LICENSE for details. 00006 // 00007 //===----------------------------------------------------------------------===// 00008 // 00009 // This header file contains the base class for arithmetic expressions 00010 // 00011 //===----------------------------------------------------------------------===// 00012 00013 #ifndef CT_COMMON_EXP_A_H_ 00014 #define CT_COMMON_EXP_A_H_ 00015 00016 #include <ct_common/common/utils.h> 00017 #include <ct_common/common/exp.h> 00018 #include <ct_common/common/paramspec.h> 00019 #include <boost/shared_ptr.hpp> 00020 #include <ct_common/common/eval_type_int.h> 00021 #include <ct_common/common/eval_type_double.h> 00022 #include <ct_common/common/assignment.h> 00023 00024 namespace ct { 00025 namespace common { 00029 enum eEXP_A_TYPE { 00030 EAT_INT, 00031 EAT_DOUBLE, 00032 }; 00033 00038 #define GET_EXP_VAL(type, identifier, exp, param_specs, assignment) \ 00039 type identifier; \ 00040 switch (exp->get_type()) { \ 00041 case EAT_INT: \ 00042 identifier = exp->EvaluateInt(param_specs, assignment); \ 00043 break; \ 00044 case EAT_DOUBLE: \ 00045 identifier = exp->EvaluateDouble(param_specs, assignment); \ 00046 break; \ 00047 default: \ 00048 CT_EXCEPTION("unrecognized expression type when evaluating"); \ 00049 } 00050 00054 class DLL_EXPORT Exp_A : public Exp { 00055 public: 00056 Exp_A(void); 00057 Exp_A(const Exp_A &from); 00058 Exp_A &operator = (const Exp_A &right); 00059 virtual ~Exp_A(void) = 0; 00060 00061 public: 00062 virtual std::string get_class_name(void) const; 00063 static std::string class_name(void); 00064 00065 public: 00067 EvalType_Double EvaluateDouble( 00068 const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, 00069 const Assignment &assignment) const; 00071 EvalType_Int EvaluateInt( 00072 const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, 00073 const Assignment &assignment) const; 00074 00075 eEXP_A_TYPE get_type(void) const { return this->type_; } 00076 void set_type(eEXP_A_TYPE type) { this->type_ = type; } 00077 00078 private: 00080 virtual EvalType_Double EvaluateDouble_Impl( const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, 00081 const Assignment &assignment) const = 0; 00083 virtual EvalType_Int EvaluateInt_Impl( const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, 00084 const Assignment &assignment) const = 0; 00085 00086 protected: 00087 eEXP_A_TYPE type_; 00088 }; 00089 } // namespace common 00090 } // namespace ct 00091 00092 #endif // CT_COMMON_EXP_A_H_