For each study, a list of users that have a role on the study. More...
#include <Roster.h>
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 |
For each study, a list of users that have a role on the study.
A roster has these attributes:
Definition at line 25 of file Roster.h.
typedef RoleMap::const_iterator Yosokumo::Roster::RoleConstIterator |
typedef RoleMap::iterator Yosokumo::Roster::RoleIterator |
typedef std::map<std::string, Role> Yosokumo::Roster::RoleMap [private] |
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.
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.
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.
newRole | the Role to add to the roster. |
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().
Add a role to the roster.
In all cases the Role
parameter is added to the roster. The return value distinguishes two possibilities.
newRole | the Role to add to the roster. | |
oldRole | where to save an existing role with the same user id as newRole. |
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 }
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.
userIdentifier | the identifier of the Role to test for. |
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.
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.
userIdentifier | the identifier of the Role to get from the roster. | |
foundRole | where to place the found Role . |
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.
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.
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.
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.
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.
rhs | the righthand side of the inequality. |
Definition at line 59 of file Roster.cpp.
bool Roster::operator== | ( | const Roster & | rhs | ) | const |
Equality operator - compare two Roster
for equality.
rhs | the righthand side of the equality. |
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.
userIdentifier | the user identifier of the Role to remove from the roster. |
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.
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.
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.
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.
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.
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.
showAll | specifies if internal data members should be shown. |
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().
RoleMap Yosokumo::Roster::roleCollection [private] |
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().