guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
Public Types | Public Member Functions | List of all members
guit::GSuperState Class Reference

Hierarchical State. More...

Inheritance diagram for guit::GSuperState:
guit::GState guit::GBool guit::GVarProp_< bool > guit::GVarProp guit::GProp guit::GObject guit::GStateChart

Public Types

using Specif = int32_t
 Specificity of Properties.
 

Public Member Functions

void setInitial (GState &)
 Sets the initial state.
 
GStatecurrentState () const
 Returns the current state (null if none).
 
GStateaddState (GString const &name="")
 Creates and adds a substate to this hierarchical state (or state machine). More...
 
void removeStates ()
 Removes all states.
 
GStateclone (bool) const override
 a GState can't be cloned.
 
auto operator~ ()
 Reference that can be added to an Active Expression (see GExpr). More...
 
GString const name () const
 Returns the name of the state (or "" if no name was specified).
 
GSuperStateparent () const
 Returns the parent State. More...
 
GStateTransitionoperator>> (GState &state2)
 Adds a transition from this state to state2. More...
 
bool isEquivalent (const GProp &) const override
 Returns true if these props are equivalent. More...
 
bool boolValue () const override
 Returns the value as a bool. More...
 
void set (GProp const &) override
 Changes value. More...
 
virtual void set (boolconst &value, bool callalways)
 Changes the value. More...
 
void set (GString const &str) override
 Changes the value from a string.
 
GBooloperator<<= (GBoolExpr &)
 Binds this model to an Active Expression (see GExpr). More...
 
GVarProptoVarProp () override
 Type conversions.
 
bool isMutable () const override
 Returns true if the prop is mutable. More...
 
void setImmutable () override
 Makes the prop immutable. More...
 
virtual void blend (GProp const &value1, GProp const &value2, float mix)
 Changes value by blending the value of two props. More...
 
void blink (GString const &msg="", GTime duration=500)
 Blinks gadget parents of the prop. More...
 
void update ()
 updates gadget parents of the prop.
 
void perform (std::function< void(Gadget &)> fun)
 performs this function on gadget parents.
 
GPropList const & props () const
 Returns callbacks and bound props.
 
virtual void removeNotifiers (void *object) override
 [Implementation] Notifies this object that it must no longer refer obj.
 
virtual void removeAll ()
 Removes callbacks and notifiers.
 
virtual bool onAdd (Gadget *)
 Called when the property is added to an object. More...
 
virtual void onRemove (Gadget *)
 Called when the property is removed from an object. More...
 
virtual void error (GString const &funname, GString const &message) const
 Prints an error message. More...
 
void operator delete (void *)
 delete does nothing, see GObject class.
 
void forgetSmartPointers ()
 Forgets all smart pointers pointing this object. More...
 
unsigned int useCount () const
 Returns the numbers of smart pointers referencing the object.
 
 GSuperState (GSuperState &parent, GString const &name="")
 Creates a hierarchical state (see GState).
 
GSuperStateoperator<< (GState &substate)
 Adds a substate to this hierarchical state (or state machine). More...
 
bool entered () const
 Returns the state value, i.e. More...
 
float floatValue () const override
 Returns the value of the prop as a float. More...
 
GString stringValue () const override
 Returns the value of the prop as a string. More...
 
GBoolExproperator+ ()
 Returns a trigger testing the state value that can be used in a Conditional Expression. More...
 
boolconst & value () const
 Returns the value.
 
bool read (GString const &filename)
 Reads the value of the prop from a file or a stream.
 
void unbind (GVarProp &sender)
 Unbinds this prop. More...
 
GString typeName () const override
 Returns the name and role of the prop's type.
 
GProptoProp () override
 Class conversions.
 
bool write (GString const &filename) const
 Writes the value of the prop on a file or a stream.
 
template<class Subclass >
Subclass * to ()
 Class conversions.
 
void ignoreSmartPointers ()
 Checks/sets whether this object can be auto-deleted by smart pointers. More...
 

Detailed Description

Hierarchical State.

Member Function Documentation

GSuperState & guit::GSuperState::operator<< ( GState substate)

Adds a substate to this hierarchical state (or state machine).

Returns the superstate

GState & guit::GSuperState::addState ( GString const &  name = "")

Creates and adds a substate to this hierarchical state (or state machine).

Returns the newly created state

auto guit::GState::operator~ ( )
inlineinherited

Reference that can be added to an Active Expression (see GExpr).

This reference will hold the future value, which can be (state entered) or false (state exited)

Note
operator+() and operator-() can also be used as shortcuts:
auto& state = State(parent);
mygadget
<< +state / "yes" / GColor::green // when the state is entered
<< -state / "no" / GColor::red; // when the state is exited
The color of the gadget will be green when the state is entered and red when it is exited
bool guit::GState::entered ( ) const
inherited

Returns the state value, i.e.

true if the state is entered and false if it is exited.

float guit::GState::floatValue ( ) const
inlineoverridevirtualinherited

Returns the value of the prop as a float.

Returns 0.f if the prop has no value of its value cannot be converted to a float.

Reimplemented from guit::GBool.

GString guit::GState::stringValue ( ) const
overridevirtualinherited

Returns the value of the prop as a string.

Returns "" if the prop has no value of its value cannot be converted to a string.

Reimplemented from guit::GProp.

GSuperState* guit::GState::parent ( ) const
inlineinherited

Returns the parent State.

The parent state is either the StateChart or a hierarchical State (GSuperState).

GStateTransition & guit::GState::operator>> ( GState state2)
inherited

Adds a transition from this state to state2.

Allows creating a transition (state1 >> state2) in an expression such as:

mygadget << (state1 >> state2);
mygadget << (state1 >> state2) / [this]{doAction();}
mygadget << trigger / (state1 >> state2) / [this]{doAction();}
bool guit::GState::isEquivalent ( const GProp other) const
inlineoverridevirtualinherited

Returns true if these props are equivalent.

Adding a prop to a gadget replaces the equivalent prop it contains (if it contains any). In all other cases, the prop is added to the gadget proplist. NOTE: props with a negative role are never equivalent!

Reimplemented from guit::GProp.

bool guit::GBool::boolValue ( ) const
inlineoverridevirtualinherited

Returns the value as a bool.

Returns false if the prop has no value of its value cannot be converted to a bool.

Reimplemented from guit::GProp.

void guit::GBool::set ( GProp const &  value)
overridevirtualinherited

Changes value.

Does nothing if the type of from is not convertible to the type of this prop.

See Also
set() and operator=() methods in subclasses

Implements guit::GVarProp.

virtual void guit::GVarProp_< bool >::set ( bool const &  value,
bool  callalways 
)
inlinevirtualinherited

Changes the value.

Callbacks are fired and parent gadgets updated if:

  • the value is different from the value that was previously set (using set() or operator=)
  • callalways is true, in which case they are always fired Does nothing and produces an warning if the prop is immutable (see setImmutable())
GBoolExpr & guit::GBool::operator+ ( )
inherited

Returns a trigger testing the state value that can be used in a Conditional Expression.

  • +state: equivalent to (~state == true) : fires callbacks and activates conditional props when the state is entered; deactivates conditional props when the state is exited;
  • -state: equivalent to (~state == false)
    auto& status = Bool();
    mygadget
    << +status / [this]{doAction()
    << +status / "OK" / GColor.green
    << -status / "Wrong" / GColor.red;
GBool & guit::GBool::operator<<= ( GBoolExpr expr)
inherited

Binds this model to an Active Expression (see GExpr).

bool guit::GVarProp::isMutable ( ) const
inlineoverridevirtualinherited

Returns true if the prop is mutable.

Returns true only if the prop derives from GVarProp and setImmutable() was not called. Props with another type than GVarProp are always immutable.

Reimplemented from guit::GProp.

void guit::GVarProp::setImmutable ( )
inlineoverridevirtualinherited

Makes the prop immutable.

Affects only GVarProp props (other props are always immutable). A prop cannot be made mutable again after this method has been called.

Reimplemented from guit::GProp.

void guit::GVarProp::blend ( GProp const &  value1,
GProp const &  value2,
float  mix 
)
virtualinherited

Changes value by blending the value of two props.

Does nothing if the type of from1 or from2 is not convertible to the type of this prop.

Reimplemented in guit::GColor, guit::GPos, and guit::GSize.

void guit::GVarProp::unbind ( GVarProp sender)
inherited

Unbinds this prop.

  • the first version unbinds another prop (note that it doesn't unbind Prop fields).
  • the second version unbinds bindings according to its bindtag argument:

    if bindtag is >= 0, unbinds bindings performed with the same bindtag (default by 0, see bind())

if bindtag is < 0, unbinds all bindings with a value >= bindtag

Importantly, these methods unbinds props both ways if the binding was done both ways (e.g. by using sync())

void guit::GVarProp::blink ( GString const &  msg = "",
GTime  duration = 500 
)
inherited

Blinks gadget parents of the prop.

Shows a warning if msg is not empty.

bool guit::GProp::onAdd ( Gadget g)
virtualinherited

Called when the property is added to an object.

note: must call addModes().

Reimplemented in guit::GTextData, guit::GTip, guit::GCond, guit::GDragPos, guit::GDragSize, guit::GPos, guit::GText, guit::GSize, guit::GFlex, guit::GFlow, guit::GItems, and guit::GValue.

void guit::GProp::onRemove ( Gadget g)
virtualinherited

Called when the property is removed from an object.

note: must call removeModes().

Reimplemented in guit::GTextData, guit::GTip, guit::GCond, guit::GDragPos, guit::GDragSize, guit::GPos, guit::GText, guit::GSize, guit::GFlex, and guit::GHotkey.

void guit::GObject::error ( GString const &  funname,
GString const &  message 
) const
virtualinherited

Prints an error message.

See Also
GApp::onError() to change error management.
void guit::GObject::ignoreSmartPointers ( )
inlineinherited

Checks/sets whether this object can be auto-deleted by smart pointers.

ignoreSmartPointers() has a permanent effect, contrary to forgetSmartPointers(). Objects not created by calling new are never auto-deleted by smart pointers.

void guit::GObject::forgetSmartPointers ( )
inlineinherited

Forgets all smart pointers pointing this object.

The smart pointers that are currently pointing to the object won't auto-delete it. forgetSmartPointers() has a temporary effect, contrary to ignoreSmartPointers().


The documentation for this class was generated from the following files: