ct_common  1.0.1
Common library for combinatorial testing
src/ct_common/common/constraint_a_binary.cpp
Go to the documentation of this file.
00001 //===----- ct_common/common/constraint_a_binary.cpp -------------*- 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 file contains the function definitions of class Constraint_A_Binary
00010 //
00011 //===----------------------------------------------------------------------===//
00012 
00013 #include <ct_common/common/constraint_a_binary.h>
00014 #include <ct_common/common/arithmetic_utils.h>
00015 
00016 using namespace ct::common;
00017 
00018 Constraint_A_Binary::Constraint_A_Binary(void)
00019     : Constraint_A(), precision_(0) {
00020   this->oprds_.resize(2);
00021 }
00022 
00023 Constraint_A_Binary::Constraint_A_Binary(const Constraint_A_Binary &from)
00024     : Constraint_A(from), precision_(from.precision_) {
00025 }
00026 
00027 Constraint_A_Binary &Constraint_A_Binary::operator = (
00028     const Constraint_A_Binary &right) {
00029   Constraint_A::operator=(right);
00030   this->precision_ = right.precision_;
00031   return *this;
00032 }
00033 
00034 Constraint_A_Binary::~Constraint_A_Binary(void) {
00035 }
00036 
00037 std::string Constraint_A_Binary::get_class_name(void) const {
00038   return Constraint_A_Binary::class_name();
00039 }
00040 
00041 std::string Constraint_A_Binary::class_name(void) {
00042   return "Constraint_A_Binary";
00043 }
00044 
00045 EvalType_Bool Constraint_A_Binary::Evaluate( const std::vector<boost::shared_ptr<ParamSpec> > &param_specs,
00046                                 const Assignment &assignment) const {
00047   EvalType_Bool tmp_return;
00048   if (this->get_loprd()->get_type() == EAT_INT &&
00049       this->get_roprd()->get_type() == EAT_INT) {
00050     GET_EXP_VAL(EvalType_Int, val_l, this->get_loprd(), param_specs, assignment);
00051     GET_EXP_VAL(EvalType_Int, val_r, this->get_roprd(), param_specs, assignment);
00052     tmp_return.is_valid_ = val_l.is_valid_ && val_r.is_valid_;
00053     if (tmp_return.is_valid_) {
00054       tmp_return.value_ = this->evaluate_func_int(val_l.value_, val_r.value_);
00055     }
00056   } else {
00057     GET_EXP_VAL(EvalType_Int, val_l, this->get_loprd(), param_specs, assignment);
00058     GET_EXP_VAL(EvalType_Int, val_r, this->get_roprd(), param_specs, assignment);
00059     tmp_return.is_valid_ = val_l.is_valid_ && val_r.is_valid_;
00060     if (tmp_return.is_valid_) {
00061       tmp_return.value_ = this->evaluate_func_int(val_l.value_, val_r.value_);
00062     }
00063   }
00064   return tmp_return;
00065 }
00066 
00067 void Constraint_A_Binary::dump(std::ostream &os, const std::vector<boost::shared_ptr<ParamSpec> > &param_specs) const {
00068   os << "(";
00069   this->get_loprd()->dump(os, param_specs);
00070   os << this->get_op_token();
00071   this->get_roprd()->dump(os, param_specs);
00072   os << ")";
00073 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines