📄 coach_lang_comp.h
字号:
std::auto_ptr< Cond > m_cond; Storage m_dirs; }; /******** Defs ********************/ class DefCond; class DefDir; class DefReg; class DefAct; class DefRule; class Def { public:// typedef util::Visitor10< DefCond*,// DefDir*,// DefReg*,// DefAct*,// DefRule* > Visitor;// typedef util::Visitor10< const DefCond*,// const DefDir*,// const DefReg*,// const DefAct*,// const DefRule* > ConstVisitor;// class TypeExtractor// : public util::TypeExtractor10< DefCond*,// DefDir*,// DefReg*,// DefAct*,// DefRule* >// {// protected:// void// visit( DefCond* def )// { setValue( def ); }// void// visit( DefDir* def )// { setValue( def ); }// void// visit( DefReg* def )// { setValue( def ); }// void// visit( DefAct* def )// { setValue( def ); }// void// visit( DefRule* def )// { setValue( def ); }// };// class ConstTypeExtractor// : public util::TypeExtractor10< const DefCond*,// const DefDir*,// const DefReg*,// const DefAct*,// const DefRule* >// {// protected:// void// visit( const DefCond* def )// { setValue( def ); }// void// visit( const DefDir* def )// { setValue( def ); }// void// visit( const DefReg* def )// { setValue( def ); }// void// visit( const DefAct* def )// { setValue( def ); }// void// visit( const DefRule* def )// { setValue( def ); }// }; Def() {} Def( const std::string& name ) : M_name( name ) {} virtual ~Def() {} virtual std::ostream& print( std::ostream& out ) const = 0; virtual std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const = 0; const std::string& getName() const { return M_name; } void setName( const std::string& name ) { M_name = name; } // virtual// void// accept( Visitor& v ) = 0; // virtual// void// accept( ConstVisitor& v ) const = 0; virtual std::auto_ptr< Def > deepCopy() const = 0; protected: std::string M_name; }; inline std::ostream& operator <<( std::ostream & os, const Def& t ) { return t.print(os); } class DefCond : public Def { public: DefCond() : Def(), M_cond( (Cond*)NULL ) {} DefCond( const std::string& name, std::auto_ptr< Cond > cond ) : Def( name ), M_cond( cond ) {} DefCond( const DefCond& def ) : Def( def ), M_cond( def.M_cond->deepCopy() ) {} ~DefCond() {} DefCond& operator=( const DefCond& def ) { setName( def.getName() ); std::auto_ptr< Cond > cond( def.M_cond->deepCopy() ); M_cond = cond; return *this; } std::ostream& print( std::ostream& out ) const { out << "(definec \"" << M_name << "\" "; if( M_cond.get() == NULL ) out << " (null)"; else out << *M_cond; return out << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { out << line_header << "Cond \"" << M_name << "\"" << std::endl; if( M_cond.get() == NULL ) out << line_header << " (null)\n"; else M_cond->printPretty( out, line_header + " " ); return out; } Cond* getCond() { return M_cond.get(); } const Cond* getCond() const { return M_cond.get(); } void setCond( std::auto_ptr< Cond >& cond ) { M_cond = cond; } std::auto_ptr< Cond > detachCond() { return M_cond; } // void// accept( Visitor& v )// { v.startVisit( this ); }// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Def > deepCopy() const { return std::auto_ptr< Def >( new DefCond( *this ) ); } private: std::auto_ptr< Cond > M_cond; }; class DefDir : public Def { public: DefDir() : Def(), M_dir( (Dir*)NULL ) {} DefDir( const std::string& name, std::auto_ptr< Dir > dir ) : Def( name ), M_dir( dir ) {} DefDir( const DefDir& def ) : Def( def ), M_dir( def.M_dir->deepCopy() ) {} ~DefDir() {} DefDir& operator=( const DefDir& def ) { setName( def.getName() ); std::auto_ptr< Dir > dir( def.M_dir->deepCopy() ); M_dir = dir; return *this; } std::ostream& print( std::ostream& out ) const { out << "(defined \"" << M_name << "\" "; if( M_dir.get() == NULL ) out << "(null)"; else out << *M_dir; return out << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { out << line_header << "Dir \"" << M_name << "\"" << std::endl; if( M_dir.get() == NULL ) out << line_header << " (null)\n"; else M_dir->printPretty( out, line_header + " " ); return out; } Dir* getDir() { return M_dir.get(); } const Dir* getDir() const { return M_dir.get(); } void setDir( std::auto_ptr< Dir >& dir ) { M_dir = dir; } std::auto_ptr< Dir > detachDir() { return M_dir; }// void// accept( Visitor& v )// { v.startVisit( this ); }// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Def > deepCopy() const { return std::auto_ptr< Def >( new DefDir( *this ) ); } private: std::auto_ptr< Dir > M_dir; }; class DefReg : public Def { public: DefReg() : Def(), M_reg( (Region*)NULL ) {} DefReg( const std::string& name, std::auto_ptr< Region > reg ) : Def( name ), M_reg( reg ) {} DefReg( const DefReg& def ) : Def( def ), M_reg( def.M_reg->deepCopy() ) {} ~DefReg() {} DefReg& operator=( const DefReg& def ) { setName( def.getName() ); std::auto_ptr< Region > reg( def.M_reg->deepCopy() ); M_reg = reg; return *this; } std::ostream& print( std::ostream& out ) const { out << "(definer \"" << M_name << "\" "; if( M_reg.get() == NULL ) out << "(null)"; else out << *M_reg; return out << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { out << line_header << "Region \"" << M_name << "\"" << std::endl; if( M_reg.get() == NULL ) out << line_header << " (null)\n"; else M_reg->printPretty( out, line_header + " " ); return out; } Region* getReg() { return M_reg.get(); } const Region* getReg() const { return M_reg.get(); } void setReg( std::auto_ptr< Region >& reg ) { M_reg = reg; } std::auto_ptr< Region > detachReg() { return M_reg; }// void// accept( Visitor& v )// { v.startVisit( this ); }// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Def > deepCopy() const { return std::auto_ptr< Def >( new DefReg( *this ) ); } private: std::auto_ptr< Region > M_reg; }; class DefAct : public Def { public: DefAct() : Def(), M_act( (Action*)NULL ) {} DefAct( const std::string& name, std::auto_ptr< Action > act ) : Def( name ), M_act( act ) {} DefAct( const DefAct& def ) : Def( def ), M_act( def.M_act->deepCopy() ) {} ~DefAct() {} DefAct& operator=( const DefAct& def ) { setName( def.getName() ); std::auto_ptr< Action > act( def.M_act->deepCopy() ); M_act = act; return *this; } std::ostream& print( std::ostream& out ) const { out << "(definea \"" << M_name << "\" "; if( M_act.get() == NULL ) out << "(null)"; else out << *M_act; return out << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { out << line_header << "Action \"" << M_name << "\"" << std::endl; if( M_act.get() == NULL ) out << line_header << " (null)\n"; else M_act->printPretty( out, line_header + " "); return out; } Action* getAction() { return M_act.get(); } const Action* getAction() const { return M_act.get(); } void setAction( std::auto_ptr< Action >& act ) { M_act = act; } std::auto_ptr< Action > detachAction() { return M_act; } // void// accept( Visitor& v )// { v.startVisit( this ); }// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Def > deepCopy() const { return std::auto_ptr< Def >( new DefAct( *this ) ); } private: std::auto_ptr< Action > M_act; }; }}#include "rule.h"namespace rcss{ namespace clang { class DefRule : public Def { public: DefRule() : Def(), M_model( false ) {} DefRule( const std::string& name, std::auto_ptr< Rule > rule, bool model ) : Def( name ), m_rule( rule ), M_model( model ) {} virtual ~DefRule() {} std::ostream& print( std::ostream& out ) const; std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const; const Rule* getRule() const { return m_rule.get(); } std::auto_ptr< Rule > detachRule() { return m_rule; } bool isModel() const { return M_model; } void setModel( bool model ) { M_model = model; }// void// accept( Visitor& v )// { v.startVisit( this ); }// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Def > deepCopy() const { if( getRule() ) return std::auto_ptr< Def >( new DefRule( getName(), getRule()->deepCopy(), M_model ) ); else return std::auto_ptr< Def >( new DefRule( getName(), std::auto_ptr< Rule >(), M_model ) ); } private: std::auto_ptr< Rule > m_rule; bool M_model; }; }}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -