ct_common
1.0.1
Common library for combinatorial testing
|
00001 //===----- ct_common/common/constraint_a_binary.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 binary arithmetic constraints 00010 // 00011 //===----------------------------------------------------------------------===// 00012 00013 #ifndef CT_COMMON_CONSTRAINT_A_BINARY_H_ 00014 #define CT_COMMON_CONSTRAINT_A_BINARY_H_ 00015 00016 #include <boost/shared_ptr.hpp> 00017 #include <ct_common/common/utils.h> 00018 #include <ct_common/common/constraint_a.h> 00019 #include <ct_common/common/exp_a.h> 00020 00021 namespace ct { 00022 namespace common { 00026 class DLL_EXPORT Constraint_A_Binary : public Constraint_A { 00027 public: 00028 Constraint_A_Binary(void); 00029 Constraint_A_Binary(const Constraint_A_Binary &from); 00030 Constraint_A_Binary &operator = (const Constraint_A_Binary &right); 00031 virtual ~Constraint_A_Binary(void); 00032 00033 virtual std::string get_class_name(void) const; 00034 static std::string class_name(void); 00035 virtual void dump(std::ostream &os, const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs) const; 00037 virtual std::string get_op_token(void) const = 0; 00038 00039 boost::shared_ptr<const Exp_A> get_loprd(void) const { return boost::dynamic_pointer_cast<Exp_A>(this->oprds_[0]); } 00040 boost::shared_ptr<const Exp_A> get_roprd(void) const { return boost::dynamic_pointer_cast<Exp_A>(this->oprds_[1]); } 00041 00042 void set_loprd(const boost::shared_ptr<TreeNode> &loprd) { this->oprds_[0] = loprd; } 00043 void set_roprd(const boost::shared_ptr<TreeNode> &roprd) { this->oprds_[1] = roprd; } 00044 00046 void set_precision(double precision) { this->precision_ = (precision>=0) ? precision : -precision; } // absolute value 00048 double get_precision(void) const { return this->precision_; } 00049 00050 virtual EvalType_Bool Evaluate( 00051 const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, 00052 const Assignment &assignment) const; 00053 00054 private: 00056 virtual bool evaluate_func_int(int val_1, int val_2) const = 0; 00058 virtual bool evaluate_func_double(double val_1, double val_2) const = 0; 00059 00060 protected: 00061 double precision_; 00062 }; 00063 } // namespace common 00064 } // namespace ct 00065 00066 #endif // CT_COMMON_CONSTRAINT_A_BINARY_H_