Regina 7.0 Calculation Engine
|
Stores the location and description of one of Regina's in-built census databases. More...
#include <census/census.h>
Public Member Functions | |
CensusDB (std::string filename, std::string desc) | |
Creates a new reference to one of Regina's census databases. More... | |
CensusDB (const CensusDB &)=default | |
Creates a new clone of the given database reference. More... | |
CensusDB (CensusDB &&) noexcept=default | |
Moves the given database reference into this new object. More... | |
const std::string & | filename () const |
Returns the filename where this database is stored. More... | |
const std::string & | desc () const |
Returns a human-readable description of this database. More... | |
template<typename Action > | |
bool | lookup (const std::string &isoSig, Action &&action) const |
Searches for the given isomorphism signature in this database. More... | |
CensusDB & | operator= (const CensusDB &)=default |
Sets this to be a clone of the given database reference. More... | |
CensusDB & | operator= (CensusDB &&) noexcept=default |
Moves the given database reference into this object. More... | |
void | swap (CensusDB &other) noexcept |
Swaps the contents of this and the given database reference. More... | |
bool | operator== (const CensusDB &rhs) const |
Tests whether this and the given object represent the same database. More... | |
bool | operator!= (const CensusDB &rhs) const |
Tests whether this and the given object represent different databases. More... | |
Stores the location and description of one of Regina's in-built census databases.
A census database stores a list of key-value pairs. The keys are isomorphism signatures of triangulations (as returned by Triangulation<3>::isoSig(), for instance), and the values are human-readable names (typically the names of the triangulations and/or the names of the underlying manifolds). An isomorphism signature may appear multiple times (with different names) within the same database.
The format used to store census databases is an internal implementation detail that may change in future releases of Regina. End users should only search census databases using high-level routines such as Census::lookup() and CensusDB::lookup().
This class implements C++ move semantics and adheres to the C++ Swappable requirement. It is designed to avoid deep copies wherever possible, even when passing or returning objects by value.
|
inline |
Creates a new reference to one of Regina's census databases.
This constructor will not run any checks (e.g., it will not verify that the database exists, or that it is stored in the correct format). Note that even if the database does not exist, the lookup() routine will fail gracefully.
filename | the filename where the database is stored. |
desc | a human-readable description of the database. See the desc() routine for further information on how this description might be used. |
|
default |
Creates a new clone of the given database reference.
|
defaultnoexcept |
Moves the given database reference into this new object.
The reference that was passed will no longer be usable.
|
inline |
Returns a human-readable description of this database.
The description could (for instance) be shown to users when giving a list of all available databases, or when identifying in which particular database a match was found.
|
inline |
Returns the filename where this database is stored.
bool regina::CensusDB::lookup | ( | const std::string & | isoSig, |
Action && | action | ||
) | const |
Searches for the given isomorphism signature in this database.
For each match that is found (if any), this routine will call action (which must be a function or some other callable object). This action should return void
, and must take exactly one CensusHit argument. The argument will be passed as a prvalue, which means the argument type for action could be any of (CensusHit), (const CensusHit&), or (CensusHit&&).
Note that the database will be opened and closed every time this routine is called.
If the given isomorphism signature is empty then this routine will return true
immediately (i.e., it will be treated as successful with no hits but it will not actually search the database).
If you are using this routine yourself, you will need to include the extra header census/census-impl.h (which is not automatically included from this file). Typically, however, end users can simply use the catch-all Census::lookup() routines and will not need to call this more fine-grained routine.
isoSig | the isomorphism signature to search for. |
action | a function (or other callable object) that will be called for each match in the database. |
true
if the lookup was correctly performed, or false
if some error occurred (e.g., the database could not be opened). Note in particular that if there were no matches but no errors, then the return value will be true
.
|
inline |
Tests whether this and the given object represent different databases.
Two databases are considered the same if they have identical filenames (as returned by the filename() function). The database descriptions are irrelevant here.
rhs | the database to compare this against. |
true
if and only if this and the given object represent different databases. Moves the given database reference into this object.
The reference that was passed will no longer be usable.
Sets this to be a clone of the given database reference.
|
inline |
Tests whether this and the given object represent the same database.
Two databases are considered the same if they have identical filenames (as returned by the filename() function). The database descriptions are irrelevant here.
rhs | the database to compare this against. |
true
if and only if this and the given object represent the same database.
|
inlinenoexcept |
Swaps the contents of this and the given database reference.
other | the database reference whose contents are to be swapped with this. |