Yosokumo::Roster Class Reference

For each study, a list of users that have a role on the study. More...

#include <Roster.h>

List of all members.

Public Types

typedef RoleMap::iterator RoleIterator
 For iterating over roles in a roster.
typedef RoleMap::const_iterator RoleConstIterator

Public Member Functions

 Roster ()
 Initializes a newly created Roster object with default attributes.
 Roster (const std::string &studyIdentifier, const std::string &studyName)
 Initializes a newly created Roster object with attributes specified by the input parameters.
bool operator== (const Roster &rhs) const
 Equality operator - compare two Roster for equality.
bool operator!= (const Roster &rhs) const
 Inequality operator - compare two Roster for inequality.
void setStudyIdentifier (const std::string &id)
 Set the study identifier.
std::string getStudyIdentifier () const
 Return the study identifier.
void setStudyName (const std::string &name)
 Set the study name.
std::string getStudyName () const
 Return the study name.
void setRosterLocation (const std::string &loc)
 Set the roster location.
std::string getRosterLocation () const
 Return the roster location.
bool addRole (const Role &newRole, Role &oldRole)
 Add a role to the roster.
bool addRole (const Role &newRole)
 Add a role to the roster.
bool removeRole (const std::string &userIdentifier)
 Remove a role from the roster.
void clearRoles ()
 Remove all roles from the roster.
bool getRole (const std::string &userIdentifier, Role &foundRole) const
 Return a role from the roster.
bool containsRole (std::string userIdentifier) const
 Test if a role is in the roster.
int size () const
 Return the number of roles in the roster.
bool isEmpty () const
 Return true if the roster contains no roles.
RoleIterator begin ()
 Return an iterator referring to the first role in the roster.
RoleConstIterator begin () const
RoleIterator end ()
 Return an iterator referring to the past-the-end role in the roster.
RoleConstIterator end () const
std::string toString () const
 Return a string representation of this Roster.
std::string toStringInternal (bool showAll) const
 Return a string representation of this Roster.

Private Types

typedef std::map< std::string,
Role
RoleMap

Private Attributes

std::string studyIdentifier
std::string studyName
std::string rosterLocation
RoleMap roleCollection

Detailed Description

For each study, a list of users that have a role on the study.

A roster has these attributes:

Author:
Roger House
Version:
0.9

Definition at line 25 of file Roster.h.


Member Typedef Documentation

typedef RoleMap::const_iterator Yosokumo::Roster::RoleConstIterator

Definition at line 47 of file Roster.h.

typedef RoleMap::iterator Yosokumo::Roster::RoleIterator

For iterating over roles in a roster.

Definition at line 46 of file Roster.h.

typedef std::map<std::string, Role> Yosokumo::Roster::RoleMap [private]

Definition at line 37 of file Roster.h.


Constructor & Destructor Documentation

Roster::Roster (  ) 

Initializes a newly created Roster object with default attributes.

Definition at line 12 of file Roster.cpp.

Roster::Roster ( const std::string &  studyIdentifier,
const std::string &  studyName 
)

Initializes a newly created Roster object with attributes specified by the input parameters.

Parameters:
studyIdentifier the identifier of the study the roster is for.
studyName the name of the study the roster is for.

Definition at line 19 of file Roster.cpp.


Member Function Documentation

bool Roster::addRole ( const Role newRole  ) 

Add a role to the roster.

In all cases the Role parameter is added to the roster. The return value distinguishes two possibilities.

Parameters:
newRole the Role to add to the roster.
Returns:
true means there was no role already in the roster with the same user identifier as newRole. false means there was a role with the same user identifier already in the roster, and it has been replaced by the newRole. The old role is no longer available. In both cases, newRole has been added to the roster.

Definition at line 123 of file Roster.cpp.

References addRole().

bool Roster::addRole ( const Role newRole,
Role oldRole 
)

Add a role to the roster.

In all cases the Role parameter is added to the roster. The return value distinguishes two possibilities.

Parameters:
newRole the Role to add to the roster.
oldRole where to save an existing role with the same user id as newRole.
Returns:
true means there was no role already in the roster with the same user identifier as newRole. The contents of oldRole are unchanged. false means there was a role with the same user identifier already in the roster, and it has been replaced by the newRole. The old role is saved in oldRole. In both cases, newRole has been added to the roster.

Definition at line 99 of file Roster.cpp.

References Yosokumo::Role::getUserIdentifier(), and roleCollection.

Referenced by addRole(), and Yosokumo::YosokumoProtobuf::makeRosterFromProtobufRoster().

Roster::RoleConstIterator Roster::begin (  )  const

Definition at line 174 of file Roster.cpp.

References roleCollection.

Roster::RoleIterator Roster::begin (  ) 

Return an iterator referring to the first role in the roster.

This method can be used with the end() method to iterate over all roles in a roster like this:

   Roster roster; 
   ...
   RoleIterator iter;
   for (iter = roster.begin();  iter != roster.end();  ++iter)
   {
       Role role = iter->second;
       process role 
   }
 
Returns:
an iterator referring to the first role in the roster.

Definition at line 169 of file Roster.cpp.

References roleCollection.

Referenced by Yosokumo::YosokumoProtobuf::makeProtobufRosterFromRoster(), operator==(), and toStringInternal().

void Roster::clearRoles (  ) 

Remove all roles from the roster.

After a call of this method, the roster is empty, i.e., it contains no roles.

Definition at line 135 of file Roster.cpp.

References roleCollection.

bool Roster::containsRole ( std::string  userIdentifier  )  const

Test if a role is in the roster.

Parameters:
userIdentifier the identifier of the Role to test for.
Returns:
false means there is no role in the roster with the user identifier specified by the parameter. true means that there is a role in the roster with the user identifier specified by the parameter.

Definition at line 154 of file Roster.cpp.

References roleCollection.

Roster::RoleConstIterator Roster::end (  )  const

Definition at line 184 of file Roster.cpp.

References roleCollection.

Roster::RoleIterator Roster::end (  ) 

Return an iterator referring to the past-the-end role in the roster.

See begin() for an example of how to use end() to iterate over roles.

Returns:
an iterator referring to the past-the-end role in the roster.

Definition at line 179 of file Roster.cpp.

References roleCollection.

Referenced by Yosokumo::YosokumoProtobuf::makeProtobufRosterFromRoster(), operator==(), and toStringInternal().

bool Roster::getRole ( const std::string &  userIdentifier,
Role foundRole 
) const

Return a role from the roster.

Parameters:
userIdentifier the identifier of the Role to get from the roster.
foundRole where to place the found Role.
Returns:
false means there is no role in the roster with the user identifier specified by the parameter. In this case foundRole is unchanged. true means that there is a role in the roster with the user identifier specified by the parameter. foundRound contains the found role.

Definition at line 140 of file Roster.cpp.

References roleCollection.

Referenced by operator==().

std::string Roster::getRosterLocation (  )  const

Return the roster location.

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

Definition at line 92 of file Roster.cpp.

References rosterLocation.

Referenced by Yosokumo::YosokumoProtobuf::makeProtobufRosterFromRoster(), and toStringInternal().

std::string Roster::getStudyIdentifier (  )  const

Return the study identifier.

Returns:
the identifier of the study to which the roster belongs. May be null.

Definition at line 72 of file Roster.cpp.

References studyIdentifier.

Referenced by Yosokumo::YosokumoProtobuf::makeProtobufRosterFromRoster(), and toStringInternal().

std::string Roster::getStudyName (  )  const

Return the study name.

Returns:
the name of the study to which the roster belongs. May be null.

Definition at line 82 of file Roster.cpp.

References studyName.

Referenced by Yosokumo::YosokumoProtobuf::makeProtobufRosterFromRoster(), and toStringInternal().

bool Roster::isEmpty (  )  const

Return true if the roster contains no roles.

Returns:
true if the roster contains no roles. false otherwise.

Definition at line 164 of file Roster.cpp.

References roleCollection.

bool Roster::operator!= ( const Roster rhs  )  const

Inequality operator - compare two Roster for inequality.

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

Definition at line 59 of file Roster.cpp.

bool Roster::operator== ( const Roster rhs  )  const

Equality operator - compare two Roster for equality.

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

Definition at line 30 of file Roster.cpp.

References begin(), end(), getRole(), Yosokumo::Role::getUserIdentifier(), rosterLocation, size(), studyIdentifier, and studyName.

bool Roster::removeRole ( const std::string &  userIdentifier  ) 

Remove a role from the roster.

Parameters:
userIdentifier the user identifier of the Role to remove from the roster.
Returns:
false means there was no role in the roster with the user identifier specified by the parameter; the roster is left unchanged. true means that there was a role in the roster with the user identifier specified by the parameter; the role has been removed from the roster.

Definition at line 130 of file Roster.cpp.

References roleCollection.

void Roster::setRosterLocation ( const std::string &  loc  ) 

Set the roster location.

Parameters:
loc the location to assign to this roster. May be null.

Definition at line 87 of file Roster.cpp.

References rosterLocation.

Referenced by Yosokumo::YosokumoProtobuf::makeRosterFromProtobufRoster().

void Roster::setStudyIdentifier ( const std::string &  id  ) 

Set the study identifier.

Parameters:
id the identifier of the study to which the roster belongs. May be null.

Definition at line 67 of file Roster.cpp.

References studyIdentifier.

Referenced by Yosokumo::YosokumoProtobuf::makeRosterFromProtobufRoster().

void Roster::setStudyName ( const std::string &  name  ) 

Set the study name.

Parameters:
name the name of the study to which the roster belongs. May be null.

Definition at line 77 of file Roster.cpp.

References studyName.

Referenced by Yosokumo::YosokumoProtobuf::makeRosterFromProtobufRoster().

int Roster::size (  )  const

Return the number of roles in the roster.

Returns:
the number of roles in the roster.

Definition at line 159 of file Roster.cpp.

References roleCollection.

Referenced by operator==().

std::string Roster::toString (  )  const

Return a string representation of this Roster.

Note that for a role in the roster only the role identifier is represented as a string, not the entire role.

Returns:
the string representation of this Roster.

Definition at line 192 of file Roster.cpp.

References toStringInternal().

std::string Roster::toStringInternal ( bool  showAll  )  const

Return a string representation of this Roster.

Note that for a role in the roster only the role identifier is represented as a string, not the entire role.

Parameters:
showAll specifies if internal data members should be shown.
Returns:
the string representation of this Roster.

Definition at line 197 of file Roster.cpp.

References begin(), end(), getRosterLocation(), getStudyIdentifier(), getStudyName(), Yosokumo::Role::getUserIdentifier(), and Yosokumo::Role::getUserName().

Referenced by toString().


Member Data Documentation

Definition at line 39 of file Roster.h.

Referenced by addRole(), begin(), clearRoles(), containsRole(), end(), getRole(), isEmpty(), removeRole(), and size().

std::string Yosokumo::Roster::rosterLocation [private]

Definition at line 30 of file Roster.h.

Referenced by getRosterLocation(), operator==(), and setRosterLocation().

std::string Yosokumo::Roster::studyIdentifier [private]

Definition at line 27 of file Roster.h.

Referenced by getStudyIdentifier(), operator==(), and setStudyIdentifier().

std::string Yosokumo::Roster::studyName [private]

Definition at line 28 of file Roster.h.

Referenced by getStudyName(), operator==(), and setStudyName().


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