ALBA
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
albaStorageElement Class Referenceabstract

#include <albaStorageElement.h>

Inheritance diagram for albaStorageElement:
Inheritance graph
[legend]
Collaboration diagram for albaStorageElement:
Collaboration graph
[legend]

Public Types

typedef std::vector< albaStorageElement * > ChildrenVector
 

Public Member Functions

virtual ~albaStorageElement ()
 
virtual const char * GetName ()=0
 
virtual void SetAttribute (const char *name, const char *value)=0
 
void SetAttribute (const char *name, const albaID value)
 
void SetAttribute (const char *name, const double value)
 
virtual bool GetAttribute (const char *name, albaString &value)=0
 
bool GetAttributeAsDouble (const char *name, double &value)
 
bool GetAttributeAsInteger (const char *name, albaID &value)
 
albaString UpgradeAttribute (const char *attribute)
 
virtual int StoreText (const char *name, const char *text)=0
 
virtual int StoreMatrix (const char *name, const albaMatrix *matrix)=0
 
virtual int StoreVectorN (const char *name, double *comps, int num)=0
 
virtual int StoreVectorN (const char *name, int *comps, int num)=0
 
virtual int StoreVectorN (const char *name, const std::vector< double > &comps, int num)=0
 
virtual int StoreVectorN (const char *name, const std::vector< int > &comps, int num)=0
 
virtual int StoreVectorN (const char *name, const std::vector< albaString > &comps, int num, const char *tag)=0
 
int RestoreMatrix (const char *name, albaMatrix *matrix)
 
int RestoreVectorN (const char *name, double *comps, unsigned int num)
 
int RestoreVectorN (const char *name, int *comps, unsigned int num)
 
int RestoreVectorN (const char *name, std::vector< double > &comps, unsigned int num)
 
int RestoreVectorN (const char *name, std::vector< int > &comps, unsigned int num)
 
int RestoreVectorN (const char *name, std::vector< albaString > &comps, unsigned int num, const char *tag)
 
int RestoreText (const char *name, char *&buffer)
 
int RestoreText (const char *name, albaString &buffer)
 
virtual int RestoreMatrix (albaMatrix *matrix)=0
 
virtual int RestoreVectorN (double *comps, unsigned int num)=0
 
virtual int RestoreVectorN (int *comps, unsigned int num)=0
 
virtual int RestoreVectorN (std::vector< double > &comps, unsigned int num)=0
 
virtual int RestoreVectorN (std::vector< int > &comps, unsigned int num)=0
 
virtual int RestoreVectorN (std::vector< albaString > &comps, unsigned int num, const char *tag)=0
 
virtual int RestoreText (albaString &buffer)=0
 
virtual int RestoreText (char *&buffer)
 
int StoreDouble (const char *name, const double &value)
 
int RestoreDouble (const char *name, double &value)
 
int RestoreDouble (double &value)
 
int StoreInteger (const char *name, const int &value)
 
int RestoreInteger (const char *name, int &value)
 
int RestoreInteger (int &value)
 
int RestoreObject (const char *name, albaStorable *object)
 
albaObjectRestoreObject (const char *name)
 
albaObjectRestoreObject ()
 
albaStorageElementStoreObject (const char *name, albaObject *object)
 
virtual int StoreObjectVector (const char *name, const std::vector< albaObject * > &vector, const char *items_name="Item")
 
virtual int RestoreObjectVector (const char *name, std::vector< albaObject * > &vector, const char *items_name="Item")
 
virtual int RestoreObjectVector (albaStorageElement *element, std::vector< albaObject * > &vector, const char *items_name="Item")
 
albaStorageGetStorage ()
 
albaStorageElementGetParent ()
 
virtual albaStorageElementAppendChild (const char *name)=0
 
virtual albaStorageElementFindNestedElement (const char *name)
 
virtual ChildrenVectorGetChildren ()=0
 
virtual bool GetNestedElementsByName (const char *name, std::vector< albaStorageElement * > &list)
 

Protected Member Functions

 albaStorageElement (albaStorageElement *parent, albaStorage *storage)
 
albaStorageElementStoreObject (const char *name, albaStorable *storable, const char *type_name)
 
void SetStorage (albaStorage *storage)
 
void SetParent (albaStorageElement *element)
 

Protected Attributes

albaStoragem_Storage
 
albaStorageElementm_Parent
 
std::vector< albaStorageElement * > * m_Children
 

Detailed Description

Abstract class representing the interface for the unit of information stored in the storage.

Abstract class representing the interface for the unit of information stored into a storage. A number of utility functions are defined to store and restore basic objects into the element. More complex serialization algorithms can be implemented by specific "serializable" objects. Among the others, the RestoreObject() function is a function which try to restore a albaObject from element, by creating a new instance from the object factory, taking the object name from the "Type" attribute, and then calling the Restore function of the newly create object. The newly created object must also be a "albaStorable" to support the Restore() function. This abstract class does not implement any real encoding, and subclasses can define specialized de/serialization algorithm.

See also
albaXMLStorage albaStorageElement albaXMLElement albaStorable
Todo:
  • reimplement children list as a map

Definition at line 45 of file albaStorageElement.h.

Member Typedef Documentation

◆ ChildrenVector

Definition at line 175 of file albaStorageElement.h.

Constructor & Destructor Documentation

◆ ~albaStorageElement()

virtual albaStorageElement::~albaStorageElement ( )
virtual

◆ albaStorageElement()

albaStorageElement::albaStorageElement ( albaStorageElement parent,
albaStorage storage 
)
protected

elements can be created only by means of AppendChild() or FindNestedElement()

Member Function Documentation

◆ GetName()

virtual const char * albaStorageElement::GetName ( )
pure virtual

get the name of this element.

The element name is set at creation time (

See also
AppendChild())

Implemented in albaXMLElement.

◆ SetAttribute() [1/3]

virtual void albaStorageElement::SetAttribute ( const char *  name,
const char *  value 
)
pure virtual

Set an attribute of this element.

Attribute 'name' and 'value' must be passed as argument.

Implemented in albaXMLElement.

◆ SetAttribute() [2/3]

void albaStorageElement::SetAttribute ( const char *  name,
const albaID  value 
)

◆ SetAttribute() [3/3]

void albaStorageElement::SetAttribute ( const char *  name,
const double  value 
)

◆ GetAttribute()

virtual bool albaStorageElement::GetAttribute ( const char *  name,
albaString value 
)
pure virtual

Return an attribute value given its name.

Return false if not found.

Implemented in albaXMLElement.

◆ GetAttributeAsDouble()

bool albaStorageElement::GetAttributeAsDouble ( const char *  name,
double &  value 
)

Return an attribute value given its name, converting it to double.

Return false if attribute is not found.

◆ GetAttributeAsInteger()

bool albaStorageElement::GetAttributeAsInteger ( const char *  name,
albaID value 
)

Return an attribute value given its name, converting it to integer.

Return false if attribute is not found.

◆ UpgradeAttribute()

albaString albaStorageElement::UpgradeAttribute ( const char *  attribute)

Used to upgrade attribute value from previous MSF file version.

◆ StoreText()

virtual int albaStorageElement::StoreText ( const char *  name,
const char *  text 
)
pure virtual

Implemented in albaXMLElement.

◆ StoreMatrix()

virtual int albaStorageElement::StoreMatrix ( const char *  name,
const albaMatrix matrix 
)
pure virtual

Implemented in albaXMLElement.

◆ StoreVectorN() [1/5]

virtual int albaStorageElement::StoreVectorN ( const char *  name,
double *  comps,
int  num 
)
pure virtual

Implemented in albaXMLElement.

◆ StoreVectorN() [2/5]

virtual int albaStorageElement::StoreVectorN ( const char *  name,
int *  comps,
int  num 
)
pure virtual

Implemented in albaXMLElement.

◆ StoreVectorN() [3/5]

virtual int albaStorageElement::StoreVectorN ( const char *  name,
const std::vector< double > &  comps,
int  num 
)
pure virtual

Implemented in albaXMLElement.

◆ StoreVectorN() [4/5]

virtual int albaStorageElement::StoreVectorN ( const char *  name,
const std::vector< int > &  comps,
int  num 
)
pure virtual

Implemented in albaXMLElement.

◆ StoreVectorN() [5/5]

virtual int albaStorageElement::StoreVectorN ( const char *  name,
const std::vector< albaString > &  comps,
int  num,
const char *  tag 
)
pure virtual

