ct_common  1.0.1
Common library for combinatorial testing
src/ct_common/common/tree_node.cpp
Go to the documentation of this file.
00001 //===----- ct_common/common/treenode.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 TreeNode
00010 //
00011 //===----------------------------------------------------------------------===//
00012 
00013 #include <stack>
00014 #include <map>
00015 #include <ct_common/common/tree_node.h>
00016 #include <ct_common/common/arithmetic_utils.h>
00017 
00018 using namespace ct::common;
00019 
00020 TreeNode::TreeNode(void)
00021     : oprds_() {
00022 }
00023 
00024 TreeNode::TreeNode(const TreeNode &from)
00025     : oprds_(from.oprds_) {
00026 }
00027 
00028 TreeNode::~TreeNode(void) {
00029   std::stack<std::pair<TreeNode*, std::size_t> > s;
00030   s.push(std::pair<TreeNode*, std::size_t>(const_cast<TreeNode*>(this), 0));
00031   while (!s.empty()) {
00032     if (s.top().first == 0) {
00033       CT_EXCEPTION("empty constraint encountered");      
00034       s.pop();
00035       ++s.top().second;
00036     }
00037     if (s.top().second >= s.top().first->oprds_.size()) {
00038       s.top().first->oprds_.clear();
00039       s.pop();
00040       if (!s.empty()) {
00041         ++s.top().second;
00042       }
00043       continue;
00044     }
00045     TreeNode *next = s.top().first->oprds_[s.top().second].get();
00046     s.push(std::pair<TreeNode*, std::size_t>(next, 0));
00047   }
00048 }
00049 
00050 TreeNode &TreeNode::operator =(const TreeNode &right) {
00051   this->oprds_ = right.oprds_;
00052   return *this;
00053 }
00054 
00055 std::string TreeNode::get_class_name(void) const {
00056   return TreeNode::class_name();
00057 }
00058 
00059 std::string TreeNode::class_name(void) {
00060   return "TreeNode";
00061 }
00062 
00063 const std::string &TreeNode::get_str_value(void) const {
00064   static std::string empty_string;
00065   return empty_string;
00066 }
00067 
00068 void TreeNode::touch_pids( const std::vector<boost::shared_ptr<ParamSpec> > &param_specs,
00069                                 std::set<std::size_t> &pids_to_touch) const {
00070   std::stack<std::pair<const TreeNode*, std::size_t> > s;
00071   s.push(std::pair<const TreeNode*, std::size_t>(this, 0));
00072   while (!s.empty()) {
00073     if (s.top().first == 0) {
00074       CT_EXCEPTION("empty constraint encountered");      
00075       s.pop();
00076       ++s.top().second;
00077     }
00078     if (s.top().second >= s.top().first->oprds_.size()) {
00079       s.top().first->inner_touch_leaf_pids(param_specs, pids_to_touch);
00080       s.pop();
00081       if (!s.empty()) {
00082         ++s.top().second;
00083       }
00084       continue;
00085     }
00086     const TreeNode *next = s.top().first->oprds_[s.top().second].get();
00087     s.push(std::pair<const TreeNode*, std::size_t>(next, 0));
00088   }                                
00089 }
00090 
00091 void TreeNode::inner_touch_leaf_pids( const std::vector<boost::shared_ptr<ParamSpec> > &param_specs,
00092                                       std::set<std::size_t> &pids_to_touch) const {
00093 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines