Workspace 6.21.5
Public Member Functions | List of all members
MeshModelLibrary Class Reference

Effectively acts like a container for MeshModelSource objects. More...

#include <Mesh/DataStructures/meshmodellibrary.h>

Public Member Functions

 MeshModelLibrary ()
 
 MeshModelLibrary (const MeshModelLibrary &)
 
 MeshModelLibrary (MeshModelLibrary &&)
 
virtual ~MeshModelLibrary ()
 
bool add (MeshModelLibrary &library)
 
bool add (MeshModelSource &source)
 
void clearSources ()
 
void clearSubLibraries ()
 
MeshModelSourcegetMeshModelSource (const QString &id) const
 
QStringList getSourceIds (bool recursive) const
 
MeshModelLibraryoperator= (MeshModelLibrary lib)
 
bool remove (const QString &id)
 
bool remove (MeshModelLibrary &library)
 
bool remove (MeshModelSource &source)
 

Detailed Description

The main purpose of this class is to provide a single place from which clients can retrieve a MeshModel with a given model id. A MeshModelLibrary can hold other MeshModelLibrary instances, searching recursively (depth first) for a requested model id.

Constructor & Destructor Documentation

◆ MeshModelLibrary() [1/3]

Creates an empty library.

◆ MeshModelLibrary() [2/3]

Parameters
libThe library to make a copy of.

When lib is copied, the items it contains are not copied. Instead, the new MeshModelLibrary instance will hold references to the same things as lib. Therefore, the client needs to ensure that these contents remain valid for as long as the copy is in use. In particular, if lib is rebuilt as a result of a workspace operation's inputs being updated, the original copy of it should also be updated to prevent that copy from trying to use objects which might no longer exist.

◆ MeshModelLibrary() [3/3]

Parameters
libThe library to make a copy of

◆ ~MeshModelLibrary()

~MeshModelLibrary ( )
virtual

The destructor destroys the library, but not the things it contains.

Member Function Documentation

◆ add() [1/2]

bool add ( MeshModelLibrary library)
Parameters
libraryThe sub-library to add to this library.
Returns
True if library could be added or false if it is already a direct sub-library of this one.

◆ add() [2/2]

bool add ( MeshModelSource source)
Parameters
sourceThe model source to add to the library.

If a source with the same id as source is already present in the library, this function will not add source. Instead, the old source is retained and the function returns false. Note that this test is only performed for model sources held directly by this library, not for any of the sub-libraries it also might hold. This allows a library to provide model sources which override those specified in any sub-libraries.

Returns
True if source could be added.

◆ clearSources()

void clearSources ( )

Clears all model sources from the library. Note that the model sources are not deleted. This function merely clears the list of sources the library keeps internally.

◆ clearSubLibraries()

void clearSubLibraries ( )

Clears all sub-libraries from this library. Note that the sub-libraries are not deleted. This function merely clears the list of sub-libraries this library keeps internally.

◆ getMeshModelSource()

MeshModelSource * getMeshModelSource ( const QString &  id) const
Parameters
idThe id of the model source to retrieve.
Returns
The mesh model source corresponding to the specified model id, or a null pointer if no such model source could be found. Note that if a sub-library supplies a source for a given id but for some reason the source fails to generate a model, any source in any other sub-library which also matches the id will never be seen. The first source matching id is always returned whether or not it is able to successfully obtain a model (since this is not usually known at the time getMeshModelSource() is called).

◆ getSourceIds()

QStringList getSourceIds ( bool  recursive) const
Parameters
recursiveWhether or not to recursively retrieve IDs from sub-libraries.
Returns
A QStringList containing the IDs of all MeshModelSource objects contained within this MeshModelLibrary (and optionally its child libraries).

◆ operator=()

MeshModelLibrary & operator= ( MeshModelLibrary  lib)
Parameters
libThe library to assign to this one.

See the comments for MeshModelLibrary(const MeshModelLibrary&), since they also apply here.

Returns
A reference to this object.

◆ remove() [1/3]

bool remove ( const QString &  id)
Parameters
idThe id of the model source to remove from the library.
Returns
True if a source exists in the library with the specified id and it could be removed.

◆ remove() [2/3]

bool remove ( MeshModelLibrary library)
Parameters
libraryThe sub-library to remove from this library.
Returns
True if library is a sub-library directly held by this library and it could be removed. It will not be removed if it is not an immediate sub-library but is held more deeply in the sub-library hierachy.

◆ remove() [3/3]

bool remove ( MeshModelSource source)
Parameters
sourceThe model source to remove from the library.

Note that this function is slower than the remove(const String&) version due to how the data is stored internally. Access is optimized for lookups based on the id string, so searching for a particular model source object is O(n) where n is the number of source this library holds directly (but is not affected by any sub-libraries).

Returns
True if source exists in the library and could be removed.