OpenMS
2.6.0
|
Tags OpenMS file containers with a DocumentID. More...
#include <OpenMS/METADATA/DocumentIDTagger.h>
Public Member Functions | |
DocumentIDTagger (String toolname) | |
Constructor. More... | |
DocumentIDTagger (const DocumentIDTagger &source)=default | |
Copy constructor. More... | |
~DocumentIDTagger () | |
Destructor. More... | |
DocumentIDTagger & | operator= (const DocumentIDTagger &source)=default |
Assignment operator. More... | |
bool | operator== (const DocumentIDTagger &source) const |
Equality operator. More... | |
bool | operator!= (const DocumentIDTagger &source) const |
Equality operator. More... | |
String | getPoolFile () const |
Return the file used as ID pool. More... | |
void | setPoolFile (const String &file) |
Set the file used as ID pool. More... | |
bool | tag (DocumentIdentifier &map) const |
Tags any structure which is derived from DocumentIdentifier with a unique tag. More... | |
bool | countFreeIDs (Int &free) const |
return the number of available IDs in the pool. More... | |
Protected Attributes | |
String | toolname_ |
name of the calling TOPP tool More... | |
String | pool_file_ |
location of the ID pool More... | |
Private Member Functions | |
DocumentIDTagger () | |
Constructor (declared away) More... | |
bool | getID_ (String &id, Int &free, bool idcount_only) const |
retrieve an ID from the pool More... | |
Tags OpenMS file containers with a DocumentID.
Intended usage is from within a TOPP tool. An instance of this class is present in TOPPBase and can be used by all derived TOPP tools to assign a unique ID which is fetched from an ID pool in ./share/OpenMS/IDPool/.
|
private |
Constructor (declared away)
DocumentIDTagger | ( | String | toolname | ) |
Constructor.
|
default |
Copy constructor.
~DocumentIDTagger | ( | ) |
Destructor.
bool countFreeIDs | ( | Int & | free | ) | const |
return the number of available IDs in the pool.
Retrieve the number of available IDs in the pool. Returns true of count was successful, false otherwise (locking error, file creation error ...)
free | Number of available identifiers. You should worry if it's 0! |
retrieve an ID from the pool
Uses boost file locks to safely retrieve an ID from an ID pool.
id | Unique identifier returned from ID pool |
free | Number of available identifiers in ID pool (before this query) |
idcount_only | Only count available identifiers, do NOT retrieve one (the id string will nevertheless be filled) |
Return true if all file operations could be executed successfully (this does not imply there was an ID left over - check free>0)
String getPoolFile | ( | ) | const |
Return the file used as ID pool.
The default ID pool file is in /share/OpenMS/IDPool/IDPool.txt A custom file can be set by setIDPoolFile()
bool operator!= | ( | const DocumentIDTagger & | source | ) | const |
Equality operator.
|
default |
Assignment operator.
bool operator== | ( | const DocumentIDTagger & | source | ) | const |
Equality operator.
void setPoolFile | ( | const String & | file | ) |
Set the file used as ID pool.
bool tag | ( | DocumentIdentifier & | map | ) | const |
Tags any structure which is derived from DocumentIdentifier with a unique tag.
Tags any structure which is derived from DocumentIdentifier with a unique tag Returns true if ID could be assigned, otherwise an Exception::DepletedIDPool is thrown
map | Some class (derived from a DocumentIdentifier class) which needs a unique id |
Exception::DepletedIDPool | when no identifier (for whatever reason) could be acquired |
|
protected |
location of the ID pool
|
protected |
name of the calling TOPP tool