📄 clangaction.h
字号:
// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } virtual std::auto_ptr< Action > deepCopy() const { if( getRegion() ) return std::auto_ptr< Action >( new ActMarkLineReg( getRegion()->deepCopy() ) ); else return std::auto_ptr< Action >( new ActMarkLineReg() ); } private: std::auto_ptr< Region > m_reg; }; class ActOffsidesLine : public Action { public: ActOffsidesLine() : Action() {} ActOffsidesLine( std::auto_ptr< Region > r ) : Action(), m_reg( r ) {} virtual ~ActOffsidesLine() {} std::ostream& print( std::ostream& out ) const { out << "(oline "; if( getRegion() == NULL ) out << "(null)"; else out << *getRegion(); return out << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { out << line_header << "offsides line at: " << std::endl; if( getRegion() == NULL ) out << line_header << " (null)\n"; else getRegion()->printPretty( out, line_header + " " ); return out; } const Region* getRegion() const { return m_reg.get(); } std::auto_ptr< Region > detachRegion() { return m_reg; }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } virtual std::auto_ptr< Action > deepCopy() const { if( getRegion() ) return std::auto_ptr< Action >( new ActOffsidesLine( getRegion()->deepCopy() ) ); else return std::auto_ptr< Action >( new ActOffsidesLine() ); } private: std::auto_ptr< Region > m_reg; }; class ActHetType : public Action { public: ActHetType() : Action(), M_player_type ( 0 ) {} ActHetType( const int& player_type ) : Action(), M_player_type( player_type ) {} ~ActHetType() {} std::ostream& print( std::ostream& out ) const { return out << "(htype " << M_player_type << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { return out << line_header << "heterogenous type: " << M_player_type << std::endl; } /* class specific stuff */ int getPlayerType() const { return M_player_type; } void setPlayerType( const int& player_type ) { M_player_type = player_type; }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Action > deepCopy() const { return std::auto_ptr< Action >( new ActHetType( *this ) ); } private: int M_player_type; } ; class ActNamed : public Action { public: ActNamed( const std::string& name = "" ) : Action(), M_name( name ) {} ~ActNamed() {} std::ostream& print( std::ostream& out ) const { return out << "\"" << M_name << "\""; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { return out << line_header << "action named \"" << M_name << "\"" << std::endl; } /* class specific */ std::string& getName() { return M_name; } const std::string& getName() const { return M_name; } void setName( const std::string& name ) { M_name = name; }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Action > deepCopy() const { return std::auto_ptr< Action >( new ActNamed( *this ) ); } private: std::string M_name; } ; class ActPassReg : public Action { public: ActPassReg() : Action() {} ActPassReg( std::auto_ptr< Region > reg ) : Action(), m_reg( reg ) {} ~ActPassReg() {} std::ostream& print( std::ostream& out ) const { out << "(pass "; if( getRegion() == NULL ) out << "(null)"; else out << *getRegion(); return out << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { out << line_header << "pass to region:" << std::endl; if( getRegion() == NULL ) out << line_header << " (null)\n"; else getRegion()->printPretty( out, line_header + " " ); return out; } const Region* getRegion() const { return m_reg.get(); } std::auto_ptr< Region > detachRegion() { return m_reg; }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } virtual std::auto_ptr< Action > deepCopy() const { if( getRegion() ) return std::auto_ptr< Action >( new ActPassReg( getRegion()->deepCopy() ) ); else return std::auto_ptr< Action >( new ActPassReg() ); } private: std::auto_ptr< Region > m_reg; }; class ActPassUNum : public Action { public: ActPassUNum() : Action() {} ActPassUNum( const UNumSet& players ) : Action(), m_players( players ) {} ~ActPassUNum() {} std::ostream& print( std::ostream& out ) const { return out << "(pass " << getPlayers() << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { return out << line_header << "pass to player(s) " << getPlayers() << std::endl; } /* class specific stuff */ UNumSet getPlayers() { return m_players; } const UNumSet& getPlayers() const { return m_players; } void add( const UNum& unum ) { m_players.add( unum ); } void clearPlayers() { m_players.clear(); }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } virtual std::auto_ptr< Action > deepCopy() const { return std::auto_ptr< Action >( new ActPassUNum( *this ) ); } private: UNumSet m_players; }; class ActDribble : public Action { public: ActDribble() : Action() {} ActDribble( std::auto_ptr< Region > reg ) : Action(), m_reg( reg ) {} ~ActDribble() {} std::ostream& print( std::ostream& out ) const { out << "(dribble "; if( getRegion() == NULL ) out << "(null)"; else out << *getRegion(); return out << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { out << line_header << "dribble to region:" << std::endl; if( getRegion() == NULL ) out << line_header << " (null)\n"; else getRegion()->printPretty( out, line_header + " " ); return out; } const Region* getRegion() const { return m_reg.get(); } std::auto_ptr< Region > detachRegion() { return m_reg; }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } virtual std::auto_ptr< Action > deepCopy() const { if( getRegion() ) return std::auto_ptr< Action >( new ActDribble( getRegion()->deepCopy() ) ); else return std::auto_ptr< Action >( new ActDribble() ); } private: std::auto_ptr< Region > m_reg; }; class ActClear : public Action { public: ActClear() : Action() {} ActClear( std::auto_ptr< Region > reg ) : Action(), m_reg( reg ) {} ~ActClear() {} std::ostream& print( std::ostream& out ) const { out << "(clear "; if( getRegion() == NULL ) out << "(null)"; else out << *getRegion(); return out << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { out << line_header << "clear to region:" << std::endl; if( getRegion() == NULL ) out << line_header << " (null)\n"; else getRegion()->printPretty( out, line_header + " " ); return out; } const Region* getRegion() const { return m_reg.get(); } std::auto_ptr< Region > detachRegion() { return m_reg; }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } virtual std::auto_ptr< Action > deepCopy() const { if( getRegion() ) return std::auto_ptr< Action >( new ActClear( getRegion()->deepCopy() ) ); else return std::auto_ptr< Action >( new ActClear() ); } private: std::auto_ptr< Region > m_reg; }; class ActShoot : public Action { public: ActShoot() : Action() {} ~ActShoot() {} std::ostream& print( std::ostream& out ) const { return out << "(shoot)"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { return out << line_header << "shoot" << std::endl; }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Action > deepCopy() const { return std::auto_ptr< Action >( new ActShoot( *this ) ); } }; class ActHold : public Action { public: ActHold() : Action() {} ~ActHold() {} std::ostream& print( std::ostream& out ) const { return out << "(hold)"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { return out << line_header << "hold" << std::endl; }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Action > deepCopy() const { return std::auto_ptr< Action >( new ActHold( *this ) ); } }; class ActIntercept : public Action { public: ActIntercept() : Action() {} ~ActIntercept() {} std::ostream& print( std::ostream& out ) const { return out << "(intercept)"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { return out << line_header << "intercept" << std::endl; }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Action > deepCopy() const { return std::auto_ptr< Action >( new ActIntercept( *this ) ); } }; class ActTackle : public Action { public: ActTackle() : Action() {} ActTackle( const UNumSet& players ) : Action(), M_players( players ) {} ~ActTackle() {} std::ostream& print( std::ostream& out ) const { return out << "(tackle " << M_players << ")"; } std::ostream& printPretty( std::ostream& out, const std::string& line_header ) const { return out << line_header << "tackle player(s) " << M_players << std::endl; } /* class specific stuff */ UNumSet& getPlayers() { return M_players; } const UNumSet& getPlayers() const { return M_players; } void setPlayers( const UNumSet& players ) { M_players = players; } void addPlayer( const UNum& i ) { M_players.add( i ); } void clearPlayers() { M_players.clear(); }// virtual// void// accept( Visitor& v )// { v.startVisit( this ); }// virtual// void// accept( ConstVisitor& v ) const// { v.startVisit( this ); } std::auto_ptr< Action > deepCopy() const { return std::auto_ptr< Action >( new ActTackle( *this ) ); } private: UNumSet M_players; }; std::ostream& operator<<( std::ostream & os, const Action& a ); }}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -