Envision
A visual programming IDE for object-oriented languages
|
TODO It might be good to separate trees with piecewise loaders and other "kinds" of trees into subclasses. More...
Public Member Functions | |
GenericTree (QString name=QString{}) | |
~GenericTree () | |
void | buildLookupHash () |
GenericNode * | find (Model::NodeIdType id, bool lazyLoad=false, bool mayNotExist=false) const |
Returns the node in this tree with the ID id or nullptr if no such node exists. More... | |
const QString & | name () const |
GenericPersistentUnit & | newPersistentUnit (QString name, char *data=nullptr, int dataSize=0) |
GenericPersistentUnit * | persistentUnit (const QString &name, bool partial=false) const |
QList< std::shared_ptr< GenericPersistentUnit > > | persistentUnits () const |
bool | remove (Model::NodeIdType id, bool recursive=false) |
void | removePersistentUnit (const GenericPersistentUnit &unit) |
void | removePersistentUnit (const QString &persistentUnitName) |
GenericNode * | root () const |
void | setPiecewiseLoader (std::shared_ptr< PiecewiseLoader > loader) |
Private Member Functions | |
GenericNode * | emptyChunk () |
QMultiHash< Model::NodeIdType, GenericNode * > & | nodesWithoutParents () |
const std::shared_ptr< PiecewiseLoader > & | piecewiseLoader () const |
void | releaseChunk (GenericNode *unusedChunk) |
Private Attributes | |
QList< GenericNode * > | emptyChunks_ |
bool | hasQuickLookupHash_ {} |
QString | name_ |
QMultiHash< Model::NodeIdType, GenericNode * > | nodesWithoutParents_ |
If this tree has a piecewise loader, this hash maps IDs of unloaded nodes to all nodes whose parentId = ID. More... | |
QHash< QString, std::shared_ptr< GenericPersistentUnit > > | persistentUnits_ |
std::shared_ptr< PiecewiseLoader > | piecewiseLoader_ |
QHash< Model::NodeIdType, GenericNode * > | quickLookupHash_ |
Static Private Attributes | |
static constexpr int | ALLOCATION_CHUNK_SIZE = 1000 |
num elements to allocate at once More... | |
Friends | |
class | GenericNode |
class | GenericPersistentUnit |
class | PiecewiseLoader |
TODO It might be good to separate trees with piecewise loaders and other "kinds" of trees into subclasses.
FilePersistence::GenericTree::GenericTree | ( | QString | name = QString{} | ) |
FilePersistence::GenericTree::~GenericTree | ( | ) |
void FilePersistence::GenericTree::buildLookupHash | ( | ) |
|
private |
GenericNode * FilePersistence::GenericTree::find | ( | Model::NodeIdType | id, |
bool | lazyLoad = false , |
||
bool | mayNotExist = false |
||
) | const |
Returns the node in this tree with the ID id or nullptr if no such node exists.
If lazyLoad is true, this attempts to lazy-load the node if it does not exist yet.
For trees without a piecewise loader, this will perform a depth first search for the node from the root recursively in all linked nodes. This means on such trees, this method is slow and might not return the node if it's not linked, even if it is loaded in the tree.
If mayNotExist is false (the default) the lazy loader will fail if the node is not found.
|
inline |
GenericPersistentUnit & FilePersistence::GenericTree::newPersistentUnit | ( | QString | name, |
char * | data = nullptr , |
||
int | dataSize = 0 |
||
) |
|
private |
GenericPersistentUnit * FilePersistence::GenericTree::persistentUnit | ( | const QString & | name, |
bool | partial = false |
||
) | const |
|
inline |
|
private |
|
private |
bool FilePersistence::GenericTree::remove | ( | Model::NodeIdType | id, |
bool | recursive = false |
||
) |
|
inline |
|
inline |
GenericNode * FilePersistence::GenericTree::root | ( | ) | const |
void FilePersistence::GenericTree::setPiecewiseLoader | ( | std::shared_ptr< PiecewiseLoader > | loader | ) |
|
friend |
|
friend |
|
friend |
|
staticconstexprprivate |
num elements to allocate at once
|
private |
|
private |
|
private |
|
private |
If this tree has a piecewise loader, this hash maps IDs of unloaded nodes to all nodes whose parentId = ID.
If this tree does not have a piecewise loader, this is empty.
|
private |
|
private |
|
private |