/**** , [ bobocheTree.cc ], Copyright (c) 2008 Universite d'Orleans - Jeremie Vautard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *************************************************************************/ #include "Strategy.hh" StrategyImp::StrategyImp() { cout<<"Default constructor of StrategyImp should not be called !"<todosUpdate(i); } StrategyImp::StrategyImp(StrategyNode tag) { // cout<<"Strategy imp constructor"<::iterator i = nodes.begin();i != nodes.end();i++) { if (((*i).imp->father) == this) { (*i).imp->father = NULL; } } } Strategy::Strategy() { // cout<<"strategy default"<imp = imp; this->imp->pointers++; } Strategy::Strategy(bool qt,int VMin, int VMax, int scope, vector values) { // cout<<"strategy with values"<pointers)++; } Strategy& Strategy::operator = (const Strategy& rvalue) { // cout<<"Strategy = "<pointers)--; if ( (imp->pointers) == 0) { // cout<<"no more references for the imp. Delete"<pointers)++; return *this; } Strategy::~Strategy() { // cout<<"strategy destructor"<pointers)--; if ( (imp->pointers) == 0) { // cout<<"no more references for the imp. Delete"<zetag; } Strategy Strategy::getFather() { if (hasFather()) return Strategy(imp->father); return Dummy(); } bool Strategy::hasFather() { if (imp->father != NULL) { for (int i=0;i< imp->father->nodes.size();i++) { if ((imp->father->nodes[i].imp) == imp) return true; } } return false; } Strategy Strategy::getChild(int i) { if (i<0 || i>=degree() ) {cout<<"Child "<nodes[i]; } Strategy Strategy::getSubStrategy(vector position) { if (position.empty()) return *this; int deg = degree(); if (deg == 0) { cout<<"Did not find substrategy"<attach(child.getChild(i)); } } else { imp->nodes.push_back(child); todosUpdate(child.imp->todos); (child.imp)->father = this->imp; } } void Strategy::detach(Strategy son) { vector::iterator it = imp->nodes.begin(); while (it != (imp->nodes.end()) && ( (*it).id() != son.id())) { it++;} if ( it != imp->nodes.end()) { todosUpdate(0-((*it).imp->todos)); (*it).imp->father=NULL; imp->nodes.erase(it); } } void Strategy::detach(unsigned int i) { if (imp->nodes.size() < i) return; vector::iterator it = imp->nodes.begin()+i; todosUpdate(0-((*it).imp->todos)); (*it).imp->father=NULL; imp->nodes.erase(it); } Strategy Strategy::STrue() { Strategy ret(StrategyNode::STrue()); return ret; } Strategy Strategy::SFalse() { Strategy ret(StrategyNode::SFalse()); return ret; } Strategy Strategy::Dummy() { Strategy ret(StrategyNode::Dummy()); return ret; } Strategy Strategy::Stodo() { Strategy ret(StrategyNode::Todo()); ret.imp->todos=1; return ret; } vector Strategy::getPosition() { vector ret; Strategy asc = *this; while (!asc.isDummy()) { // cout<<"GetPosition adding "< ret2; ret2.reserve(ret.size() + asc.values().size() +1); for (int i=0;idegree());i++) { if ( (((imp->nodes[i]).imp)->father) != imp) { ret++; cout<< (((imp->nodes[i]).imp)->father) << " should be " << imp <