nomlib
Loading...
Searching...
No Matches
IState.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_SYSTEM_ISTATE_HPP
30#define NOMLIB_SYSTEM_ISTATE_HPP
31
32#include "nomlib/config.hpp"
33
34namespace nom {
35
36// Forward declarations
37class RenderWindow;
38struct Event;
39
43class IState
44{
45 public:
46 typedef std::unique_ptr<IState> unique_ptr;
47
51 enum Flags
52 {
56
60 };
61
65 enum Type
66 {
68 Parent = 0,
69 Child
70 };
71
73 IState( void );
74
76 virtual ~IState( void );
77
82 IState( uint32 id );
83
91 IState( uint32 id, uint32 flags, IState::Type type );
92
98 uint32 id ( void ) const;
99
105 uint32 timestamp ( void ) const;
106
112 uint32 flags ( void ) const;
113
117 IState::Type type( void ) const;
118
129 virtual bool on_event(const nom::Event& ev);
130
136 virtual void on_update ( float );
137
146 virtual void on_draw ( RenderWindow& );
147
153 virtual void on_init ( void_ptr );
154
160 virtual void on_exit ( void_ptr );
161
167 virtual void on_pause ( void_ptr );
168
175 virtual void on_resume ( void_ptr );
176
177 private:
179 uint32 id_;
180
183
185 uint32 flags_;
186
189};
190
191} // namespace nom
192
193#endif // include guard defined
Type
State type enumeration.
Definition IState.hpp:66
@ Parent
Top-level / top-most placement on the stack.
Definition IState.hpp:68
Type type_
The type of state.
Definition IState.hpp:188
virtual void on_init(void_ptr)
User-defined implementation of the state's initialization logic.
uint32 id(void) const
Obtain the user-defined identifier of the state.
uint32 id_
Unique identifier for the state.
Definition IState.hpp:179
virtual void on_draw(RenderWindow &)
uint32 timestamp(void) const
Obtain the recorded time stamp of the state.
virtual void on_resume(void_ptr)
User-defined implementation of the state's resume from pause state logic.
virtual bool on_event(const nom::Event &ev)
User-defined implementation of the state's event handling logic.
uint32 timestamp_
Number of ticks recorded at the time of state's construction.
Definition IState.hpp:182
uint32 flags_
Specialized state management.
Definition IState.hpp:185
IState(void)
Default constructor; initializes class variables to zero.
virtual void on_pause(void_ptr)
User-defined implementation of the state's paused state logic.
IState(uint32 id)
Constructor for user-defined initialization of the class variable fields.
Flags
Specialized control over state management.
Definition IState.hpp:52
uint32 flags(void) const
Obtain the user-defined flags of the state.
IState(uint32 id, uint32 flags, IState::Type type)
Constructor for user-defined initialization of the class variable fields.
IState::Type type(void) const
Get the type of state.
virtual void on_exit(void_ptr)
User-defined implementation of the state's destruction logic.
virtual ~IState(void)
Destructor; declared virtual for inheritance.
virtual void on_update(float)
User-defined implementation of the state's update logic.
Event handling types.
Definition Event.hpp:457