ct_common  1.0.1
Common library for combinatorial testing
src/ct_common/common/exp_a_constraintcast.cpp
Go to the documentation of this file.
00001 //===----- ct_common/common/exp_a_constraintcast.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 Exp_A_ConstraintCast
00010 //
00011 //===----------------------------------------------------------------------===//
00012 
00013 #include <ct_common/common/exp_a_constraintcast.h>
00014 
00015 using namespace ct::common;
00016 
00017 Exp_A_ConstraintCast::Exp_A_ConstraintCast(void)
00018     : Exp_A_Atom() {
00019   oprds_.resize(1);
00020 }
00021 
00022 Exp_A_ConstraintCast::Exp_A_ConstraintCast(const Exp_A_ConstraintCast &from)
00023     : Exp_A_Atom(from) {
00024 }
00025 
00026 Exp_A_ConstraintCast &Exp_A_ConstraintCast::operator = (const Exp_A_ConstraintCast &right) {
00027   Exp_A_Atom::operator = (right);
00028   return *this;
00029 }
00030 
00031 Exp_A_ConstraintCast::~Exp_A_ConstraintCast(void) {
00032 }
00033 
00034 std::string Exp_A_ConstraintCast::get_class_name(void) const {
00035   return Exp_A_ConstraintCast::class_name();
00036 }
00037 
00038 std::string Exp_A_ConstraintCast::class_name(void) {
00039   return "Exp_A_ConstraintCast";
00040 }
00041 
00042 EvalType_Double Exp_A_ConstraintCast::EvaluateDouble_Impl(
00043                       const std::vector<boost::shared_ptr<ParamSpec> > &param_specs,
00044                       const Assignment &assignment) const {
00045   EvalType_Bool val = this->get_oprd()->Evaluate(param_specs, assignment);
00046   return EvalType_Double(val.value_ ? 1.0 : 0.0, val.is_valid_);
00047 }
00048 
00049 EvalType_Int Exp_A_ConstraintCast::EvaluateInt_Impl(
00050                       const std::vector<boost::shared_ptr<ParamSpec> > &param_specs,
00051                       const Assignment &assignment) const {
00052   EvalType_Bool val = this->get_oprd()->Evaluate(param_specs, assignment);
00053   return EvalType_Int(val.value_ ? 1 : 0, val.is_valid_);
00054 }
00055 
00056 void Exp_A_ConstraintCast::dump(std::ostream &os, const std::vector<boost::shared_ptr<ParamSpec> > &param_specs) const {
00057   switch (this->type_) {
00058   case EAT_INT:
00059     os << "int";
00060     break;
00061   case EAT_DOUBLE:
00062     os << "double";
00063     break;
00064   default:
00065     CT_EXCEPTION("unknown cast type");
00066     break;
00067   }
00068   this->get_oprd()->dump(os, param_specs);
00069 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines