COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Option Class Referenceabstract

Adds fonctionnalities to Property class. More...

#include <Option.hpp>

Inherits TaggedObject.

Inherited by OptionArray< TYPE >, OptionComponent< T >, OptionT< TYPE >, and OptionT< URI >.

Public Types

typedef boost::function< void() > TriggerT
 Typedef for trigger functions. More...
 
typedef Uint TriggerID
 ID for triggers. More...
 
typedef std::map< TriggerID, TriggerTTriggerStorageT
 Typedef for trigger functions storage. More...
 

Public Member Functions

 Option (const std::string &name, boost::any def)
 
virtual ~Option ()
 Desctructor. More...
 
template<typename TYPE >
TYPE value () const
 Casts the value to the provided TYPE. More...
 
template<typename OPTION_TYPE >
OPTION_TYPE & cast_to ()
 
template<typename OPTION_TYPE >
const OPTION_TYPE & cast_to () const
 
Optionpretty_name (const std::string &pretty_name)
 Sets the option pretty name. More...
 
Optiondescription (const std::string &description)
 Sets the option description. More...
 
Optionseparator (const std::string &separator)
 Sets the option operator. The separator is used in some convertions to string to separate items, i.e. the restricted list of values or the option value if it is an array. More...
 
void set (XML::XmlNode &node)
 configure this option using the passed xml node More...
 
Optionattach_trigger (TriggerT trigger)
 
TriggerID attach_trigger_tracked (TriggerT trigger)
 Attach a trigger, returning an ID that can be used to detach again. More...
 
void detach_trigger (const TriggerID trigger_id)
 Detach the given trigger. More...
 
std::string name () const
 
std::string pretty_name () const
 
std::string description () const
 
std::string separator () const
 
Optionoperator= (const boost::any &new_value)
 
template<typename TYPE >
Optionlink_to (TYPE *par)
 
Optionlink_option (const boost::shared_ptr< common::Option > &linked)
 Link another option to this option. More...
 
Optionmark_basic ()
 
virtual void change_value (const boost::any &value)
 change the value of this option More...
 
std::vector< boost::any > & restricted_list ()
 Gives a reference to the restricted list. More...
 
const std::vector< boost::any > & restricted_list () const
 Gives a const reference to the restricted list. More...
 
virtual std::string restricted_list_str () const =0
 Return the restricted list as string. More...
 
virtual void set_restricted_list_str (const std::vector< std::string > &list)=0
 Set the restricted list using a vector of strings. More...
 
virtual bool has_restricted_list () const
 Checks whether the option has a list of restricted values. More...
 
void trigger () const
 Calls the triggers connected to this option. More...
 
void restore_default ()
 restore the default value of the option More...
 
VIRTUAL FUNCTIONS
virtual std::string value_str () const =0
 
virtual boost::any value () const
 
virtual std::string type () const
 
virtual std::string element_type () const
 
- Public Member Functions inherited from TaggedObject
 TaggedObject ()
 Constructor. More...
 
bool has_tag (const std::string &tag) const
 
void add_tag (const std::string &tag)
 
std::vector< std::string > get_tags () const
 
void remove_tag (const std::string &tag)
 

Protected Attributes

boost::any m_value
 storage of the value of the option More...
 
std::vector< boost::any > m_linked_params
 parameters that also get updated when option is changed More...
 
std::vector< Handle< Option > > m_linked_opts
 options that also get updated when option is changed More...
 

Private Member Functions

virtual void copy_to_linked_params (std::vector< boost::any > &linked_params)=0
 copy the configured update value to all linked parameters More...
 
void copy_to_linked_options ()
 
virtual boost::any extract_configured_value (XML::XmlNode &node)=0
 
virtual void change_value_impl (const boost::any &value)=0
 Concrete implementation of the value changing. More...
 

Private Attributes

boost::any m_default
 storage of the default value of the option More...
 
std::string m_name
 option name More...
 
std::string m_pretty_name
 option pretty name More...
 
std::string m_description
 option description More...
 
TriggerStorageT m_triggers
 list of processors that will process the option More...
 
std::vector< boost::any > m_restricted_list
 Restricted list of values. More...
 
std::string m_separator
 Option separator. More...
 
Uint m_current_connection_id
 Current connection ID for the triggers. More...
 

Detailed Description

Adds fonctionnalities to Property class.

An option is a piece of data of which user can modify the value. An option provides:

Definition at line 76 of file Option.hpp.

Member Typedef Documentation

typedef Uint TriggerID

ID for triggers.

Definition at line 83 of file Option.hpp.

Typedef for trigger functions storage.

Definition at line 85 of file Option.hpp.

typedef boost::function< void() > TriggerT

Typedef for trigger functions.

Definition at line 81 of file Option.hpp.

Constructor & Destructor Documentation

Option ( const std::string &  name,
boost::any  def 
)

Constructor.

Parameters
nameOption name.
defDefault value.

Definition at line 19 of file Option.cpp.

~Option ( )
virtual

Desctructor.

Definition at line 32 of file Option.cpp.

Member Function Documentation

Option & attach_trigger ( TriggerT  trigger)

attach a function that will be triggered when an option gets configured

Returns
this option

Definition at line 46 of file Option.cpp.

Option::TriggerID attach_trigger_tracked ( Option::TriggerT  trigger)

Attach a trigger, returning an ID that can be used to detach again.

Definition at line 54 of file Option.cpp.

OPTION_TYPE& cast_to ( )
inline

Definition at line 114 of file Option.hpp.

const OPTION_TYPE& cast_to ( ) const
inline

Definition at line 120 of file Option.hpp.

void change_value ( const boost::any &  value)
virtual

change the value of this option

Definition at line 89 of file Option.cpp.

virtual void change_value_impl ( const boost::any &  value)
privatepure virtual

Concrete implementation of the value changing.

Implemented in OptionArray< TYPE >, OptionComponent< T >, OptionT< TYPE >, OptionT< URI >, and OptionURI.

void copy_to_linked_options ( )
private

Definition at line 108 of file Option.cpp.

virtual void copy_to_linked_params ( std::vector< boost::any > &  linked_params)
privatepure virtual

copy the configured update value to all linked parameters

Implemented in OptionComponent< T >, OptionArray< TYPE >, OptionT< TYPE >, and OptionT< URI >.

Option & description ( const std::string &  description)

Sets the option description.

Parameters
pretty_nameThe option description.
Returns
Returns a reference to this object.

Definition at line 148 of file Option.cpp.

std::string description ( ) const
inline
Returns
the description of the option

Definition at line 179 of file Option.hpp.

void detach_trigger ( const TriggerID  trigger_id)

Detach the given trigger.

Definition at line 64 of file Option.cpp.

std::string element_type ( ) const
virtual
Returns
the type of a single sub-element as a string

Reimplemented in OptionArray< TYPE >.

Definition at line 141 of file Option.cpp.

virtual boost::any extract_configured_value ( XML::XmlNode node)
privatepure virtual

Get the value to use from XML

Parameters
nodeXML node with data for this option

Implemented in OptionComponent< T >, OptionArray< TYPE >, OptionT< TYPE >, and OptionT< URI >.

virtual bool has_restricted_list ( ) const
inlinevirtual

Checks whether the option has a list of restricted values.

Returns
Returns true if the option a such list; otherwise, returns false.

Definition at line 229 of file Option.hpp.

Option & link_option ( const boost::shared_ptr< common::Option > &  linked)

Link another option to this option.

so that when this option is changed, the other option will be changed as well

Definition at line 100 of file Option.cpp.

Option& link_to ( TYPE *  par)
inline

Link the state of this option to the passed parameter

Returns
this option

Definition at line 192 of file Option.hpp.

Option & mark_basic ( )

this option is tagged as a basic option on the GUI

Returns
this option

Definition at line 80 of file Option.cpp.

std::string name ( ) const
inline
Returns
the name of the option

Definition at line 173 of file Option.hpp.

Option & operator= ( const boost::any &  new_value)

Assigns a new value to the option

Parameters
new_valueThe new value
Returns
Returns a reference to this object.

Definition at line 72 of file Option.cpp.

Option & pretty_name ( const std::string &  pretty_name)

Sets the option pretty name.

Parameters
pretty_nameThe option pretty name.
Returns
Returns a reference to this object.

Definition at line 156 of file Option.cpp.

std::string pretty_name ( ) const
inline
Returns
the pretty name of the option

Definition at line 176 of file Option.hpp.

void restore_default ( )
inline

restore the default value of the option

Definition at line 235 of file Option.hpp.

std::vector<boost::any>& restricted_list ( )
inline

Gives a reference to the restricted list.

Returns
Returns a reference to the restricted list.

Definition at line 214 of file Option.hpp.

const std::vector<boost::any>& restricted_list ( ) const
inline

Gives a const reference to the restricted list.

Returns
Returns a const reference to the restricted list.

Definition at line 218 of file Option.hpp.

virtual std::string restricted_list_str ( ) const
pure virtual

Return the restricted list as string.

Implemented in OptionComponent< T >, OptionArray< TYPE >, OptionT< TYPE >, OptionT< URI >, and OptionURI.

Option & separator ( const std::string &  separator)

Sets the option operator. The separator is used in some convertions to string to separate items, i.e. the restricted list of values or the option value if it is an array.

Parameters
pretty_nameThe option description.
Returns
Returns a reference to this object.

Definition at line 164 of file Option.cpp.

std::string separator ( ) const
inline
Returns
the separator of the option

Definition at line 182 of file Option.hpp.

void set ( XML::XmlNode node)

configure this option using the passed xml node

Definition at line 38 of file Option.cpp.

virtual void set_restricted_list_str ( const std::vector< std::string > &  list)
pure virtual

Set the restricted list using a vector of strings.

Implemented in OptionComponent< T >, OptionArray< TYPE >, OptionT< TYPE >, and OptionT< URI >.

void trigger ( ) const

Calls the triggers connected to this option.

Definition at line 121 of file Option.cpp.

std::string type ( ) const
virtual
Returns
the type of the option as a string

Reimplemented in OptionComponent< T >.

Definition at line 134 of file Option.cpp.

TYPE value ( ) const
inline

Casts the value to the provided TYPE.

Returns
Returns the cast value.
Exceptions
CastingFailedif the value could not be cast.

Definition at line 100 of file Option.hpp.

virtual boost::any value ( ) const
inlinevirtual
Returns
A copy of the stored value

Reimplemented in OptionComponent< T >, OptionComponent< T >, OptionArray< TYPE >, and OptionArray< TYPE >.

Definition at line 132 of file Option.hpp.

virtual std::string value_str ( ) const
pure virtual
Returns
Returns the value cast to string.

Implemented in OptionComponent< T >, OptionArray< TYPE >, OptionT< TYPE >, and OptionT< URI >.

Member Data Documentation

Uint m_current_connection_id
private

Current connection ID for the triggers.

Definition at line 262 of file Option.hpp.

boost::any m_default
private

storage of the default value of the option

Definition at line 247 of file Option.hpp.

std::string m_description
private

option description

Definition at line 253 of file Option.hpp.

std::vector< Handle<Option> > m_linked_opts
protected

options that also get updated when option is changed

Definition at line 243 of file Option.hpp.

std::vector< boost::any > m_linked_params
protected

parameters that also get updated when option is changed

Definition at line 241 of file Option.hpp.

std::string m_name
private

option name

Definition at line 249 of file Option.hpp.

std::string m_pretty_name
private

option pretty name

Definition at line 251 of file Option.hpp.

std::vector<boost::any> m_restricted_list
private

Restricted list of values.

Definition at line 257 of file Option.hpp.

std::string m_separator
private

Option separator.

Definition at line 259 of file Option.hpp.

TriggerStorageT m_triggers
private

list of processors that will process the option

Definition at line 255 of file Option.hpp.

boost::any m_value
protected

storage of the value of the option

Definition at line 239 of file Option.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin