OpenMS  2.8.0
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
DocumentIDTagger Class Reference

Tags OpenMS file containers with a DocumentID. More...

#include <OpenMS/METADATA/DocumentIDTagger.h>

Collaboration diagram for DocumentIDTagger:
[legend]

Public Member Functions

 DocumentIDTagger (String toolname)
 Constructor. More...
 
 DocumentIDTagger (const DocumentIDTagger &source)=default
 Copy constructor. More...
 
 ~DocumentIDTagger ()
 Destructor. More...
 
DocumentIDTaggeroperator= (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...
 

Detailed Description

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/.

Constructor & Destructor Documentation

◆ DocumentIDTagger() [1/3]

DocumentIDTagger ( )
private

Constructor (declared away)

◆ DocumentIDTagger() [2/3]

DocumentIDTagger ( String  toolname)

Constructor.

◆ DocumentIDTagger() [3/3]

DocumentIDTagger ( const DocumentIDTagger source)
default

Copy constructor.

◆ ~DocumentIDTagger()

Destructor.

Member Function Documentation

◆ countFreeIDs()

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 ...)

Parameters
freeNumber of available identifiers. You should worry if it's 0!

◆ getID_()

bool getID_ ( String id,
Int free,
bool  idcount_only 
) const
private

retrieve an ID from the pool

Uses boost file locks to safely retrieve an ID from an ID pool.

Parameters
idUnique identifier returned from ID pool
freeNumber of available identifiers in ID pool (before this query)
idcount_onlyOnly 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)

◆ getPoolFile()

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()

◆ operator!=()

bool operator!= ( const DocumentIDTagger source) const

Equality operator.

◆ operator=()

DocumentIDTagger& operator= ( const DocumentIDTagger source)
default

Assignment operator.

◆ operator==()

bool operator== ( const DocumentIDTagger source) const

Equality operator.

◆ setPoolFile()

void setPoolFile ( const String file)

Set the file used as ID pool.

◆ tag()

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

Parameters
mapSome class (derived from a DocumentIdentifier class) which needs a unique id
Exceptions
Exception::DepletedIDPoolwhen no identifier (for whatever reason) could be acquired

Member Data Documentation

◆ pool_file_

String pool_file_
protected

location of the ID pool

◆ toolname_

String toolname_
protected

name of the calling TOPP tool