DataModel Class Reference
Declared in |
|
template <class T> class DataModel; |
flip::DataModel is a type that represents declarations of classes that form a consistent data model. Typical usage consists to derive from this class, using this class as the template parameter, to define your model.
Example:
class MyModel : public flip::DataModel <MyModel> {}; |
Member Functions Synopsys
Sets the format revision of the data model | |
Declares a class of the model | |
Adds a class to the model | |
Changes the root class of the model | |
Returns true iff the class is available in the model | |
Clones an entire model |
Member Functions
version
static void version (const std::string & version); |
Sets the format revision of the data model. The name must be in the ascii-7 character set, with exception of control characters as well as del character.
The format revision is used to discriminate between two data models. This is typically used for document conversion from one data model to another one, for example when upgrading to a new version of the model with more properties.
Example:
MyModel::version ("1.00 RC1"); |
declare
template <class U> static Class <U> & declare (); |
Declares a class and add it to the model. Returns a reference to the Class to declare the class name, inheritance and members.
This also sets the class as the root class model, making the last declaration the root class by default. This behavior can be changed by using set_root decribed below.
Example:
MyModel::declare <MyClass> () |
.name ("MyClass"); |
add
template <class U> static void add (); |
Add an already declared class to the model. This is typically used when sharing a class between multiple models.
Example:
MyModel::declare <MyClass> () |
.name ("MyClass"); |
MyModel2::add <MyClass> (); |
set_root
template <class U> static void set_root (); |
Changes the root class of the model. The class must already been declared in the model. This is typically used in unit testing.
Example:
MyModel::declare <Root> () |
.name ("Root"); |
// last declared class is root by default |
MyModel::set_root <MyClass> (); |
// now the root of 'MyModel' is 'MyClass' |
has
template <class U> static bool has (); |
Returns true iff the class is available in the model.
Example:
MyModel::declare <MyClass> () |
.name ("MyClass"); |
assert (MyModel::has <MyClass>); |
clone_from
template <class Model> static void clone_from (); |
Clones an entire model.
This is typically used in unit testing to :
- clone an entire model and change the root class to isolate testing
- clone an entire model and add a text fixture class
Example:
MyTestModel::clone_from <MyModel> (); |
MyTestModel::declare <MyFixture> (); |
MyTestModel::set_root <MyFixture> (); |