store a vector of strings into an XML element, and stores single items in "tag" sub elements

Implemented in albaXMLElement.

◆ RestoreMatrix() [1/2]

int albaStorageElement::RestoreMatrix ( const char *  name,
albaMatrix matrix 
)

Store 8bit binary data.

Not yet supported. Store 16bit binary data. Not yet supported. Store 32bit binary data. Not yet supported. Restore 8bit binary data. Not yet supported. Restore 16bit binary data. Not yet supported. Restore 32bit binary data. Not yet supported.

◆ RestoreVectorN() [1/10]

int albaStorageElement::RestoreVectorN ( const char *  name,
double *  comps,
unsigned int  num 
)

◆ RestoreVectorN() [2/10]

int albaStorageElement::RestoreVectorN ( const char *  name,
int *  comps,
unsigned int  num 
)

◆ RestoreVectorN() [3/10]

int albaStorageElement::RestoreVectorN ( const char *  name,
std::vector< double > &  comps,
unsigned int  num 
)

◆ RestoreVectorN() [4/10]

int albaStorageElement::RestoreVectorN ( const char *  name,
std::vector< int > &  comps,
unsigned int  num 
)

◆ RestoreVectorN() [5/10]

int albaStorageElement::RestoreVectorN ( const char *  name,
std::vector< albaString > &  comps,
unsigned int  num,
const char *  tag 
)

restore a vector of strings from an XML element, where single items are stored in "tag" sub elements

◆ RestoreText() [1/4]

int albaStorageElement::RestoreText ( const char *  name,
char *&  buffer 
)

◆ RestoreText() [2/4]

int albaStorageElement::RestoreText ( const char *  name,
albaString buffer 
)

◆ RestoreMatrix() [2/2]

virtual int albaStorageElement::RestoreMatrix ( albaMatrix matrix)
pure virtual

Implemented in albaXMLElement.

◆ RestoreVectorN() [6/10]

virtual int albaStorageElement::RestoreVectorN ( double *  comps,
unsigned int  num 
)
pure virtual

Implemented in albaXMLElement.

◆ RestoreVectorN() [7/10]

virtual int albaStorageElement::RestoreVectorN ( int *  comps,
unsigned int  num 
)
pure virtual

Implemented in albaXMLElement.

◆ RestoreVectorN() [8/10]

virtual int albaStorageElement::RestoreVectorN ( std::vector< double > &  comps,
unsigned int  num 
)
pure virtual

Implemented in albaXMLElement.

◆ RestoreVectorN() [9/10]

virtual int albaStorageElement::RestoreVectorN ( std::vector< int > &  comps,
unsigned int  num 
)
pure virtual

Implemented in albaXMLElement.

◆ RestoreVectorN() [10/10]

virtual int albaStorageElement::RestoreVectorN ( std::vector< albaString > &  comps,
unsigned int  num,
const char *  tag 
)
pure virtual

restore a vector of strings from an XML element, where single items are stored in "tag" sub elements

Implemented in albaXMLElement.

◆ RestoreText() [3/4]

virtual int albaStorageElement::RestoreText ( albaString buffer)
pure virtual

Implemented in albaXMLElement.

◆ RestoreText() [4/4]

virtual int albaStorageElement::RestoreText ( char *&  buffer)
virtual

◆ StoreDouble()

int albaStorageElement::StoreDouble ( const char *  name,
const double &  value 
)

◆ RestoreDouble() [1/2]

int albaStorageElement::RestoreDouble ( const char *  name,
double &  value 
)

◆ RestoreDouble() [2/2]

int albaStorageElement::RestoreDouble ( double &  value)

◆ StoreInteger()

int albaStorageElement::StoreInteger ( const char *  name,
const int &  value 
)

◆ RestoreInteger() [1/2]

int albaStorageElement::RestoreInteger ( const char *  name,
int &  value 
)

◆ RestoreInteger() [2/2]

int albaStorageElement::RestoreInteger ( int &  value)

◆ RestoreObject() [1/3]

int albaStorageElement::RestoreObject ( const char *  name,
albaStorable object 
)

Function to try restoring a albaObject from a albaStorageElement.

If the element has an attribute with name "Type", the function try to instantiate an object with the same name and to restore it from the element. In case of problems the function return NULL. The new object is always created by means of New(), this way in case of smart object it can be registered. The object to be restored must be both a albaObject (to stay in the object factory) and a albaStorable to support Restore() method.

◆ RestoreObject() [2/3]

albaObject * albaStorageElement::RestoreObject ( const char *  name)

Restore object from given element.

See also
RestoreObject(const char *name,albaObject *&)

◆ RestoreObject() [3/3]

albaObject * albaStorageElement::RestoreObject ( )

Restore object from given element.

See also
RestoreObject(const char *name,albaObject *&)

◆ StoreObject() [1/2]

albaStorageElement * albaStorageElement::StoreObject ( const char *  name,
albaObject object 
)

Used for storing a albaObjects.

The function simply creates a new element with given 'name' and add an attribute with name 'Type' storing the object name. Then the function calls the Store function of the object. The object must be a storable object to support Store() interface. The newly stored element is returned if OK, NULL in case of problems

◆ StoreObjectVector()

virtual int albaStorageElement::StoreObjectVector ( const char *  name,
const std::vector< albaObject * > &  vector,
const char *  items_name = "Item" 
)
virtual

Store a vector of objects.

Objects must be both albaObject and albaStorable

See also
StoreObject()

◆ RestoreObjectVector() [1/2]

virtual int albaStorageElement::RestoreObjectVector ( const char *  name,
std::vector< albaObject * > &  vector,
const char *  items_name = "Item" 
)
virtual

Restore a vector of objects.

Objects must be both albaObject and albaStorable

See also
RestoreObject()

◆ RestoreObjectVector() [2/2]

virtual int albaStorageElement::RestoreObjectVector ( albaStorageElement element,
std::vector< albaObject * > &  vector,
const char *  items_name = "Item" 
)
virtual

Restore a vector of objects.

Objects must be both albaObject and albaStorable

See also
RestoreObject()

◆ GetStorage()

albaStorage * albaStorageElement::GetStorage ( )
inline

return a pointer to the storage who created this element

Definition at line 162 of file albaStorageElement.h.

◆ GetParent()

albaStorageElement * albaStorageElement::GetParent ( )
inline

return a pointer to the parent element, i.e.

the element upper in the hierarchy

Definition at line 165 of file albaStorageElement.h.

◆ AppendChild()

virtual albaStorageElement * albaStorageElement::AppendChild ( const char *  name)
pure virtual

Create a new child element and return its pointer.

This is the only way to create a new element. The first element (the root) is automatically created by storage object.

Implemented in albaXMLElement.

◆ FindNestedElement()

virtual albaStorageElement * albaStorageElement::FindNestedElement ( const char *  name)
virtual

Find a nested element by Name.

◆ GetChildren()

virtual ChildrenVector & albaStorageElement::GetChildren ( )
pure virtual

Return the list of children.

Subclasses must implement this to build the children list.

Implemented in albaXMLElement.

◆ GetNestedElementsByName()

virtual bool albaStorageElement::GetNestedElementsByName ( const char *  name,
std::vector< albaStorageElement * > &  list 
)
virtual

Return the list of all children with a given name.

return true if at least one found.

◆ StoreObject() [2/2]

albaStorageElement * albaStorageElement::StoreObject ( const char *  name,
albaStorable storable,
const char *  type_name 
)
protected

commodity function to store a storable object creating on the fly the element to store it inside.

◆ SetStorage()

void albaStorageElement::SetStorage ( albaStorage storage)
inlineprotected

Definition at line 193 of file albaStorageElement.h.

◆ SetParent()

void albaStorageElement::SetParent ( albaStorageElement element)
inlineprotected

Definition at line 194 of file albaStorageElement.h.

Member Data Documentation

◆ m_Storage

albaStorage* albaStorageElement::m_Storage
protected

storage who created this element

Definition at line 196 of file albaStorageElement.h.

◆ m_Parent

albaStorageElement* albaStorageElement::m_Parent
protected

the parent element in the hierarchy

Definition at line 197 of file albaStorageElement.h.

◆ m_Children

std::vector<albaStorageElement *>* albaStorageElement::m_Children
protected

children elements

Definition at line 198 of file albaStorageElement.h.


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