Regina 7.3 Calculation Engine
Public Member Functions | List of all members
regina::CensusDB Class Reference

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...
 
CensusDBoperator= (const CensusDB &)=default
 Sets this to be a clone of the given database reference. More...
 
CensusDBoperator= (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CensusDB() [1/3]

regina::CensusDB::CensusDB ( std::string  filename,
std::string  desc 
)
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.

Parameters
filenamethe filename where the database is stored.
desca human-readable description of the database. See the desc() routine for further information on how this description might be used.

◆ CensusDB() [2/3]

regina::CensusDB::CensusDB ( const CensusDB )
default

Creates a new clone of the given database reference.

◆ CensusDB() [3/3]

regina::CensusDB::CensusDB ( CensusDB &&  )
defaultnoexcept

Moves the given database reference into this new object.

The reference that was passed will no longer be usable.

Member Function Documentation

◆ desc()

const std::string & regina::CensusDB::desc ( ) const
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.

Returns
the database description.

◆ filename()

const std::string & regina::CensusDB::filename ( ) const
inline

Returns the filename where this database is stored.

Returns
the database filename.

◆ lookup()

template<typename Action >
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.

Python
This function is available in Python, and the action argument may be a pure Python function.
Parameters
isoSigthe isomorphism signature to search for.
actiona function (or other callable object) that will be called for each match in the database.
Returns
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.

◆ operator!=()

bool regina::CensusDB::operator!= ( const CensusDB rhs) const
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.

Parameters
rhsthe database to compare this against.
Returns
true if and only if this and the given object represent different databases.

◆ operator=() [1/2]

CensusDB & regina::CensusDB::operator= ( CensusDB &&  )
defaultnoexcept

Moves the given database reference into this object.

The reference that was passed will no longer be usable.

◆ operator=() [2/2]

CensusDB & regina::CensusDB::operator= ( const CensusDB )
default

Sets this to be a clone of the given database reference.

◆ operator==()

bool regina::CensusDB::operator== ( const CensusDB rhs) const
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.

Parameters
rhsthe database to compare this against.
Returns
true if and only if this and the given object represent the same database.

◆ swap()

void regina::CensusDB::swap ( CensusDB other)
inlinenoexcept

Swaps the contents of this and the given database reference.

Parameters
otherthe database reference whose contents are to be swapped with this.

The documentation for this class was generated from the following file:

Copyright © 1999-2023, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).