AuboCaps  0.6.0
arcs::aubo_scope::DataModel Class Reference

#include <data_model.h>

Public Member Functions

 DataModel (DataModel &f)
 
 DataModel (DataModel &&f)
 
 ~DataModel ()
 
void set (const std::string &key, bool value)
 Assign a bool value to the specified key. More...
 
bool get (const std::string &key, bool default_value) const
 Get the bool value assigned to the specified key. More...
 
void set (const std::string &key, int value)
 Assign an int value to the specified key. More...
 
int get (const std::string &key, int default_value) const
 Get the int value assigned to the specified key. More...
 
void set (const std::string &key, long value)
 Assign a long value to the specified key. More...
 
void set (const std::string &key, uint64_t value)
 
long get (const std::string &key, long default_value) const
 Get the long value assigned to the specified key. More...
 
uint64_t get (const std::string &key, uint64_t default_value) const
 
void set (const std::string &key, float value)
 Assign a float value to the specified key. More...
 
float get (const std::string &key, float default_value) const
 Get the float value assigned to the specified key. More...
 
void set (const std::string &key, double value)
 Assign a double value to the specified key. More...
 
double get (const std::string &key, double default_value) const
 Get the double value assigned to the specified key. More...
 
void set (const std::string &key, const std::string &value)
 Assign a std::string value to the specified key. More...
 
std::string get (const std::string &key, const std::string &default_value) const
 Get the std::string value assigned to the specified key. More...
 
void set (const std::string &key, VariablePtr value)
 Assign a Variable value to the specified key. More...
 
void set (const std::string &key, ExpressionPtr value)
 
void set (const std::string &key, PayloadPtr value)
 
void set (const std::string &key, IoPtr value)
 
void set (const std::string &key, WaypointPtr value)
 
VariablePtr get (const std::string &key, VariablePtr default_value) const
 Get the Variable value assigned to the specified key. More...
 
ExpressionPtr get (const std::string &key, ExpressionPtr default_value) const
 
PayloadPtr get (const std::string &key, PayloadPtr default_value) const
 
IoPtr get (const std::string &key, IoPtr default_value) const
 
WaypointPtr get (const std::string &key, WaypointPtr default_value) const
 
void set (const std::string &key, const std::vector< bool > &value)
 Assign a bool[] as value to the specified key. More...
 
std::vector< bool > get (const std::string &key, const std::vector< bool > &default_value) const
 Get the bool[] as value assigned to the specified key. More...
 
void set (const std::string &key, const std::vector< int > &value)
 Assign a int[] as value to the specified key. More...
 
std::vector< int > get (const std::string &key, const std::vector< int > &default_value) const
 Get the int[] as value assigned to the specified key. More...
 
void set (const std::string &key, const std::vector< long > &value)
 Assign a long[] as value to the specified key. More...
 
void set (const std::string &key, const std::vector< uint64_t > &value)
 
std::vector< long > get (const std::string &key, const std::vector< long > &default_value) const
 Get the long[] as value assigned to the specified key. More...
 
std::vector< uint64_t > get (const std::string &key, const std::vector< uint64_t > &default_value) const
 
void set (const std::string &key, const std::vector< float > &value)
 Assign a float[] as value to the specified key. More...
 
std::vector< float > get (const std::string &key, const std::vector< float > &default_value) const
 Get the float[] as value assigned to the specified key. More...
 
void set (const std::string &key, const std::vector< double > &value)
 Assign a double[] as value to the specified key. More...
 
std::vector< double > get (const std::string &key, const std::vector< double > &default_value) const
 Get the double[] as value assigned to the specified key. More...
 
void set (const std::string &key, const std::vector< std::string > &value)
 Assign a std::string[] as value to the specified key. More...
 
std::vector< std::string > get (const std::string &key, const std::vector< std::string > &default_value) const
 Get the std::string[] as value assigned to the specified key. More...
 
void set (const std::string &key, TCPPtr value)
 Assign a TCP value to the specified key. More...
 
TCPPtr get (const std::string &key, TCPPtr default_value) const
 Get the TCP value assigned to the specified key. More...
 
void set (const std::string &key, FeaturePtr value)
 Assign a Feature value to the specified key. More...
 
FeaturePtr get (const std::string &key, FeaturePtr default_value) const
 Get the Feature value assigned to the specified key. More...
 
std::set< std::string > getKeys () const
 Get a set of all the keys in the data model. More...
 
bool isSet (const std::string &key) const
 Check if a key is present in the data model. More...
 
bool remove (const std::string &key)
 Remove a key-value pair from the data model. More...
 

Private Member Functions

 DataModel ()
 

Private Attributes

void * d_ { nullptr }
 

Friends

class DataSwitch
 

Detailed Description

This interface is used for storing and managing data that represents the current configuration of, e.g. a ProgramNodeContribution or InstallationNodeContribution. Methods for adding, removing, retrieving and changing values in a dictionary are provided.

Setting a new value for a key already in use, will overwrite the current value with the new value. This happens regardless of the type of value (e.g. storing the value true under the key myBool and afterwards storing an Angle object under the same key will overwrite the value true with the provided Angle object).

A auboCap installation screen has an underlying DataModel object. That object is saved and loaded along with each AuboScope installation.

Similarly, each contributed program node instance has an underlying DataModel object. That object is saved and loaded along with the program where the node occurs. Undo/redo actions are supported for all modifications to the DataModel object in HTML-based program node contributions. Swing-based AuboCaps must use the UndoRedoManager to record the changes on the undo/redo stack.

When retrieving an object, both key and object type must match what was previously stored. This means that if a TCP object was stored using the key myAngle, then attempting to retrieve it using get(std::string key, Angle default_value) with the key myAngle will not return the stored value, since the types do not match. Instead the provided default_value will be returned.

Definition at line 65 of file data_model.h.

Constructor & Destructor Documentation

arcs::aubo_scope::DataModel::DataModel ( DataModel f)
arcs::aubo_scope::DataModel::DataModel ( DataModel &&  f)
arcs::aubo_scope::DataModel::~DataModel ( )
arcs::aubo_scope::DataModel::DataModel ( )
private

Member Function Documentation

bool arcs::aubo_scope::DataModel::get ( const std::string &  key,
bool  default_value 
) const

Get the bool value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
int arcs::aubo_scope::DataModel::get ( const std::string &  key,
int  default_value 
) const

Get the int value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
long arcs::aubo_scope::DataModel::get ( const std::string &  key,
long  default_value 
) const

Get the long value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
uint64_t arcs::aubo_scope::DataModel::get ( const std::string &  key,
uint64_t  default_value 
) const
float arcs::aubo_scope::DataModel::get ( const std::string &  key,
float  default_value 
) const

Get the float value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
double arcs::aubo_scope::DataModel::get ( const std::string &  key,
double  default_value 
) const

Get the double value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
std::string arcs::aubo_scope::DataModel::get ( const std::string &  key,
const std::string &  default_value 
) const

Get the std::string value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
VariablePtr arcs::aubo_scope::DataModel::get ( const std::string &  key,
VariablePtr  default_value 
) const

Get the Variable value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
ExpressionPtr arcs::aubo_scope::DataModel::get ( const std::string &  key,
ExpressionPtr  default_value 
) const
PayloadPtr arcs::aubo_scope::DataModel::get ( const std::string &  key,
PayloadPtr  default_value 
) const
IoPtr arcs::aubo_scope::DataModel::get ( const std::string &  key,
IoPtr  default_value 
) const
WaypointPtr arcs::aubo_scope::DataModel::get ( const std::string &  key,
WaypointPtr  default_value 
) const
std::vector<bool> arcs::aubo_scope::DataModel::get ( const std::string &  key,
const std::vector< bool > &  default_value 
) const

Get the bool[] as value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
std::vector<int> arcs::aubo_scope::DataModel::get ( const std::string &  key,
const std::vector< int > &  default_value 
) const

Get the int[] as value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
std::vector<long> arcs::aubo_scope::DataModel::get ( const std::string &  key,
const std::vector< long > &  default_value 
) const

Get the long[] as value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
std::vector<uint64_t> arcs::aubo_scope::DataModel::get ( const std::string &  key,
const std::vector< uint64_t > &  default_value 
) const
std::vector<float> arcs::aubo_scope::DataModel::get ( const std::string &  key,
const std::vector< float > &  default_value 
) const

Get the float[] as value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
std::vector<double> arcs::aubo_scope::DataModel::get ( const std::string &  key,
const std::vector< double > &  default_value 
) const

Get the double[] as value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
std::vector<std::string> arcs::aubo_scope::DataModel::get ( const std::string &  key,
const std::vector< std::string > &  default_value 
) const

Get the std::string[] as value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
TCPPtr arcs::aubo_scope::DataModel::get ( const std::string &  key,
TCPPtr  default_value 
) const

Get the TCP value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
FeaturePtr arcs::aubo_scope::DataModel::get ( const std::string &  key,
FeaturePtr  default_value 
) const

Get the Feature value assigned to the specified key.

Parameters
keykey in the data model.
default_valuevalue to be returned, if key does not exist.
Returns
the value assigned to the key. If not exist, default_value is returned.
std::set<std::string> arcs::aubo_scope::DataModel::getKeys ( ) const

Get a set of all the keys in the data model.

Returns
A Set of keys.
bool arcs::aubo_scope::DataModel::isSet ( const std::string &  key) const

Check if a key is present in the data model.

Parameters
keykey in the data model (not null and not an empty std::string).
Returns
true, if key exist, otherwise false.
bool arcs::aubo_scope::DataModel::remove ( const std::string &  key)

Remove a key-value pair from the data model.

Parameters
keykey in the data model (not null and not an empty std::string).
Returns
true, if succeed, otherwise false.
Exceptions
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
bool  value 
)

Assign a bool value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
int  value 
)

Assign an int value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
long  value 
)

Assign a long value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
uint64_t  value 
)
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
float  value 
)

Assign a float value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
double  value 
)

Assign a double value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
const std::string &  value 
)

Assign a std::string value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
VariablePtr  value 
)

Assign a Variable value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
ExpressionPtr  value 
)
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
PayloadPtr  value 
)
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
IoPtr  value 
)
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
WaypointPtr  value 
)
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
const std::vector< bool > &  value 
)

Assign a bool[] as value to the specified key.

Parameters
keykey in the data model (not null} and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
const std::vector< int > &  value 
)

Assign a int[] as value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
const std::vector< long > &  value 
)

Assign a long[] as value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null} or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
const std::vector< uint64_t > &  value 
)
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
const std::vector< float > &  value 
)

Assign a float[] as value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
const std::vector< double > &  value 
)

Assign a double[] as value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
const std::vector< std::string > &  value 
)

Assign a std::string[] as value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
TCPPtr  value 
)

Assign a TCP value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).
void arcs::aubo_scope::DataModel::set ( const std::string &  key,
FeaturePtr  value 
)

Assign a Feature value to the specified key.

Parameters
keykey in the data model (not null and not an empty std::string).
valuevalue assigned to key.
Exceptions
IllegalArgumentExceptionif the key is null or an empty std::string.
IllegalStateExceptionif called from a Swing-based AuboCap program node outside of an UndoableChanges scope (see also UndoRedoManager).

Friends And Related Function Documentation

friend class DataSwitch
friend

Definition at line 497 of file data_model.h.

Member Data Documentation

void* arcs::aubo_scope::DataModel::d_ { nullptr }
private

Definition at line 499 of file data_model.h.


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