SDLPP: Visitor pattern
This commit is contained in:
parent
ee82430f82
commit
87970bfc4b
@ -237,4 +237,7 @@ void RenderObject::setAnimationSpeed( const double fps ) {
|
|||||||
animation_fps = fps;
|
animation_fps = fps;
|
||||||
animation_next_frame = animation_next_frame_base = 1000 / fps;
|
animation_next_frame = animation_next_frame_base = 1000 / fps;
|
||||||
}
|
}
|
||||||
|
void RenderObject::visit( Visitor &visitor ) {
|
||||||
|
visitor.visit( *this );
|
||||||
|
}
|
||||||
} // namespace SDLPP
|
} // namespace SDLPP
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "sdlpp_renderer.hpp"
|
#include "sdlpp_renderer.hpp"
|
||||||
#include "sdlpp_texture.hpp"
|
#include "sdlpp_texture.hpp"
|
||||||
#include "sdlpp_vector.hpp"
|
#include "sdlpp_vector.hpp"
|
||||||
|
#include "sdlpp_visitor.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -101,6 +102,7 @@ public:
|
|||||||
void resumeAnimation();
|
void resumeAnimation();
|
||||||
void removeAnimation();
|
void removeAnimation();
|
||||||
void animate( int ticks );
|
void animate( int ticks );
|
||||||
|
void visit( Visitor &visitor );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void copyTo( std::shared_ptr< RenderObject > other );
|
virtual void copyTo( std::shared_ptr< RenderObject > other );
|
||||||
|
18
sdlpp/sdlpp_visitor.hpp
Normal file
18
sdlpp/sdlpp_visitor.hpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef SDLPP_HPP_VISITOR
|
||||||
|
#define SDLPP_HPP_VISITOR
|
||||||
|
|
||||||
|
#include "sdlpp_common.hpp"
|
||||||
|
|
||||||
|
namespace SDLPP {
|
||||||
|
|
||||||
|
class SDLPPSCOPE RenderObject;
|
||||||
|
|
||||||
|
class SDLPPSCOPE Visitor {
|
||||||
|
public:
|
||||||
|
Visitor() {}
|
||||||
|
virtual void visit( const RenderObject &obj );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SDLPP
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user