Abstract base class defining the interactions with the persistence module. More...
#include <storage/storage.h>
Public Types | |
typedef std::map< size_t, ReferencePtr > | ref_map |
typedef std::map< QString, ref_map > | ref_map_type |
typedef ptrdiff_t | reference_t |
Type of a reference identifier. | |
Public Member Functions | |
virtual bool | checkNextField (const QString &name)=0 |
Test if there is a field with matching name and type. | |
virtual void | clear () |
Clear the internal structures of the object. | |
virtual void | clearLastError () |
Remove any error message. | |
virtual bool | endCompound ()=0 |
End the current compound. | |
virtual bool | endReference ()=0 |
Stop the current reference. | |
template<typename T , typename Model > | |
bool | field (const QString &name, T &value, Model *model) |
Create a new field, using the model to serialize it. | |
template<typename T > | |
bool | field (const QString &name, T &value) |
Create a new field. | |
virtual QString | filename () const =0 |
Name of the file being processed. | |
const QString & | fileVersion () const |
Version of the file. | |
virtual bool | ignore (const QString &) |
Instruct a reader to ignore the next field if called name . | |
int | lastError () const |
Retrieve the identifier for the last error. | |
QString | lastErrorString () const |
Retrieve a string describing the last error that occured, if any. | |
virtual bool | reader ()=0 |
template<typename Ptr > | |
bool | reference (const QString &name, const QString &type, Ptr &value, Model *model) |
Create a reference to a field, using the model to serialize it. | |
template<typename Ptr > | |
bool | reference (const QString &name, const QString &type, Ptr &value) |
Create a reference to a field. | |
virtual bool | serialize (const QString &filename, Model *model)=0 |
Load or save depending on the object. | |
virtual void | setLastError (int error, const QString &error_str) |
Change the text of the last error. | |
virtual bool | setOption (int, int) |
Change an option. | |
virtual bool | startCompound (const QString &name)=0 |
Start a new compound. | |
virtual int | startReference (const QString &name, const QString &ref_type, reference_t ref)=0 |
Start a reference. | |
int | version () const |
Integer representing the version of the file for the model. | |
virtual bool | writer ()=0 |
virtual | ~VVEStorage () |
Pure virtual destructor to allow for inheritance. | |
Fields with standard types | |
virtual bool | field (const QString &name, std::string &value)=0 |
Create a std::string field. | |
virtual bool | field (const QString &name, QString &value)=0 |
Create a QString field. | |
virtual bool | field (const QString &name, long double &value)=0 |
Create a long double field. | |
virtual bool | field (const QString &name, double &value)=0 |
Create a double field. | |
virtual bool | field (const QString &name, float &value)=0 |
Create a float field. | |
virtual bool | field (const QString &name, unsigned long long &value)=0 |
Create a unsigned long long integer field. | |
virtual bool | field (const QString &name, unsigned long &value)=0 |
Create a unsigned long integer field. | |
virtual bool | field (const QString &name, unsigned int &value)=0 |
Create an unsigned integer field. | |
virtual bool | field (const QString &name, unsigned short &value)=0 |
Create a unsigned short integer field. | |
virtual bool | field (const QString &name, unsigned char &value)=0 |
Create a unsigned char field. | |
virtual bool | field (const QString &name, long long &value)=0 |
Create a long long integer field. | |
virtual bool | field (const QString &name, long &value)=0 |
Create a long integer field. | |
virtual bool | field (const QString &name, int &value)=0 |
Create an integer field. | |
virtual bool | field (const QString &name, short &value)=0 |
Create a short integer field. | |
virtual bool | field (const QString &name, signed char &value)=0 |
Create a signed char field. | |
virtual bool | field (const QString &name, char &value)=0 |
Create a char field. | |
virtual bool | field (const QString &name, wchar_t &value)=0 |
Create a wchar_t field. | |
virtual bool | field (const QString &name, bool &value)=0 |
Create a boolean field. | |
Public Attributes | |
ref_map_type | references |
Protected Member Functions | |
template<typename Ptr > | |
bool | find_reference (const QString &type, int ref, Ptr &value) |
Protected Attributes | |
QString | file_version |
int | last_error |
QString | last_error_string |
int | version_number |
Abstract base class defining the interactions with the persistence module.
Definition at line 387 of file storage.h.
typedef ptrdiff_t storage::VVEStorage::reference_t |
Type of a reference identifier.
Reimplemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
virtual storage::VVEStorage::~VVEStorage | ( | ) | [inline, virtual] |
virtual bool storage::VVEStorage::checkNextField | ( | const QString & | name | ) | [pure virtual] |
Test if there is a field with matching name and type.
For writer, this should always return False.
Implemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
void storage::VVEStorage::clear | ( | ) | [virtual] |
Clear the internal structures of the object.
Definition at line 21 of file storage.cpp.
virtual void storage::VVEStorage::clearLastError | ( | ) | [inline, virtual] |
virtual bool storage::VVEStorage::endCompound | ( | ) | [pure virtual] |
End the current compound.
Implemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
Referenced by field().
virtual bool storage::VVEStorage::endReference | ( | ) | [pure virtual] |
Stop the current reference.
Implemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
Referenced by reference().
bool storage::VVEStorage::field | ( | const QString & | name, | |
T & | value, | |||
Model * | model | |||
) | [inline] |
Create a new field, using the model to serialize it.
name | Name of the field | |
value | Variable to associate | |
model | Model used for serialization |
Definition at line 550 of file storage.h.
References endCompound(), QString::isEmpty(), Model::serialize(), and startCompound().
00551 { 00552 bool result = false; 00553 bool no_name = name.isEmpty(); 00554 if(startCompound(name)) 00555 { 00556 result = model->serialize(*this, value); 00557 result &= endCompound(); 00558 } 00559 return result; 00560 }
bool storage::VVEStorage::field | ( | const QString & | name, | |
T & | value | |||
) | [inline] |
Create a new field.
name | Name of the field | |
value | Variable to associate |
Definition at line 526 of file storage.h.
References endCompound(), storage::serialization(), and startCompound().
00527 { 00528 bool result = false; 00529 if(startCompound(name)) 00530 { 00531 result = serialization(*this, value); 00532 if(!result) 00533 return false; 00534 result &= endCompound(); 00535 } 00536 return result; 00537 }
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
std::string & | value | |||
) | [pure virtual] |
Create a std::string field.
Create a QString field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
long double & | value | |||
) | [pure virtual] |
Create a long double field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
double & | value | |||
) | [pure virtual] |
Create a double field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
float & | value | |||
) | [pure virtual] |
Create a float field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
unsigned long long & | value | |||
) | [pure virtual] |
Create a unsigned long long integer field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
unsigned long & | value | |||
) | [pure virtual] |
Create a unsigned long integer field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
unsigned int & | value | |||
) | [pure virtual] |
Create an unsigned integer field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
unsigned short & | value | |||
) | [pure virtual] |
Create a unsigned short integer field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
unsigned char & | value | |||
) | [pure virtual] |
Create a unsigned char field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
long long & | value | |||
) | [pure virtual] |
Create a long long integer field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
long & | value | |||
) | [pure virtual] |
Create a long integer field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
int & | value | |||
) | [pure virtual] |
Create an integer field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
short & | value | |||
) | [pure virtual] |
Create a short integer field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
signed char & | value | |||
) | [pure virtual] |
Create a signed char field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
char & | value | |||
) | [pure virtual] |
Create a char field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
wchar_t & | value | |||
) | [pure virtual] |
Create a wchar_t field.
virtual bool storage::VVEStorage::field | ( | const QString & | name, | |
bool & | value | |||
) | [pure virtual] |
Create a boolean field.
Referenced by reference(), vvcomplex::VVComplex< Model, CellContent, JunctionContent, WallContent, CellEdgeContent, CellJunctionContent, JunctionCellContent, compact, LeafClass >::serialize(), cell_system::CellSystem< TissueClass, RealModel >::serialize(), cell_system::CellSystemJunction::serialize(), and cell_system::CellSystemCell::serialize().
virtual QString storage::VVEStorage::filename | ( | ) | const [pure virtual] |
Name of the file being processed.
Implemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
const QString& storage::VVEStorage::fileVersion | ( | ) | const [inline] |
virtual bool storage::VVEStorage::ignore | ( | const QString & | ) | [inline, virtual] |
Instruct a reader to ignore the next field if called name
.
This method is useful only for truly serial reader (like the BIN one)
Reimplemented in storage::VVEStorage_BINReader.
int storage::VVEStorage::lastError | ( | ) | const [inline] |
Retrieve the identifier for the last error.
QString storage::VVEStorage::lastErrorString | ( | ) | const [inline] |
virtual bool storage::VVEStorage::reader | ( | ) | [pure virtual] |
Implemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
Referenced by reference().
bool storage::VVEStorage::reference | ( | const QString & | name, | |
const QString & | type, | |||
Ptr & | value, | |||
Model * | model | |||
) | [inline] |
Create a reference to a field, using the model to serialize it.
The value is supposed to be a pointer on the variable, not the variable itself.
Definition at line 598 of file storage.h.
References endReference(), field(), reader(), and startReference().
00599 { 00600 int ref = startReference(name, type, (char*)(&*value) - (char*)0); 00601 if(ref < 0) 00602 return false; 00603 if(!find_reference(type, ref, value)) 00604 { 00605 if(reader()) 00606 value = create_object(value); 00607 if(!field("", *value, model)) 00608 { 00609 return false; 00610 } 00611 references[type][ref] = make_reference(value); 00612 } 00613 return endReference(); 00614 }
bool storage::VVEStorage::reference | ( | const QString & | name, | |
const QString & | type, | |||
Ptr & | value | |||
) | [inline] |
Create a reference to a field.
The value is supposed to be a pointer on the variable, not the variable itself.
Definition at line 571 of file storage.h.
References endReference(), field(), reader(), and startReference().
00572 { 00573 int ref = startReference(name, type, (char*)(&*value) - (char*)0); 00574 if(ref < 0) 00575 return false; 00576 if(!find_reference(type, ref, value)) 00577 { 00578 if(reader()) 00579 value = create_object(value); 00580 if(!field("", *value)) 00581 { 00582 return false; 00583 } 00584 references[type][ref] = make_reference(value); 00585 } 00586 return endReference(); 00587 }
virtual bool storage::VVEStorage::serialize | ( | const QString & | filename, | |
Model * | model | |||
) | [pure virtual] |
Load or save depending on the object.
Implemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
virtual void storage::VVEStorage::setLastError | ( | int | error, | |
const QString & | error_str | |||
) | [inline, virtual] |
Change the text of the last error.
Any specific implementation might alter the text.
Reimplemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINReader, and storage::VVEStorage_XMLReader.
Definition at line 640 of file storage.h.
References storage::NO__ERROR.
Referenced by storage::VVEStorage_XMLWriter::endCompound(), storage::VVEStorage_BINWriter::endCompound(), storage::VVEStorage_XMLWriter::endReference(), storage::VVEStorage_XMLWriter::serialize(), and storage::VVEStorage_BINWriter::serialize().
00640 { if(last_error == NO__ERROR) { last_error = error; last_error_string = error_str; } }
virtual bool storage::VVEStorage::setOption | ( | int | , | |
int | ||||
) | [inline, virtual] |
Change an option.
The options are implementation-dependent. If the option is not supported, the function returns 0.
Reimplemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
virtual bool storage::VVEStorage::startCompound | ( | const QString & | name | ) | [pure virtual] |
Start a new compound.
Useful to organize complicated data structure
When writing, always returns true. When reading, returns true only if the compound exists.
Implemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
Referenced by field().
virtual int storage::VVEStorage::startReference | ( | const QString & | name, | |
const QString & | ref_type, | |||
reference_t | ref | |||
) | [pure virtual] |
Start a reference.
All operations preceding the call to stopReference should be stored in a section reserved for references.
References should be loaded only on need.
When writing, always returns true. When reading, returns true only if the reference exists. If the reference does not exist, it will create it, so the reader has to set the fields.
Implemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.
Referenced by reference().
int storage::VVEStorage::version | ( | ) | const [inline] |
virtual bool storage::VVEStorage::writer | ( | ) | [pure virtual] |
Implemented in storage::old::VVEStorage_BINReader, storage::VVEStorage_BINWriter, storage::VVEStorage_BINReader, storage::VVEStorage_XMLWriter, and storage::VVEStorage_XMLReader.