BlueBerry
A modular, cross-platform, C++ application framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
berry::IMemento Struct Reference

#include <berryIMemento.h>

+ Inheritance diagram for berry::IMemento:
+ Collaboration diagram for berry::IMemento:

List of all members.

Public Member Functions

virtual berryInterfaceMacro(IMemento,
berry) static const std
IMemento::Pointer 
CreateChild (const std::string &type)=0
virtual IMemento::Pointer CreateChild (const std::string &type, const std::string &id)=0
virtual IMemento::Pointer GetChild (const std::string &type) const =0
virtual std::vector
< IMemento::Pointer
GetChildren (const std::string &type) const =0
virtual bool GetFloat (const std::string &key, double &value) const =0
virtual bool GetInteger (const std::string &key, int &value) const =0
virtual bool GetString (const std::string &key, std::string &value) const =0
virtual bool GetBoolean (const std::string &key, bool &value) const =0
virtual const std::string & GetTextData () const =0
virtual std::vector< std::string > GetAttributeKeys () const =0
virtual std::string GetType () const =0
virtual std::string GetID () const =0
virtual void PutFloat (const std::string &key, double value)=0
virtual void PutInteger (const std::string &key, int value)=0
virtual void PutMemento (IMemento::Pointer memento)=0
virtual void PutString (const std::string &key, const std::string &value)=0
virtual void PutBoolean (const std::string &key, bool value)=0
virtual void PutTextData (const std::string &data)=0
virtual ~IMemento ()

Detailed Description

Interface to a memento used for saving the important state of an object in a form that can be persisted in the file system.

Mementos were designed with the following requirements in mind:

  1. Certain objects need to be saved and restored across platform sessions.
  2. When an object is restored, an appropriate class for an object might not be available. It must be possible to skip an object in this case.
  3. When an object is restored, the appropriate class for the object may be different from the one when the object was originally saved. If so, the new class should still be able to read the old form of the data.

Mementos meet these requirements by providing support for storing a mapping of arbitrary string keys to primitive values, and by allowing mementos to have other mementos as children (arranged into a tree). A robust external storage format based on XML is used.

The key for an attribute may be any alpha numeric value. However, the value of TAG_ID is reserved for internal use.

This interface is not intended to be implemented or extended by clients.

See also:
IPersistableElement
IElementFactory This interface is not intended to be implemented by clients.

Definition at line 64 of file berryIMemento.h.


Constructor & Destructor Documentation

Definition at line 23 of file berryIMemento.cpp.


Member Function Documentation

virtual berryInterfaceMacro (IMemento, berry) static const std IMemento::Pointer berry::IMemento::CreateChild ( const std::string &  type) [pure virtual]

Special reserved key used to store the memento id (value "IMemento.internal.id").

See also:
#getID() Creates a new child of this memento with the given type.

The GetChild and GetChildren methods are used to retrieve children of a given type.

Parameters:
typethe type
Returns:
a new child memento
See also:
GetChild
GetChildren
virtual IMemento::Pointer berry::IMemento::CreateChild ( const std::string &  type,
const std::string &  id 
) [pure virtual]

Creates a new child of this memento with the given type and id. The id is stored in the child memento (using a special reserved key, TAG_ID) and can be retrieved using GetID.

The GetChild and GetChildren methods are used to retrieve children of a given type.

Parameters:
typethe type
idthe child id
Returns:
a new child memento with the given type and id
See also:
GetID

Implemented in berry::XMLMemento.

virtual std::vector<std::string> berry::IMemento::GetAttributeKeys ( ) const [pure virtual]

Returns an array of all the attribute keys of the memento. This will not be null. If there are no keys, an array of length zero will be returned.

Returns:
an array with all the attribute keys of the memento

Implemented in berry::XMLMemento.

virtual bool berry::IMemento::GetBoolean ( const std::string &  key,
bool &  value 
) const [pure virtual]

Gets the boolean value of the given key.

Parameters:
keythe key
valuethe value of the given key
Returns:
false if the key was not found, else true

Implemented in berry::XMLMemento.

virtual IMemento::Pointer berry::IMemento::GetChild ( const std::string &  type) const [pure virtual]

Returns the first child with the given type id.

Parameters:
typethe type id
Returns:
the first child with the given type

Implemented in berry::XMLMemento.

virtual std::vector<IMemento::Pointer> berry::IMemento::GetChildren ( const std::string &  type) const [pure virtual]

Returns all children with the given type id.

Parameters:
typethe type id
Returns:
an array of children with the given type

Implemented in berry::XMLMemento.

virtual bool berry::IMemento::GetFloat ( const std::string &  key,
double &  value 
) const [pure virtual]

Gets the floating point value of the given key.

Parameters:
keythe key
valuethe value of the given key
Returns:
false if the key was not found or was found but was not a floating point number, else true

Implemented in berry::XMLMemento.

virtual std::string berry::IMemento::GetID ( ) const [pure virtual]

Returns the id for this memento.

Returns:
the memento id, or "" if none
See also:
CreateChild(const std::string&, const std::string&)

Implemented in berry::XMLMemento.

virtual bool berry::IMemento::GetInteger ( const std::string &  key,
int &  value 
) const [pure virtual]

Gets the integer value of the given key.

Parameters:
keythe key
valuethe value of the given key
Returns:
false if the key was not found or was found but was not an integer, else true

Implemented in berry::XMLMemento.

virtual bool berry::IMemento::GetString ( const std::string &  key,
std::string &  value 
) const [pure virtual]

Gets the string value of the given key.

Parameters:
keythe key
valuethe value of the given key
Returns:
false if the key was not found, else true

Implemented in berry::XMLMemento.

virtual const std::string& berry::IMemento::GetTextData ( ) const [pure virtual]

Returns the data of the Text node of the memento. Each memento is allowed only one Text node.

Returns:
the data of the Text node of the memento, or null if the memento has no Text node.

Implemented in berry::XMLMemento.

virtual std::string berry::IMemento::GetType ( ) const [pure virtual]

Returns the type for this memento.

Returns:
the memento type
See also:
#CreateChild(const std::string&)
CreateChild(const std::string&, const std::string&)

Implemented in berry::XMLMemento.

virtual void berry::IMemento::PutBoolean ( const std::string &  key,
bool  value 
) [pure virtual]

Sets the value of the given key to the given boolean value.

Parameters:
keythe key
valuethe value

Implemented in berry::XMLMemento.

virtual void berry::IMemento::PutFloat ( const std::string &  key,
double  value 
) [pure virtual]

Sets the value of the given key to the given floating point number.

Parameters:
keythe key
valuethe value

Implemented in berry::XMLMemento.

virtual void berry::IMemento::PutInteger ( const std::string &  key,
int  value 
) [pure virtual]

Sets the value of the given key to the given integer.

Parameters:
keythe key
valuethe value

Implemented in berry::XMLMemento.

virtual void berry::IMemento::PutMemento ( IMemento::Pointer  memento) [pure virtual]

Copy the attributes and children from memento to the receiver.

Parameters:
mementothe IMemento to be copied.

Implemented in berry::XMLMemento.

virtual void berry::IMemento::PutString ( const std::string &  key,
const std::string &  value 
) [pure virtual]

Sets the value of the given key to the given const std::string&.

Parameters:
keythe key
valuethe value

Implemented in berry::XMLMemento.

virtual void berry::IMemento::PutTextData ( const std::string &  data) [pure virtual]

Sets the memento's Text node to contain the given data. Creates the Text node if none exists. If a Text node does exist, it's current contents are replaced. Each memento is allowed only one text node.

Parameters:
datathe data to be placed on the Text node

Implemented in berry::XMLMemento.


The documentation for this struct was generated from the following files: