Envision
A visual programming IDE for object-oriented languages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
FilePersistence::SimpleTextFileStore Class Reference
Inheritance diagram for FilePersistence::SimpleTextFileStore:
Model::PersistentStore

Public Types

using FileGetterFunction = std::function< bool(QString filename, const char *&data, int &dataLength)>
 

Public Member Functions

 SimpleTextFileStore (const QString &baseDir=QString())
 TODO the Envision folder should be taken from the environment not hardcoded. More...
 
 SimpleTextFileStore (FileGetterFunction fileGetter)
 
 SimpleTextFileStore (GenericTree *externalTree)
 
virtual ~SimpleTextFileStore ()
 
virtual SimpleTextFileStoreclone () const override
 
virtual QString currentNodeType () const override
 
virtual bool isLoadingPartially () const override
 
virtual QList< Model::LoadedNodeloadAllSubNodes (Model::Node *parent, const QSet< QString > &loadPartially) override
 
virtual double loadDoubleValue () override
 
virtual int loadIntValue () override
 
virtual QString loadReferenceValue (Model::Reference *r) override
 Returns a null string if the reference is resolved and a symbolic name if the reference is unresolved. More...
 
virtual QString loadStringValue () override
 
virtual Model::NodeloadSubNode (Model::Node *parent, const QString &name, bool loadPartially) override
 
virtual void saveDoubleValue (double value) override
 
virtual void saveIntValue (int value) override
 
virtual void saveNode (const Model::Node *node, const QString &name) override
 
virtual void saveReferenceValue (const QString &name, const Model::Node *target) override
 
virtual void saveStringValue (const QString &value) override
 Methods from Persistent Store. More...
 
void setBaseFolder (const QString &baseFolder)
 
- Public Member Functions inherited from Model::PersistentStore
virtual ~PersistentStore ()
 

Static Public Member Functions

static void saveGenericTree (std::shared_ptr< GenericTree > tree, const QString &name, const QString &destDir, const QStringList &persistentUnitTypes)
 
static void setForceSinglePersistentUnit ()
 

Protected Member Functions

virtual Model::NodeloadTree (Model::TreeManager *manager, const QString &name, bool loadPartially) override
 
virtual void saveTree (Model::TreeManager *manager, const QString &name) override
 
- Protected Member Functions inherited from Model::PersistentStore
void setReferenceTargetr (Reference *r, Node *target)
 

Private Member Functions

void checkIsWorking () const
 
QString getPersistenceUnitName (const Model::Node *node)
 Returns the name of the persistent unit that corresponds to the specified node. More...
 
Model::LoadedNode loadNewPersistenceUnit (const QString &name, Model::Node *parent, QString relativeFilePath, bool loadPartially)
 
Model::LoadedNode loadNode (Model::Node *parent, bool loadPartially)
 
void saveNewPersistenceUnit (const Model::Node *node, const QString &name)
 
void saveNodeDirectly (const Model::Node *node, const QString &name)
 

Static Private Member Functions

static QString relativeDirectoryPathForPersistenceUnit (const Model::Node *node)
 Returns the relative directory path to a persistent unit. More...
 
static QList< GenericNode * > writeGenericNodeToFile (GenericNode *node, const QString &destDir, const QString &fileName, const QStringList &persistentUnitTypes)
 

Private Attributes

QDir baseFolder_
 The folder where all trees are stored. More...
 
GenericTreeexternalTree_ {}
 If the tree is external, only loading is supported and the tree will not be deleted. More...
 
FileGetterFunction fileGetter_ {}
 If specified, this function will be used to get the data of the files. More...
 
GenericNodegenericNode_ {}
 
GenericTreegenericTree_ {}
 
std::set< QString > newFiles_
 
std::set< QString > oldFiles_
 
bool partiallyLoadingATree_ {}
 
QMutex storeAccess_
 A mutex that assures exclusive tree saving and loading operations. More...
 
QStack< QDir > treeDirs_
 This is a stack of the the folder where the current tree is being saved to or loaded from. More...
 
Model::TreeManagertreeManager_ {}
 The manager that requested the last load/save operation. More...
 
QList< QPair< Model::Reference *, QString > > uninitializedReferences_
 This is a list of all references which have been constructed and which have a target that is not yet set. More...
 
bool working_ {}
 A flag that indicates if the store is currently in the middle of saving or loading a tree. More...
 

Static Private Attributes

static bool ForceSinglePersistentUnit {false}
 If true, only a single persistent unit will be generated. More...
 
static const QString NULL_STRING {"____NULL____"}
 

Member Typedef Documentation

◆ FileGetterFunction

using FilePersistence::SimpleTextFileStore::FileGetterFunction = std::function<bool (QString filename, const char*& data, int& dataLength)>

Constructor & Destructor Documentation

◆ SimpleTextFileStore() [1/3]

FilePersistence::SimpleTextFileStore::SimpleTextFileStore ( const QString &  baseDir = QString())

TODO the Envision folder should be taken from the environment not hardcoded.

◆ SimpleTextFileStore() [2/3]

FilePersistence::SimpleTextFileStore::SimpleTextFileStore ( FileGetterFunction  fileGetter)

◆ SimpleTextFileStore() [3/3]

FilePersistence::SimpleTextFileStore::SimpleTextFileStore ( GenericTree externalTree)

◆ ~SimpleTextFileStore()

FilePersistence::SimpleTextFileStore::~SimpleTextFileStore ( )
virtual

Member Function Documentation

◆ checkIsWorking()

void FilePersistence::SimpleTextFileStore::checkIsWorking ( ) const
private

◆ clone()

SimpleTextFileStore * FilePersistence::SimpleTextFileStore::clone ( ) const
overridevirtual

◆ currentNodeType()

QString FilePersistence::SimpleTextFileStore::currentNodeType ( ) const
overridevirtual

◆ getPersistenceUnitName()

QString FilePersistence::SimpleTextFileStore::getPersistenceUnitName ( const Model::Node node)
private

Returns the name of the persistent unit that corresponds to the specified node.

◆ isLoadingPartially()

bool FilePersistence::SimpleTextFileStore::isLoadingPartially ( ) const
overridevirtual

◆ loadAllSubNodes()

QList< Model::LoadedNode > FilePersistence::SimpleTextFileStore::loadAllSubNodes ( Model::Node parent,
const QSet< QString > &  loadPartially 
)
overridevirtual

◆ loadDoubleValue()

double FilePersistence::SimpleTextFileStore::loadDoubleValue ( )
overridevirtual

◆ loadIntValue()

int FilePersistence::SimpleTextFileStore::loadIntValue ( )
overridevirtual

◆ loadNewPersistenceUnit()

Model::LoadedNode FilePersistence::SimpleTextFileStore::loadNewPersistenceUnit ( const QString &  name,
Model::Node parent,
QString  relativeFilePath,
bool  loadPartially 
)
private

◆ loadNode()

Model::LoadedNode FilePersistence::SimpleTextFileStore::loadNode ( Model::Node parent,
bool  loadPartially 
)
private

◆ loadReferenceValue()

QString FilePersistence::SimpleTextFileStore::loadReferenceValue ( Model::Reference r)
overridevirtual

Returns a null string if the reference is resolved and a symbolic name if the reference is unresolved.

After the target of the reference exists in memory, the reference will be updated to point to the correct target.

Implements Model::PersistentStore.

◆ loadStringValue()

QString FilePersistence::SimpleTextFileStore::loadStringValue ( )
overridevirtual

◆ loadSubNode()

Model::Node * FilePersistence::SimpleTextFileStore::loadSubNode ( Model::Node parent,
const QString &  name,
bool  loadPartially 
)
overridevirtual

◆ loadTree()

Model::Node * FilePersistence::SimpleTextFileStore::loadTree ( Model::TreeManager manager,
const QString &  name,
bool  loadPartially 
)
overrideprotectedvirtual

◆ relativeDirectoryPathForPersistenceUnit()

QString FilePersistence::SimpleTextFileStore::relativeDirectoryPathForPersistenceUnit ( const Model::Node node)
staticprivate

Returns the relative directory path to a persistent unit.

◆ saveDoubleValue()

void FilePersistence::SimpleTextFileStore::saveDoubleValue ( double  value)
overridevirtual

◆ saveGenericTree()

void FilePersistence::SimpleTextFileStore::saveGenericTree ( std::shared_ptr< GenericTree tree,
const QString &  name,
const QString &  destDir,
const QStringList &  persistentUnitTypes 
)
static

◆ saveIntValue()

void FilePersistence::SimpleTextFileStore::saveIntValue ( int  value)
overridevirtual

◆ saveNewPersistenceUnit()

void FilePersistence::SimpleTextFileStore::saveNewPersistenceUnit ( const Model::Node node,
const QString &  name 
)
private

◆ saveNode()

void FilePersistence::SimpleTextFileStore::saveNode ( const Model::Node node,
const QString &  name 
)
overridevirtual

◆ saveNodeDirectly()

void FilePersistence::SimpleTextFileStore::saveNodeDirectly ( const Model::Node node,
const QString &  name 
)
private

◆ saveReferenceValue()

void FilePersistence::SimpleTextFileStore::saveReferenceValue ( const QString &  name,
const Model::Node target 
)
overridevirtual

◆ saveStringValue()

void FilePersistence::SimpleTextFileStore::saveStringValue ( const QString &  value)
overridevirtual

Methods from Persistent Store.

Implements Model::PersistentStore.

◆ saveTree()

void FilePersistence::SimpleTextFileStore::saveTree ( Model::TreeManager manager,
const QString &  name 
)
overrideprotectedvirtual

◆ setBaseFolder()

void FilePersistence::SimpleTextFileStore::setBaseFolder ( const QString &  baseFolder)

◆ setForceSinglePersistentUnit()

void FilePersistence::SimpleTextFileStore::setForceSinglePersistentUnit ( )
inlinestatic

◆ writeGenericNodeToFile()

QList< GenericNode * > FilePersistence::SimpleTextFileStore::writeGenericNodeToFile ( GenericNode node,
const QString &  destDir,
const QString &  fileName,
const QStringList &  persistentUnitTypes 
)
staticprivate

Member Data Documentation

◆ baseFolder_

QDir FilePersistence::SimpleTextFileStore::baseFolder_
private

The folder where all trees are stored.

Each tree is a separate sub folder in the base folder.

◆ externalTree_

GenericTree* FilePersistence::SimpleTextFileStore::externalTree_ {}
private

If the tree is external, only loading is supported and the tree will not be deleted.

◆ fileGetter_

FileGetterFunction FilePersistence::SimpleTextFileStore::fileGetter_ {}
private

If specified, this function will be used to get the data of the files.

Only used for loading.

◆ ForceSinglePersistentUnit

bool FilePersistence::SimpleTextFileStore::ForceSinglePersistentUnit {false}
staticprivate

If true, only a single persistent unit will be generated.

◆ genericNode_

GenericNode* FilePersistence::SimpleTextFileStore::genericNode_ {}
private

◆ genericTree_

GenericTree* FilePersistence::SimpleTextFileStore::genericTree_ {}
private

◆ newFiles_

std::set<QString> FilePersistence::SimpleTextFileStore::newFiles_
private

◆ NULL_STRING

const QString FilePersistence::SimpleTextFileStore::NULL_STRING {"____NULL____"}
staticprivate

◆ oldFiles_

std::set<QString> FilePersistence::SimpleTextFileStore::oldFiles_
private

◆ partiallyLoadingATree_

bool FilePersistence::SimpleTextFileStore::partiallyLoadingATree_ {}
private

◆ storeAccess_

QMutex FilePersistence::SimpleTextFileStore::storeAccess_
private

A mutex that assures exclusive tree saving and loading operations.

◆ treeDirs_

QStack<QDir> FilePersistence::SimpleTextFileStore::treeDirs_
private

This is a stack of the the folder where the current tree is being saved to or loaded from.

This is only valid if working is true.

◆ treeManager_

Model::TreeManager* FilePersistence::SimpleTextFileStore::treeManager_ {}
private

The manager that requested the last load/save operation.

◆ uninitializedReferences_

QList<QPair<Model::Reference*, QString> > FilePersistence::SimpleTextFileStore::uninitializedReferences_
private

This is a list of all references which have been constructed and which have a target that is not yet set.

The second part of the pair is the target id.

◆ working_

bool FilePersistence::SimpleTextFileStore::working_ {}
private

A flag that indicates if the store is currently in the middle of saving or loading a tree.