ct_common
1.0.1
Common library for combinatorial testing
|
00001 //===----- ct_common/file_parse/assembler.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 class for assembling elements of the SUT model 00010 // 00011 //===----------------------------------------------------------------------===// 00012 00013 #ifndef ASSEMBLER_H_ 00014 #define ASSEMBLER_H_ 00015 00016 #include <string> 00017 #include <vector> 00018 #include <cstdlib> 00019 #include <ct_common/common/paramspecs.h> 00020 #include <ct_common/common/constraints.h> 00021 #include <ct_common/common/pvpair.h> 00022 #include <ct_common/common/seed.h> 00023 #include <ct_common/common/exps.h> 00024 #include <ct_common/common/strength.h> 00025 #include <ct_common/file_parse/err_logger.h> 00026 00027 namespace ct { 00028 namespace common { 00032 enum eOPERATOR { 00033 OP_ADD, 00034 OP_SUB, 00035 OP_MULT, 00036 OP_DIV, 00037 OP_MOD, 00038 OP_NEG, 00039 OP_UPLUS, 00040 OP_EQ, 00041 OP_NE, 00042 OP_GT, 00043 OP_GE, 00044 OP_LT, 00045 OP_LE, 00046 OP_AND, 00047 OP_OR, 00048 OP_XOR, 00049 OP_IMPLY, 00050 OP_IFF, 00051 OP_NOT, 00052 }; 00053 00057 class Assembler { 00058 public: 00059 Assembler(void); 00060 Assembler(const Assembler &from); 00061 ~Assembler(void); 00062 const Assembler &operator = (const Assembler &right); 00063 00065 void setErrLogger(const boost::shared_ptr<ErrLogger> &err_logger) { this->err_logger_ = err_logger; } 00067 const boost::shared_ptr<ErrLogger> &get_err_logger(void) { return this->err_logger_; } 00068 00070 void reportError(const std::string &str); 00072 void reportWarning(const std::string &str); 00074 std::size_t numErrs(void) const; 00076 std::size_t numWarnings(void) const; 00077 00078 public: 00080 ParamSpec *asm_paramspec( 00081 const std::string &type, 00082 const std::string &identifier, 00083 const std::vector<boost::shared_ptr<TreeNode> > &vals); 00084 00086 ParamSpec *asm_paramspec( 00087 const std::string &type, 00088 const std::string &identifier, 00089 const std::vector<std::pair<boost::shared_ptr<TreeNode>, boost::shared_ptr<TreeNode> > > &auto_value_specs); 00090 00092 void attach_strengths( 00093 const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, 00094 const std::vector<std::string> &identifiers, 00095 std::vector<Strength> &strengths, 00096 std::size_t strength); 00097 00099 void attach_default_strengths( 00100 const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, 00101 std::vector<Strength> &strengths, 00102 std::size_t strength); 00103 00105 PVPair *asm_pvpair( 00106 const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, 00107 const std::string &identifier, 00108 const TreeNode *value_exp); 00109 00111 Constraint_S *asm_constraint_s(Exp_S *oprd1, Exp_S *oprd2, eOPERATOR op); 00113 Constraint_A *asm_constraint_a(Exp_A *oprd1, Exp_A *oprd2, eOPERATOR op, double precision); 00115 Constraint *asm_constraint_asb(TreeNode *oprd1, TreeNode *oprd2, eOPERATOR op, const std::string &str); 00117 Constraint_L *asm_constraint_l(TreeNode *oprd1, TreeNode *oprd2, eOPERATOR op); 00119 Constraint_L *asm_constraint_l(TreeNode *oprd, eOPERATOR op); 00121 Constraint_L_CBool *asm_constraint_l_cbool(const std::string &val); 00123 Constraint *asm_constraint_invalid(const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, const std::string &identifier); 00125 TreeNode *asm_param(const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, const std::string &identifier); 00126 00128 Exp_A *asm_exp_a(TreeNode *oprd1, TreeNode *oprd2, eOPERATOR op); 00130 Exp_A *asm_exp_a(TreeNode *oprd, eOPERATOR op); 00132 Exp_A *asm_exp_a_cast(TreeNode *oprd, const std::string &type); 00133 00135 void store_invalidation( 00136 const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs, 00137 const std::vector<std::string> &identifiers, 00138 const boost::shared_ptr<TreeNode> &precond); 00140 std::vector<boost::shared_ptr<Constraint> > dump_invalidations(const std::vector<boost::shared_ptr<ParamSpec> > ¶m_specs); 00141 00143 ct::common::Seed *asm_seed(std::size_t id, const ct::common::Tuple &tuple); 00145 ct::common::Seed *asm_seed(std::size_t id, ct::common::Constraint *constr); 00146 00148 void set_option(const std::string &identifier, const ct::common::TreeNode *value); 00149 00150 private: 00152 Constraint *conjunction(const std::vector<boost::shared_ptr<TreeNode> > &constrs); 00153 00154 private: 00155 boost::shared_ptr<ErrLogger> err_logger_; 00156 std::map<std::size_t, std::vector<boost::shared_ptr<TreeNode> > > stored_invalidations_; 00157 double default_precision_; 00158 }; 00159 } // namepsace common 00160 } // namespace ct 00161 00162 #endif // ASSEMBLER_H_