Commit 0d11949f authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD #256] allow for only being notified if the list changes.

parent 374bf80f
......@@ -39,6 +39,7 @@ WSubject::WSubject():
m_datasets(),
m_datasetAccess( m_datasets.getAccessObject() ),
m_changeCondition( boost::shared_ptr< WConditionSet >( new WConditionSet() ) ),
m_listChangeCondition( boost::shared_ptr< WConditionSet >( new WConditionSet() ) ),
m_personalInfo( WPersonalInformation::createDummyInformation() )
{
}
......@@ -47,6 +48,7 @@ WSubject::WSubject( WPersonalInformation personInfo ):
m_datasets(),
m_datasetAccess( m_datasets.getAccessObject() ),
m_changeCondition( boost::shared_ptr< WConditionSet >( new WConditionSet() ) ),
m_listChangeCondition( boost::shared_ptr< WConditionSet >( new WConditionSet() ) ),
m_personalInfo( personInfo )
{
}
......@@ -78,6 +80,7 @@ void WSubject::addDataSet( boost::shared_ptr< WDataSet > dataset )
m_changeCondition->add( c );
}
m_changeCondition->notify();
m_listChangeCondition->notify();
}
void WSubject::removeDataSet( boost::shared_ptr< WDataSet > dataset )
......@@ -96,6 +99,7 @@ void WSubject::removeDataSet( boost::shared_ptr< WDataSet > dataset )
m_datasetAccess->endWrite();
m_changeCondition->notify();
m_listChangeCondition->notify();
}
void WSubject::clear()
......@@ -115,27 +119,31 @@ void WSubject::clear()
m_datasetAccess->get().clear();
m_datasetAccess->endWrite();
m_listChangeCondition->notify();
}
boost::shared_ptr< WDataSet > WSubject::getDataSetByID( size_t datasetID )
{
m_datasetAccess->beginRead();
// TODO(all): rethink this
// wiebel: I deactivated this as we want to resort thes list ... so we have to rethinks this.
// boost::shared_ptr< WDataSet > WSubject::getDataSetByID( size_t datasetID )
// {
// m_datasetAccess->beginRead();
// search it
boost::shared_ptr< WDataSet > result;
try
{
result = m_datasetAccess->get().at( datasetID );
}
catch( const std::out_of_range& e )
{
throw WDHNoSuchDataSet();
}
// // search it
// boost::shared_ptr< WDataSet > result;
// try
// {
// result = m_datasetAccess->get().at( datasetID );
// }
// catch( const std::out_of_range& e )
// {
// throw WDHNoSuchDataSet();
// }
m_datasetAccess->endRead();
// m_datasetAccess->endRead();
return result;
}
// return result;
// }
std::vector< boost::shared_ptr< WDataTexture3D > > WSubject::getDataTextures( bool onlyActive )
{
......@@ -162,8 +170,13 @@ WSubject::DatasetAccess WSubject::getAccessObject()
return m_datasets.getAccessObject();
}
boost::shared_ptr< WCondition > WSubject::getChangeCondition()
boost::shared_ptr< WCondition > WSubject::getChangeCondition() const
{
return m_changeCondition;
}
boost::shared_ptr< WCondition > WSubject::getListChangeCondition() const
{
return m_listChangeCondition;
}
......@@ -124,18 +124,20 @@ public:
*/
void clear();
/**
* Returns the dataset which corresponds to the specified ID. It throws an exception, if the dataset does not exists anymore.
*
* \param datasetID the ID to search the dataset for
*
* \return the dataset.
*
* \throw WNoSuchDataSet in case the dataset can't be found.
*
* \note you should avoid this function. Do NOT store ID's. They may change.
*/
boost::shared_ptr< WDataSet > getDataSetByID( size_t datasetID );
// TODO(all): rethink this
// wiebel: I deactivated this as we want to resort thes list ... so we have to rethinks this.
// /**
// * Returns the dataset which corresponds to the specified ID. It throws an exception, if the dataset does not exists anymore.
// *
// * \param datasetID the ID to search the dataset for
// *
// * \return the dataset.
// *
// * \throw WNoSuchDataSet in case the dataset can't be found.
// *
// * \note you should avoid this function. Do NOT store ID's. They may change.
// */
// boost::shared_ptr< WDataSet > getDataSetByID( size_t datasetID );
/**
* This gives a list of data textures from all supporting datasets in this subject.
......@@ -157,7 +159,14 @@ public:
*
* \return the condition
*/
boost::shared_ptr< WCondition > getChangeCondition();
boost::shared_ptr< WCondition > getChangeCondition() const;
/**
* This condition fires whenever the list of datasets changes.
*
* \return the condition
*/
boost::shared_ptr< WCondition > getListChangeCondition() const;
protected:
......@@ -176,6 +185,11 @@ protected:
*/
boost::shared_ptr< WConditionSet > m_changeCondition;
/**
* This condition set fires whenever the list of datasets changes.
*/
boost::shared_ptr< WConditionSet > m_listChangeCondition;
private:
WPersonalInformation m_personalInfo; //!< Information on the person represented by this WSubject.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment