neo::core::Activator Class Reference

#include <core/activator.h>

Inheritance diagram for neo::core::Activator:

Inheritance graph
[legend]
Collaboration diagram for neo::core::Activator:

Collaboration graph
[legend]
List of all members.

Detailed Description

Base class for methods to manage active/inactive state of an object. Provides methods to set explicit state and to toggle state. Default state is active. Dervied classes should consider inheriting this class virtually to make sure there is a single base Activator in the class. The onActiveStateChange method provides a notification method for derived classes to act when the state is changed. The Activator is also scriptable by binding a script event action to the notification method.

Example usage:

 Activator obj;       //Object is now active
 obj.toggle();        //Object is now inactive, calls notification method
 obj.activate();      //Object is now active, calls notification method
 obj.activate();      //Object was already active, does NOT call notification method
 if( obj.isActive() ) //Returns true
   obj.deactivate();  //Object is now inactive, calls notification method

Scripting event names (each method is called with the current Activator object as first argument):

Author:
Mattias Jansson (mattias@realityrift.com)


Public Member Functions

 Activator (bool active=true)
 Initialize state.
 Activator (const Activator &ref)
 Initialize state.
void activate ()
 Activate object.
void deactivate ()
 Deactivate object.
bool toggle ()
 Toggle state.
bool isActive () const
 Query state.
Activatoroperator= (const Activator &rhs)
 Assign state.

Protected Member Functions

virtual void onActiveStateChange ()
 State change notification.
virtual void getEvents (core::Array< std::string > *p_events)
 Enumerate events.


Constructor & Destructor Documentation

neo::core::Activator::Activator ( bool  active = true  ) 

Set the initial state of the object, defaulting to activated. The notification method is not called

See also:
onActiveStateChanged
Parameters:
active Initial state, default true (active)

neo::core::Activator::Activator ( const Activator ref  ) 

Set the initial state of the object to match given reference object. The notification method is not called

See also:
onActiveStateChanged
Parameters:
ref Reference object to get initial state from


Member Function Documentation

void neo::core::Activator::activate (  ) 

Activate the object by setting the active flag to true and calling the state change notification method if the object was previously deactivated

See also:
onActiveStateChange

void neo::core::Activator::deactivate (  ) 

Deactivate the object by setting the active flag to false and calling the state change notification method if the object was previously activated

See also:
onActiveStateChange

bool neo::core::Activator::toggle (  )  [inline]

Toggles the activated/deactivated state by toggling the active flag and calling the state change notification method

See also:
onActiveStateChange
Returns:
New state

bool neo::core::Activator::isActive (  )  const [inline]

Query the active state of the object

Returns:
Active state of object

Activator& neo::core::Activator::operator= ( const Activator rhs  ) 

Assign state from given reference object, calling the state change notification method if the state was changed

See also:
onActiveStateChange
Parameters:
rhs Reference object
Returns:
Self-reference

virtual void neo::core::Activator::onActiveStateChange (  )  [protected, virtual]

Notification method called when the object has changed it's activated/deactivated state. This method is not called during the constructor or if the method itself causes the state to change. This method triggers the scripting event "onActiveStateChange".

virtual void neo::core::Activator::getEvents ( core::Array< std::string > *  p_events  )  [protected, virtual]

Enumerate events for this object type

Parameters:
p_events Event names receiver

Implements neo::script::Scriptable.

Reimplemented in neo::gui::Area, neo::gui::Button, neo::gui::EditBox, neo::gui::Object, neo::gui::Slider, neo::gui::TextArea, and neo::scene::Object.


The documentation for this class was generated from the following file:
Generated on Sat Feb 17 20:51:01 2007 for NeoEngine 2 - Evolution by  doxygen 1.5.1