An index to all the studies on which a given user has a role. More...
#include <Catalog.h>
Public Types | |
typedef StudyMap::iterator | StudyIterator |
typedef StudyMap::const_iterator | StudyConstIterator |
Public Member Functions | |
Catalog () | |
Initializes a newly created Catalog object with default attributes. | |
Catalog (const std::string &userIdentifier, const std::string &userName) | |
Initializes a newly created Catalog object with attributes specified by the input parameters. | |
Catalog (const Catalog &rhs) | |
Copy constructor - initializes a newly created Catalog object with a copy of another Catalog object. | |
virtual | ~Catalog () |
Destructor - destroy a Catalog object. | |
Catalog & | operator= (const Catalog &rhs) |
Assignment operator - assign one Catalog to another. | |
bool | operator== (const Catalog &rhs) const |
Equality operator - compare two Catalog for equality. | |
bool | operator!= (const Catalog &rhs) const |
Inequality operator - compare two Catalog for inequality. | |
void | setUserIdentifier (const std::string &id) |
Set the user identifier. | |
std::string | getUserIdentifier () const |
Return the user identifier. | |
void | setUserName (const std::string &name) |
Set the user name. | |
std::string | getUserName () const |
Return the user name. | |
void | setCatalogLocation (const std::string &loc) |
Set the catalog location. | |
std::string | getCatalogLocation () const |
Return the catalog location. | |
bool | addStudy (const Study &newStudy, Study &oldStudy) |
Add a study to the catalog. | |
bool | addStudy (const Study &newStudy) |
Add a study to the catalog. | |
bool | removeStudy (const std::string &studyIdentifier) |
Remove a study from the catalog. | |
void | clearStudies () |
Remove all studies from the catalog. | |
bool | getStudy (const std::string &studyIdentifier, Study &foundStudy) const |
Return a study from the catalog. | |
bool | containsStudy (const std::string &studyIdentifier) const |
Test if a study is in the catalog. | |
int | size () const |
Return the number of studies in the catalog. | |
bool | isEmpty () const |
Return true if the catalog contains no studies. | |
StudyIterator | begin () |
Return an iterator referring to the first study in the catalog. | |
StudyConstIterator | begin () const |
StudyIterator | end () |
Return an iterator referring to the past-the-end study in the catalog. | |
StudyConstIterator | end () const |
std::string | toString () const |
Return a string representation of this Catalog . | |
std::string | toStringInternal (bool showAll) const |
Return a string representation of this Catalog . | |
Static Public Member Functions | |
static void | copyCatalog (Catalog &t, const Catalog &s) |
Make a copy of a catalog. | |
Private Types | |
typedef std::map< std::string, Study > | StudyMap |
Private Attributes | |
std::string | userIdentifier |
Identifier of the user to whom the catalog belongs. | |
std::string | userName |
User name of the user to whom the catalog belongs. | |
std::string | catalogLocation |
URI of the catalog. | |
StudyMap | studyCollection |
Collection of studies comprising the catalog. |
An index to all the studies on which a given user has a role.
A catalog has these attributes:
Definition at line 26 of file Catalog.h.
typedef StudyMap::const_iterator Yosokumo::Catalog::StudyConstIterator |
typedef StudyMap::iterator Yosokumo::Catalog::StudyIterator |
typedef std::map<std::string, Study> Yosokumo::Catalog::StudyMap [private] |
Catalog::Catalog | ( | ) |
Initializes a newly created Catalog
object with default attributes.
Definition at line 10 of file Catalog.cpp.
Catalog::Catalog | ( | const std::string & | userIdentifier, | |
const std::string & | userName | |||
) |
Initializes a newly created Catalog
object with attributes specified by the input parameters.
userIdentifier | the unique identifier for the user. | |
userName | the name of the user. |
Definition at line 16 of file Catalog.cpp.
Catalog::Catalog | ( | const Catalog & | rhs | ) |
Copy constructor - initializes a newly created Catalog
object with a copy of another Catalog
object.
rhs | the Catalog to make a copy of. |
Definition at line 24 of file Catalog.cpp.
References operator=().
Catalog::~Catalog | ( | ) | [virtual] |
Destructor - destroy a Catalog
object.
Definition at line 29 of file Catalog.cpp.
bool Catalog::addStudy | ( | const Study & | newStudy | ) |
Add a study to the catalog.
In all cases the Study
parameter is added to the catalog. The return value distinguishes two possibilities.
newStudy | the Study to add to the catalog. |
true
means there was no study already in the catalog with the same study identifier as newStudy. false
means there was a study with the same study identifier already in the catalog, and it has been replaced by the newStudy. The old study is no longer available. In both cases, newStudy has been added to the catalog. Definition at line 151 of file Catalog.cpp.
References addStudy().
Add a study to the catalog.
In all cases the Study
parameter is added to the catalog. The return value distinguishes two possibilities.
newStudy | the Study to add to the catalog. | |
oldStudy | where to save an existing study with the same study id as newStudy. |
true
means there was no study already in the catalog with the same study identifier as newStudy. The contents of oldStudy are unchanged. false
means there was a study with the same study identifier already in the catalog, and it has been replaced by the newStudy. The old study is saved in oldStudy. In both cases, newStudy has been added to the catalog. Definition at line 127 of file Catalog.cpp.
References Yosokumo::Study::getStudyIdentifier(), and studyCollection.
Referenced by addStudy(), copyCatalog(), and Yosokumo::YosokumoProtobuf::makeCatalogFromProtobufCatalog().
Catalog::StudyConstIterator Catalog::begin | ( | ) | const |
Definition at line 202 of file Catalog.cpp.
References studyCollection.
Catalog::StudyIterator Catalog::begin | ( | ) |
Return an iterator referring to the first study in the catalog.
This method can be used with the end() method to iterate over all studys in a catalog like this:
Catalog catalog; ... StudyIterator iter;
for (iter = catalog.begin(); iter != catalog.end(); ++iter) { Study study = iter->second; process study }
Definition at line 197 of file Catalog.cpp.
References studyCollection.
Referenced by copyCatalog(), Yosokumo::YosokumoProtobuf::makeProtobufCatalogFromCatalog(), operator==(), and toStringInternal().
void Catalog::clearStudies | ( | ) |
Remove all studies from the catalog.
After a call of this method, the catalog is empty, i.e., it contains no studies.
Definition at line 163 of file Catalog.cpp.
References studyCollection.
Referenced by Yosokumo::YosokumoProtobuf::makeCatalogFromProtobufCatalog().
bool Catalog::containsStudy | ( | const std::string & | studyIdentifier | ) | const |
Test if a study is in the catalog.
studyIdentifier | the identifier of the Study to test for. |
false
means there is no study in the catalog with the identifier specified by the parameter. true
means that there is a study in the catalog with the identifier specified by the parameter. Definition at line 182 of file Catalog.cpp.
References studyCollection.
Make a copy of a catalog.
t | the catalog to copy to (destination). | |
s | the catalog to copy from (source). |
Definition at line 80 of file Catalog.cpp.
References addStudy(), begin(), end(), getCatalogLocation(), getUserIdentifier(), getUserName(), setCatalogLocation(), setUserIdentifier(), and setUserName().
Referenced by operator=().
Catalog::StudyConstIterator Catalog::end | ( | ) | const |
Definition at line 212 of file Catalog.cpp.
References studyCollection.
Catalog::StudyIterator Catalog::end | ( | ) |
Return an iterator referring to the past-the-end study in the catalog.
See begin() for an example of how to use end() to iterate over studys.
Definition at line 207 of file Catalog.cpp.
References studyCollection.
Referenced by copyCatalog(), Yosokumo::YosokumoProtobuf::makeProtobufCatalogFromCatalog(), operator==(), and toStringInternal().
std::string Catalog::getCatalogLocation | ( | ) | const |
Return the catalog location.
Definition at line 120 of file Catalog.cpp.
References catalogLocation.
Referenced by copyCatalog(), Yosokumo::YosokumoProtobuf::makeProtobufCatalogFromCatalog(), and toStringInternal().
bool Catalog::getStudy | ( | const std::string & | studyIdentifier, | |
Study & | foundStudy | |||
) | const |
Return a study from the catalog.
studyIdentifier | the identifier of the Study to get from the catalog. | |
foundStudy | where to place the found Study . |
false
means there is no study in the catalog with the study identifier specified by the parameter. In this case foundStudy is unchanged. true
means that there is a study in the catalog with the study identifier specified by the parameter. foundRound contains the found study. Definition at line 168 of file Catalog.cpp.
References studyCollection.
Referenced by operator==().
std::string Catalog::getUserIdentifier | ( | ) | const |
Return the user identifier.
Definition at line 100 of file Catalog.cpp.
References userIdentifier.
Referenced by copyCatalog(), Yosokumo::YosokumoProtobuf::makeProtobufCatalogFromCatalog(), and toStringInternal().
std::string Catalog::getUserName | ( | ) | const |
Return the user name.
Definition at line 110 of file Catalog.cpp.
References userName.
Referenced by copyCatalog(), Yosokumo::YosokumoProtobuf::makeProtobufCatalogFromCatalog(), and toStringInternal().
bool Catalog::isEmpty | ( | ) | const |
Return true
if the catalog contains no studies.
true
if the catalog contains no studies. false
otherwise. Definition at line 192 of file Catalog.cpp.
References studyCollection.
bool Catalog::operator!= | ( | const Catalog & | rhs | ) | const |
Inequality operator - compare two Catalog
for inequality.
rhs | the righthand side of the inequality. |
Definition at line 73 of file Catalog.cpp.
Assignment operator - assign one Catalog
to another.
rhs | the righthand side of the assignment. |
this
Catalog. Definition at line 32 of file Catalog.cpp.
References copyCatalog().
Referenced by Catalog().
bool Catalog::operator== | ( | const Catalog & | rhs | ) | const |
Equality operator - compare two Catalog
for equality.
rhs | the righthand side of the equality. |
Definition at line 44 of file Catalog.cpp.
References begin(), catalogLocation, end(), getStudy(), Yosokumo::Study::getStudyIdentifier(), size(), userIdentifier, and userName.
bool Catalog::removeStudy | ( | const std::string & | studyIdentifier | ) |
Remove a study from the catalog.
studyIdentifier | the study identifier of the Study to remove from the catalog. |
false
means there was no study in the catalog with the study identifier specified by the parameter; the catalog is left unchanged. true
means that there was a study in the catalog with the study identifier specified by the parameter; the study has been removed from the catalog. Definition at line 158 of file Catalog.cpp.
References studyCollection.
void Catalog::setCatalogLocation | ( | const std::string & | loc | ) |
Set the catalog location.
loc | the location of this catalog. May be null. |
Definition at line 115 of file Catalog.cpp.
References catalogLocation.
Referenced by copyCatalog(), and Yosokumo::YosokumoProtobuf::makeCatalogFromProtobufCatalog().
void Catalog::setUserIdentifier | ( | const std::string & | id | ) |
Set the user identifier.
id | the identifier of the user to whom the catalog belongs. May be null. |
Definition at line 95 of file Catalog.cpp.
References userIdentifier.
Referenced by copyCatalog(), and Yosokumo::YosokumoProtobuf::makeCatalogFromProtobufCatalog().
void Catalog::setUserName | ( | const std::string & | name | ) |
Set the user name.
name | the name of the user to whom the catalog belongs. May be null. |
Definition at line 105 of file Catalog.cpp.
References userName.
Referenced by copyCatalog(), and Yosokumo::YosokumoProtobuf::makeCatalogFromProtobufCatalog().
int Catalog::size | ( | ) | const |
Return the number of studies in the catalog.
Definition at line 187 of file Catalog.cpp.
References studyCollection.
Referenced by operator==().
std::string Catalog::toString | ( | ) | const |
Return a string representation of this Catalog
.
Note that for a study in the catalog only the study identifier and study name are represented as a string, not the entire study.
Catalog
. Definition at line 220 of file Catalog.cpp.
References toStringInternal().
std::string Catalog::toStringInternal | ( | bool | showAll | ) | const |
Return a string representation of this Catalog
.
Note that for a study in the catalog only the study identifier and study name are represented as a string, not the entire study.
showAll | specifies if internal data members should be shown. |
Catalog
. Definition at line 225 of file Catalog.cpp.
References begin(), end(), getCatalogLocation(), Yosokumo::Study::getStudyIdentifier(), Yosokumo::Study::getStudyName(), getUserIdentifier(), and getUserName().
Referenced by toString().
std::string Yosokumo::Catalog::catalogLocation [private] |
URI of the catalog.
Definition at line 41 of file Catalog.h.
Referenced by getCatalogLocation(), operator==(), and setCatalogLocation().
StudyMap Yosokumo::Catalog::studyCollection [private] |
Collection of studies comprising the catalog.
Definition at line 53 of file Catalog.h.
Referenced by addStudy(), begin(), clearStudies(), containsStudy(), end(), getStudy(), isEmpty(), removeStudy(), and size().
std::string Yosokumo::Catalog::userIdentifier [private] |
Identifier of the user to whom the catalog belongs.
Definition at line 31 of file Catalog.h.
Referenced by getUserIdentifier(), operator==(), and setUserIdentifier().
std::string Yosokumo::Catalog::userName [private] |
User name of the user to whom the catalog belongs.
Definition at line 36 of file Catalog.h.
Referenced by getUserName(), operator==(), and setUserName().