ct_common  1.0.1
Common library for combinatorial testing
src/ct_common/common/paramspec.h
Go to the documentation of this file.
00001 //===----- ct_common/common/paramspec.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 parameter specifications
00010 //
00011 //===----------------------------------------------------------------------===//
00012 
00013 #ifndef CT_COMMON_PARAMSPEC_H_
00014 #define CT_COMMON_PARAMSPEC_H_
00015 
00016 #include <vector>
00017 #include <string>
00018 #include <set>
00019 #include <map>
00020 #include <ct_common/common/utils.h>
00021 #include <ct_common/common/tree_node.h>
00022 #include <boost/shared_ptr.hpp>
00023 
00024 namespace ct {
00025 namespace common {
00029 class DLL_EXPORT ParamSpec
00030 {
00031 public:
00032   ParamSpec(void);  
00033   ParamSpec(const ParamSpec &from);
00034   ParamSpec &operator = (const ParamSpec &right);
00035   virtual ~ParamSpec(void) = 0;
00036 
00038   void set_param_name(const std::string &param_name) { this->param_name_ = param_name; }
00040   const std::string &get_param_name(void) const { return this->param_name_; }
00041 
00047   virtual void set_values(const std::vector<std::string> &string_values);
00048 
00052   const std::vector<std::string> &get_string_values(void) const { return this->string_values_; }
00056   std::size_t get_level(void) const { return this->get_num_values(); }
00060   const std::map<std::string, std::size_t> &get_map_string_values_2_vid(void) const { return this->map_string_values_2_vid_; }
00065   std::size_t query_value_id(const std::string &str) const;
00066 
00068   virtual std::string get_class_name(void) const;
00070   static std::string class_name(void);
00071 
00073   std::vector<std::pair<boost::shared_ptr<TreeNode>, boost::shared_ptr<TreeNode> > > &auto_value_specs(void) { return this->auto_value_specs_; }
00075   const std::vector<std::pair<boost::shared_ptr<TreeNode>, boost::shared_ptr<TreeNode> > > &get_auto_value_specs(void) const { return this->auto_value_specs_; }
00076 
00078   void touch_pids(const std::vector<boost::shared_ptr<ParamSpec> > &param_specs,
00079                   std::set<std::size_t> &pids_to_touch) const;
00080 
00082   void set_aux(bool flag) { this->is_aux_ = flag; }
00084   bool is_aux(void) const { return this->is_aux_; }
00086   void set_auto(bool flag) { this->is_auto_ = flag; }
00088   bool is_auto(void) const { return this->is_auto_; }
00089 
00091   std::size_t get_invalid_vid(void) const { return this->get_num_values(); }
00093   std::size_t get_width(void) const;
00095   std::size_t get_num_values(void) const { return this->map_string_values_2_vid_.size(); }
00097   bool is_vid_invalid(std::size_t vid) const {   return (vid >= this->get_num_values()); }
00098 
00099 private:
00101   void init(const ParamSpec &from);
00102 private:
00103   std::string param_name_;  
00104   std::vector<std::string> string_values_;  
00105   std::map<std::string, std::size_t> map_string_values_2_vid_;  
00106   std::vector<std::pair<boost::shared_ptr<TreeNode>, boost::shared_ptr<TreeNode> > > auto_value_specs_;  
00110   bool is_aux_;  
00111   bool is_auto_;  
00112 };
00113 
00117 std::size_t find_param_id(const std::vector<boost::shared_ptr<ParamSpec> > &param_specs,
00118                   const std::string &param_name);
00119 }  // namespace common
00120 }  // namespace ct
00121 
00122 #endif  // CT_COMMON_PARAMSPEC_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines