Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Static Public Member Functions | Static Private Member Functions
icl::qt::DataStore Class Reference

Extension of the associative container MultiTypeMap. More...

#include <DataStore.h>

Inheritance diagram for icl::qt::DataStore:
icl::utils::MultiTypeMap

List of all members.

Classes

struct  Assign
 internally used assignment structure More...
class  Data
 Arbitrary Data encapsulation type. More...
struct  KeyNotFoundException
 Internal Exception type thrown if operator[] is given an unknown index string. More...
struct  UnassignableTypesException
 Internal Exception type thrown if Data::operator= is called for incompatible values. More...

Public Member Functions

Data operator[] (const std::string &key) throw (KeyNotFoundException)
 Allows to assign new values to a entry with given key (*NEW*)
template<class T >
std::vector< T > collect (const std::vector< std::string > &keys)
 convenience function that allows collecting data from different source entries

Static Public Member Functions

static void list_possible_assignments (const std::string &srcType, const std::string &dstType)
 gives a list of possible assignemts for optinally given src and dst Type
template<class SRC , class DST >
static void register_assignment_rule (const std::string &srcTypeName, const std::string &dstTypeName, utils::Function< void, const SRC &, DST & > assign)
 registers a new assignment rule to the DataStore class
template<class SRC , class DST >
static void register_trivial_assignment_rule (const std::string &srcTypeName, const std::string &dstTypeName)
 registers trivial assignment rule to the DataStore class

Static Private Member Functions

static void register_assignment_rule (Assign *assign)
 internal assign method

Detailed Description

Extension of the associative container MultiTypeMap.

Adds an index operator[string] for direct access to contained values


Member Function Documentation

template<class T >
std::vector<T> icl::qt::DataStore::collect ( const std::vector< std::string > &  keys) [inline]

convenience function that allows collecting data from different source entries

This function can e.g. be used to obtain data from an array of 'float' GUI components

static void icl::qt::DataStore::list_possible_assignments ( const std::string &  srcType,
const std::string &  dstType 
) [static]

gives a list of possible assignemts for optinally given src and dst Type

Data icl::qt::DataStore::operator[] ( const std::string &  key) throw (KeyNotFoundException)

Allows to assign new values to a entry with given key (*NEW*)

The returned Data-Element is a shallow Reference of a DataStore entry of internal type DataArray. Each entry is typed by C++'s RTTI, so, the function can determine if the assigned value is compatible to actual type of the data element. Internally a magic assignment system is used to determine whether two types can be assigned, and what to do if. Basically one can say, type assignments line T = T are of course allowed as well as type assignments A = B, if A and B are C++ built-in numerical type (int, float, etc.) Additionally a lot of GUIHandle types (contained by a GUI's DataStore) can be assigned (and updated, see void DataStore::Data::update()) with this mechanism

A detailed description of all allowed assigmnet must ba added here: TODO...

Here are some examples ...

          DataStore x;
          x.allocValue("hello",int(5));
          x.allocValue("world",float(5));
          x.allocValue("!",std::string("yes yes!"));
          
          x["hello"] = "44"; // string to int
          x["world"] = 4;    // int to float
          x["!"] = 44;       // int to string
          x["hello"] = 44;   // int to int
          
          x.allocValue("image",ImgHandle(...));
          x["image"] = icl::create("parrot");   // ImgQ to ImageHandle
          
          x.allocValue("sl",SliderHandle(...));
          
          x["sl"] = 7;               // sets slider value to 7
          std::cout << "slider val is:" << x["sl"].as<int>() << std::endl;
          
          x["sl"] = Range32s(3,9);   // sets slider's Range ...
static void icl::qt::DataStore::register_assignment_rule ( Assign assign) [static, private]

internal assign method

template<class SRC , class DST >
static void icl::qt::DataStore::register_assignment_rule ( const std::string &  srcTypeName,
const std::string &  dstTypeName,
utils::Function< void, const SRC &, DST & >  assign 
) [inline, static]

registers a new assignment rule to the DataStore class

After the call, the two types can be assigned (for reading and writing DataStore entries)

template<class SRC , class DST >
static void icl::qt::DataStore::register_trivial_assignment_rule ( const std::string &  srcTypeName,
const std::string &  dstTypeName 
) [inline, static]

registers trivial assignment rule to the DataStore class

Trivial assignments are performed using dst = src


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines