00001 #include <typeinfo> 00002 #include "sequentialbehavior.h" 00003 using namespace std; 00004 00005 Ast& SequentialBehavior::operator = (const Ast& ast) { 00006 const SequentialBehavior& sequentialBehavior = dynamic_cast<const SequentialBehavior&>(ast); 00007 00008 Behavior::operator=(ast); 00009 this->behavior = sequentialBehavior.behavior ? dynamic_cast<Behavior*>(&(sequentialBehavior.behavior->clone())) : 0; 00010 this->simpleBehavior = sequentialBehavior.simpleBehavior ? dynamic_cast<SimpleBehavior*>(&(sequentialBehavior.simpleBehavior->clone())) : 0; 00011 00012 return *(this); 00013 } 00014 00015 bool SequentialBehavior::operator == (const Ast& ast) const { 00016 bool result = false; 00017 const SequentialBehavior& sequentialBehavior = dynamic_cast<const SequentialBehavior&>(ast); 00018 00019 if (typeid(ast) != typeid(SequentialBehavior)) 00020 return false; 00021 00022 if (this->behavior && this->simpleBehavior) 00023 result = (*(this->behavior) == *(sequentialBehavior.behavior) && 00024 *(this->simpleBehavior) == *(sequentialBehavior.simpleBehavior)); 00025 00026 return result && Behavior::operator==(ast); 00027 } 00028