OpenWalnut  1.4.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Private Attributes | Friends
WDataHandler Class Reference

Provides the environment for storing and accessing different subjects. More...

#include <WDataHandler.h>

List of all members.

Public Types

typedef std::vector
< boost::shared_ptr< WSubject > > 
SubjectContainerType
 For shortening: a type defining a shared vector of WSubject pointers.
typedef
WSharedSequenceContainer
< SubjectContainerType
SubjectSharedContainerType
 The alias for a shared container.
typedef
SubjectContainerType::const_iterator 
SubjectConstIterator
 Iterator for subjects.
typedef
SubjectContainerType::iterator 
SubjectIterator
 Iterator for subjects.

Public Member Functions

 WDataHandler ()
 Empty standard constructor.
virtual ~WDataHandler ()
 Destructor.
void addSubject (boost::shared_ptr< WSubject > subject)
 Insert a new subject referenced by a pointer.
void removeSubject (boost::shared_ptr< WSubject > subject)
 Removes the specified subject if it is in the set.
void clear ()
 Remove all subjects.
boost::shared_ptr< WSubjectgetSubjectByID (size_t subjectID)
 Returns the subject which corresponds to the specified ID.
SubjectSharedContainerType::ReadTicket getSubjects () const
 Returns read-access to the list of subjects.

Static Public Member Functions

static boost::shared_ptr
< WDataHandler
getDataHandler ()
 As WDataHandler is a singleton -> return instance.
static boost::shared_ptr
< WSubject
getDefaultSubject ()
 Gets the subject with the ID SUBJECT_UNKNOWN.

Protected Attributes

SubjectSharedContainerType m_subjects
 A container for all WSubjects.

Static Private Attributes

static boost::shared_ptr
< WDataHandler
m_instance = boost::shared_ptr< WDataHandler >()
 Singleton instance of WDataHandler.

Friends

class WDataHandlerTest
 Only UnitTests may be friends.

Detailed Description

Provides the environment for storing and accessing different subjects.

As all measured data belongs to one subject, this is the main access point to our data.

Definition at line 50 of file WDataHandler.h.


Member Typedef Documentation

typedef SubjectContainerType::const_iterator WDataHandler::SubjectConstIterator

Iterator for subjects.

Definition at line 71 of file WDataHandler.h.

typedef std::vector< boost::shared_ptr< WSubject > > WDataHandler::SubjectContainerType

For shortening: a type defining a shared vector of WSubject pointers.

Definition at line 61 of file WDataHandler.h.

typedef SubjectContainerType::iterator WDataHandler::SubjectIterator

Iterator for subjects.

Definition at line 76 of file WDataHandler.h.

The alias for a shared container.

Definition at line 66 of file WDataHandler.h.


Constructor & Destructor Documentation

Empty standard constructor.

Definition at line 41 of file WDataHandler.cpp.

References WLogger::addLogMessage(), addSubject(), WPersonalInformation::createDummyInformation(), and WLogger::getLogger().

Referenced by getDataHandler().

Destructor.

Definition at line 48 of file WDataHandler.cpp.


Member Function Documentation

void WDataHandler::addSubject ( boost::shared_ptr< WSubject subject)

Insert a new subject referenced by a pointer.

Parameters:
subjecta pointer to the subject that will be added

Definition at line 52 of file WDataHandler.cpp.

References WLogger::addLogMessage(), WLogger::getLogger(), m_subjects, WSharedSequenceContainer< S >::push_back(), and string_utils::toString().

Referenced by WDataHandler().

boost::shared_ptr< WDataHandler > WDataHandler::getDataHandler ( ) [static]
boost::shared_ptr< WSubject > WDataHandler::getDefaultSubject ( ) [static]

Gets the subject with the ID SUBJECT_UNKNOWN.

Notes:
this may be removed whenever we have a proper multi subject handling.
Returns:
the subject.

Definition at line 143 of file WDataHandler.cpp.

References getDataHandler().

boost::shared_ptr< WSubject > WDataHandler::getSubjectByID ( size_t  subjectID)

Returns the subject which corresponds to the specified ID.

It throws an exception, if the subject does not exists anymore.

Notes:
the ID might be not equal to the ID in the subjects personal information. This will (maybe) be changed later.
Parameters:
subjectIDthe ID to search the subject for
Returns:
the subject.
Exceptions:
WNoSuchSubjectin case the subject can't be found.

Definition at line 108 of file WDataHandler.cpp.

References WSharedObject< T >::getReadTicket(), and m_subjects.

Returns read-access to the list of subjects.

Notes:
as long as you own the read ticket, the list is not changed by others.
Returns:
the list of subjects.

Definition at line 103 of file WDataHandler.cpp.

References WSharedObject< T >::getReadTicket(), and m_subjects.

void WDataHandler::removeSubject ( boost::shared_ptr< WSubject subject)

Removes the specified subject if it is in the set.

Parameters:
subjectthe subject to remove.

Definition at line 63 of file WDataHandler.cpp.

References WLogger::addLogMessage(), WLogger::getLogger(), WSharedObject< T >::getWriteTicket(), m_subjects, and string_utils::toString().


Friends And Related Function Documentation

friend class WDataHandlerTest [friend]

Only UnitTests may be friends.

Definition at line 55 of file WDataHandler.h.


Member Data Documentation

boost::shared_ptr< WDataHandler > WDataHandler::m_instance = boost::shared_ptr< WDataHandler >() [static, private]

Singleton instance of WDataHandler.

Definition at line 154 of file WDataHandler.h.

Referenced by getDataHandler().

A container for all WSubjects.

Definition at line 148 of file WDataHandler.h.

Referenced by addSubject(), clear(), getSubjectByID(), getSubjects(), and removeSubject().


The documentation for this class was generated from the following files: