DataDirector API
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
DDD_AttributeBase Class Referenceabstract

A virtual interface class for all DataDirector attribute types. More...

#include <DDD_AttributeBase.h>

Inheritance diagram for DDD_AttributeBase:
DDD_AttributeBool DDD_AttributeByteBuffer DDD_AttributeDouble DDD_AttributeInt DDD_AttributeString DDD_AttributeUInt

Public Types

enum  ConnectionState { NOT_CONNECTED = 0, CONNECTED_INPUT = 1<<1, CONNECTED_OUTPUT = 1<<2, CONNECTED_IN_OUT = (CONNECTED_INPUT | CONNECTED_OUTPUT) }
 
enum  DataType {
  STRING = 0, INT, UINT, DOUBLE,
  BOOLEAN, BYTEBUFFER
}
 

Public Member Functions

 DDD_AttributeBase (const std::string &name, DDD_AttributeContainer *container, int validConnectionStates, bool persistent, DDD_AttributeBase *revertable)
 
virtual ~DDD_AttributeBase ()
 
bool CanConnectAsInput ()
 
bool CanConnectAsOutput ()
 
int GetValidConnectionStates ()
 
ConnectionState GetConnectionState ()
 
void SetConnectionState (ConnectionState state)
 
void AddConnectionState (ConnectionState state)
 
bool ConnectionStateSupports (ConnectionState state)
 
const char * Name () const
 
DDD_AttributeContainerGetContainer ()
 
void IncreaseRefCount ()
 
void DecreaseRefCount ()
 
int RefCount ()
 
virtual std::string GetValueString () const =0
 
virtual void SetValueString (const std::string &value, bool notify, DDD_AttributeObserver *originator)=0
 
virtual int GetValueInt (void) const =0
 
virtual void SetValueInt (const int value, bool notify, DDD_AttributeObserver *originator)=0
 
virtual unsigned int GetValueUInt (void) const =0
 
virtual void SetValueUInt (const unsigned int value, bool notify, DDD_AttributeObserver *originator)=0
 
virtual double GetValueDouble (void) const =0
 
virtual void SetValueDouble (const double value, bool notify, DDD_AttributeObserver *originator)=0
 
virtual bool GetValueBool (void) const =0
 
virtual void SetValueBool (const bool value, bool notify, DDD_AttributeObserver *originator)=0
 
virtual void GetValueByteBuffer (char **value, unsigned int &length)=0
 
virtual void SetValueByteBuffer (const char *value, unsigned int length, bool notify, DDD_AttributeObserver *originator)=0
 
virtual DataType GetPreferredDataType () const =0
 
bool AddObserver (DDD_AttributeObserver *observer)
 
bool RemoveObserver (DDD_AttributeObserver *observer)
 
std::string EditorSemantic ()
 
void EditorSemantic (const std::string &semantic)
 
std::string EditorFormatString ()
 
void EditorFormatString (const std::string &formatStr)
 
std::string Connectability ()
 
void SetRevertable (DDD_AttributeBase *attr)
 
DDD_AttributeBaseGetRevertable (void) const
 
void SetPersistent (bool flag)
 
bool IsPersistent (void) const
 
void RevertValue ()
 
void NotifyValueChanged (DDD_AttributeObserver *originator)
 

Static Public Member Functions

static const char * DataTypeToString (DataType type)
 
static DataType StringToDataType (const char *string)
 

Protected Attributes

ObserverList _observerList
 
DDD_AttributeContainer_container
 
int _refCount
 
bool _visiting
 
std::string _name
 
ConnectionState _connectionState
 
int _validConnectionStates
 
std::string _editorSemantic
 
std::string _editorFormatString
 
DDD_AttributeBase_revertable
 
bool _persistent
 

Detailed Description

A virtual interface class for all DataDirector attribute types.

Member Enumeration Documentation

The ConnectionState enum is used both to describe the current connection state of an attribute and the allowable/valid connectablity states of the attribute

Enumerator
NOT_CONNECTED 

The attribute is currently not connected

CONNECTED_INPUT 

The attribute is connected as an input

CONNECTED_OUTPUT 

The attribute is connected as an output

CONNECTED_IN_OUT 

The attribute is connected as both an input and output

enum DataType

The DataType enum describes the base data type used by an attribute. Its main purpose is to facilitate efficient typed access to attribute data

Enumerator
STRING 

String datatype

INT 

Integer datatype (32-bit)

UINT 

Unsigned Integer datatype (32-bit)

DOUBLE 

Double-precision floating point datatype

BOOLEAN 

Boolean datatype

BYTEBUFFER 

ByteBuffer datatype

Constructor & Destructor Documentation

DDD_AttributeBase ( const std::string &  name,
DDD_AttributeContainer container,
int  validConnectionStates,
bool  persistent,
DDD_AttributeBase revertable 
)

constructor

Parameters
nameThe instance name of the attribute
containerThe container that will own the attribute
validConnectionStatesThe allowable connection states for the attribute (i.e. how can it be connected?)
persistentTrue if it's a persistent attribute
revertableIf not NULL, it's a pointer to the revertable attribute for this attribute
virtual ~DDD_AttributeBase ( )
virtual

destructor

Member Function Documentation

void AddConnectionState ( ConnectionState  state)

Adds the state to the connectability mask for this attribute

Parameters
stateThe connection state to set
bool AddObserver ( DDD_AttributeObserver observer)

Adds an observer to this attribute that will be notified whenever this attribute changes

Parameters
observerThe observer to add. The observer to add must not already be observing this attribute.
Returns
True if the observer was successfully added, false otherwise
Precondition
The observer to add must not already be observing this attribute.
bool CanConnectAsInput ( )
inline
Returns
Returns true if this attribute can be connected as an input
bool CanConnectAsOutput ( )
inline
Returns
Returns true if this attribute can be connected as an output
std::string Connectability ( )

the connectability status of the attribute as a string

bool ConnectionStateSupports ( ConnectionState  state)
Returns
Returns true if the connection state supports supplied connection type
Parameters
stateType of connection to check for (CONNECTED_INPUT, CONNECTED_OUTPUT)
static const char* DataTypeToString ( DataType  type)
static
Returns
Converts the data type enum to a string
Parameters
typeThe data type enum
void DecreaseRefCount ( )

Decreases the Reference count of this attribute. The Reference Count tracks the number of connections that reference the attribute.

std::string EditorFormatString ( )
Returns
Returns a printf style format string which the editor may use when editing this attribute
void EditorFormatString ( const std::string &  formatStr)

Sets the printf style format string which the editor may use when editing this attribute

Parameters
formatStrThe format string to set
std::string EditorSemantic ( )
Returns
Returns the "EditorSemantic" which suggests to the editor what type of widget to use when editing this attribute
void EditorSemantic ( const std::string &  semantic)

Sets the "EditorSemantic" which suggests to the editor what type of widget to use when editing this attribute.

Parameters
semanticThe string to set
ConnectionState GetConnectionState ( )
Returns
Returns the current connection state of the attribute as a bitmask
DDD_AttributeContainer* GetContainer ( )
Returns
Returns a pointer to the container that owns this attribute
virtual DataType GetPreferredDataType ( ) const
pure virtual
Returns
Returns the preferred data type of the attribute
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

DDD_AttributeBase* GetRevertable ( void  ) const
inline
Returns
Gets the "revertable" attribute for this attribute. Revertable attributes are "reverted" to an initial value whenever the Data Director is Resumed()
int GetValidConnectionStates ( )
inline
Returns
Returns the valid connection states of the attribute as a bitmask
virtual bool GetValueBool ( void  ) const
pure virtual
Returns
Returns the value of this attribute as an boolean
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual void GetValueByteBuffer ( char **  value,
unsigned int &  length 
)
pure virtual
Returns
Returns the value of this attribute as an byteBuffer
Parameters
valueNewly-allocated buffer returned length of buffer
Note
To avoid leaks, the data returned by value should be deleted when appropriate by the calling module.
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual double GetValueDouble ( void  ) const
pure virtual
Returns
Returns the value of this attribute as double
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual int GetValueInt ( void  ) const
pure virtual
Returns
Returns the value of this attribute as an int
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual std::string GetValueString ( ) const
pure virtual
Returns
Returns the value of this attribute in string format

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual unsigned int GetValueUInt ( void  ) const
pure virtual
Returns
Returns the value of this attribute as an unsigned int

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

void IncreaseRefCount ( )

Increases the Reference count of this attribute. The Reference Count tracks the number of connections that reference the attribute.

bool IsPersistent ( void  ) const
inline
Returns
Gets the "persistent" flag for this attribute. Persistent attributes are not deleted by the "DeleteDynamicAttributes" method of DDD_AttributeList
const char* Name ( ) const
Returns
Returns the instance name of this attribute
void NotifyValueChanged ( DDD_AttributeObserver originator)

Notifies all observers of this attribute that the value has changed

int RefCount ( )
Returns
Returns the Reference count of this attribute. The Reference Count tracks the number of connections that reference the attribute.
bool RemoveObserver ( DDD_AttributeObserver observer)

Removes an observer from the observer list

Parameters
observerThe observer to remove.
Returns
True if the observer was found and removed, false if it wasn't found
void RevertValue ( )

Causes this attribute to "revert" to it's revert value

void SetConnectionState ( ConnectionState  state)

Sets the current connection state of the attribute

Parameters
stateThe connection state to set
void SetPersistent ( bool  flag)
inline

Sets the "persistent" flag for this attribute. Persistent attributes are not deleted by the "DeleteDynamicAttributes" method of DDD_AttributeList

Parameters
flagNew persistent flag
void SetRevertable ( DDD_AttributeBase attr)
inline

Sets the "revertable" attribute for this attribute. Revertable attributes are "reverted" to an initial value whenever the Data Director is Resumed()

Parameters
flagNew revertable flag
virtual void SetValueBool ( const bool  value,
bool  notify,
DDD_AttributeObserver originator 
)
pure virtual

Sets the value of this attribute using a bool value

Parameters
valueThe new value of the attribute
notifyWhether or not to notify attribute observers
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual void SetValueByteBuffer ( const char *  value,
unsigned int  length,
bool  notify,
DDD_AttributeObserver originator 
)
pure virtual

Sets the value of this attribute using a byte buffer value

Parameters
valueThe new buffer value of the attribute length of buffer
notifyWhether or not to notify attribute observers
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual void SetValueDouble ( const double  value,
bool  notify,
DDD_AttributeObserver originator 
)
pure virtual

Sets the value of this attribute using a double value

Parameters
valueThe new value of the attribute
notifyWhether or not to notify attribute observers
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual void SetValueInt ( const int  value,
bool  notify,
DDD_AttributeObserver originator 
)
pure virtual

Sets the value of this attribute using an int value

Parameters
valueThe new value of the attribute
notifyWhether or not to notify attribute observers
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual void SetValueString ( const std::string &  value,
bool  notify,
DDD_AttributeObserver originator 
)
pure virtual

Sets the value of this attribute using a string value

Parameters
valueThe new value of the attribute
notifyWhether or not to notify attribute observers
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

virtual void SetValueUInt ( const unsigned int  value,
bool  notify,
DDD_AttributeObserver originator 
)
pure virtual

Sets the value of this attribute using an unsigned int value

Parameters
valueThe new value of the attribute
notifyWhether or not to notify attribute observers
Exceptions
DDD_AttributeConversionException

Implemented in DDD_AttributeByteBuffer, DDD_AttributeString, DDD_AttributeUInt, DDD_AttributeBool, DDD_AttributeDouble, and DDD_AttributeInt.

static DataType StringToDataType ( const char *  string)
static
Returns
Converts the data type string to an enum
Parameters
stringThe data type as a string

Member Data Documentation

ConnectionState _connectionState
protected

The current connection state of this attribute

DDD_AttributeContainer* _container
protected

The container that owns this attribute

std::string _editorFormatString
protected

printf style format string to use in the editor

std::string _editorSemantic
protected

String defining what type of widget to use in the editor

std::string _name
protected

The instance name of this attribute

ObserverList _observerList
protected

The list of observers to notify when this attribute changes

bool _persistent
protected

True if the attribute is a "Persistent" attribute.

int _refCount
protected

The number of connections that reference this attribute

DDD_AttributeBase* _revertable
protected

If the attribute is a "Revertable" attribute, pointer to attribute to revert to

int _validConnectionStates
protected

The valid connectability states possible for this attribute

bool _visiting
protected

True while attribute is being visited...prevents loops


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