Yosokumo::Catalog Class Reference

An index to all the studies on which a given user has a role. More...

#include <Catalog.h>

List of all members.

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.
Catalogoperator= (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.

Detailed Description

An index to all the studies on which a given user has a role.

A catalog has these attributes:

Author:
Roger House
Version:
0.9

Definition at line 26 of file Catalog.h.


Member Typedef Documentation

typedef StudyMap::const_iterator Yosokumo::Catalog::StudyConstIterator

Definition at line 62 of file Catalog.h.

typedef StudyMap::iterator Yosokumo::Catalog::StudyIterator

Definition at line 61 of file Catalog.h.

typedef std::map<std::string, Study> Yosokumo::Catalog::StudyMap [private]

Definition at line 48 of file Catalog.h.


Constructor & Destructor Documentation

Catalog::Catalog (  ) 

Initializes a newly created Catalog object with default attributes.

  • user identifier "ABCDEF0123456789"
  • user name ""

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.

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.

Parameters:
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.


Member Function Documentation

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.

Parameters:
newStudy the Study to add to the catalog.
Returns:
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().

bool Catalog::addStudy ( const Study newStudy,
Study oldStudy 
)

Add a study to the catalog.

In all cases the Study parameter is added to the catalog. The return value distinguishes two possibilities.

Parameters:
newStudy the Study to add to the catalog.
oldStudy where to save an existing study with the same study id as newStudy.
Returns:
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 
   }
 
Returns:
an iterator referring to the first study in the catalog.

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.

Parameters:
studyIdentifier the identifier of the Study to test for.
Returns:
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.

void Catalog::copyCatalog ( Catalog t,
const Catalog s 
) [static]

Make a copy of a catalog.

Parameters:
t the catalog to copy to (destination).
s the catalog to copy from (source).
Returns:
a copy of s.

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.

Returns:
an iterator referring to the past-the-end study in the catalog.

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.

Returns:
the location of this catalog. May be null.

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.

Parameters:
studyIdentifier the identifier of the Study to get from the catalog.
foundStudy where to place the found Study.
Returns:
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.

Returns:
the identifier of the user to whom the catalog belongs. May be null.

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.

Returns:
the name of the user to whom the catalog belongs. May be null.

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.

Returns:
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.

Parameters:
rhs the righthand side of the inequality.
Returns:
true if and only if this Catalog and the righthand side Catalog are not identically equal.

Definition at line 73 of file Catalog.cpp.

Catalog & Catalog::operator= ( const Catalog rhs  ) 

Assignment operator - assign one Catalog to another.

Parameters:
rhs the righthand side of the assignment.
Returns:
a reference to 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.

Parameters:
rhs the righthand side of the equality.
Returns:
true if and only if this Catalog and the righthand side Catalog are identically equal.

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.

Parameters:
studyIdentifier the study identifier of the Study to remove from the catalog.
Returns:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Returns:
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.

Returns:
the string representation of this 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.

Parameters:
showAll specifies if internal data members should be shown.
Returns:
the string representation of this 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().


Member Data Documentation

std::string Yosokumo::Catalog::catalogLocation [private]

URI of the catalog.

Definition at line 41 of file Catalog.h.

Referenced by getCatalogLocation(), operator==(), and setCatalogLocation().

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


The documentation for this class was generated from the following files:
Generated on Mon May 13 09:19:11 2013 for C++ Yosokumo API by  doxygen 1.6.3