OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Private Attributes | Friends | List of all members
WDataHandler Class Reference

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

#include <WDataHandler.h>

+ Collaboration diagram for WDataHandler:

Public Types

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

Public Member Functions

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

Static Public Member Functions

static std::shared_ptr< WDataHandlergetDataHandler ()
 As WDataHandler is a singleton -> return instance. More...
 
static std::shared_ptr< WSubjectgetDefaultSubject ()
 Gets the subject with the ID SUBJECT_UNKNOWN. More...
 

Protected Attributes

SubjectSharedContainerType m_subjects
 A container for all WSubjects. More...
 

Static Private Attributes

static std::shared_ptr< WDataHandlerm_instance = std::shared_ptr< WDataHandler >()
 Singleton instance of WDataHandler. More...
 

Friends

class WDataHandlerTest
 Only UnitTests may be friends. More...
 

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 48 of file WDataHandler.h.

Member Typedef Documentation

◆ SubjectConstIterator

typedef SubjectContainerType::const_iterator WDataHandler::SubjectConstIterator

Iterator for subjects.

Definition at line 69 of file WDataHandler.h.

◆ SubjectContainerType

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

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

Definition at line 59 of file WDataHandler.h.

◆ SubjectIterator

typedef SubjectContainerType::iterator WDataHandler::SubjectIterator

Iterator for subjects.

Definition at line 74 of file WDataHandler.h.

◆ SubjectSharedContainerType

The alias for a shared container.

Definition at line 64 of file WDataHandler.h.

Constructor & Destructor Documentation

◆ WDataHandler()

WDataHandler::WDataHandler ( )

Empty standard constructor.

Definition at line 39 of file WDataHandler.cpp.

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

Referenced by getDataHandler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~WDataHandler()

WDataHandler::~WDataHandler ( )
virtual

Destructor.

Definition at line 46 of file WDataHandler.cpp.

Member Function Documentation

◆ addSubject()

void WDataHandler::addSubject ( std::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 50 of file WDataHandler.cpp.

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

Referenced by WDataHandler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void WDataHandler::clear ( )

Remove all subjects.

Definition at line 82 of file WDataHandler.cpp.

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

+ Here is the call graph for this function:

◆ getDataHandler()

std::shared_ptr< WDataHandler > WDataHandler::getDataHandler ( )
static

As WDataHandler is a singleton -> return instance.

Returns
the instance.

Definition at line 131 of file WDataHandler.cpp.

References m_instance, and WDataHandler().

Referenced by WKernel::finalize(), getDefaultSubject(), WKernel::init(), WMainWindow::newProject(), WDataHandlerTest::testAddSubjects(), WDataHandlerTest::testRemoveSubjects(), and WDataHandlerTest::testSingleton().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultSubject()

std::shared_ptr< WSubject > WDataHandler::getDefaultSubject ( )
static

Gets the subject with the ID SUBJECT_UNKNOWN.

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

Definition at line 141 of file WDataHandler.cpp.

References getDataHandler().

Referenced by WMClusterDisplayVoxels::createTexture(), WMHierchClustDisplay::initTexture(), and WQtGui::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubjectByID()

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

Note
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 106 of file WDataHandler.cpp.

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

+ Here is the call graph for this function:

◆ getSubjects()

WDataHandler::SubjectSharedContainerType::ReadTicket WDataHandler::getSubjects ( ) const

Returns read-access to the list of subjects.

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

Definition at line 101 of file WDataHandler.cpp.

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

+ Here is the call graph for this function:

◆ removeSubject()

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

Removes the specified subject if it is in the set.

Parameters
subjectthe subject to remove.

Definition at line 61 of file WDataHandler.cpp.

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

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ WDataHandlerTest

friend class WDataHandlerTest
friend

Only UnitTests may be friends.

Definition at line 53 of file WDataHandler.h.

Member Data Documentation

◆ m_instance

std::shared_ptr< WDataHandler > WDataHandler::m_instance = std::shared_ptr< WDataHandler >()
staticprivate

Singleton instance of WDataHandler.

Definition at line 152 of file WDataHandler.h.

Referenced by getDataHandler().

◆ m_subjects

SubjectSharedContainerType WDataHandler::m_subjects
protected

A container for all WSubjects.

Definition at line 146 of file WDataHandler.h.

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


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