Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 49f29e8a authored by schultezub's avatar schultezub
Browse files

added sharing concept to properties

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@176 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent b5ccf9de
......@@ -14,11 +14,11 @@ namespace TUMVis {
}
void AbstractProcessor::addDataHandle(const std::string& name, const DataHandle* dh) {
_data.addDataHandle(name, dh);
_dataContainer.addDataHandle(name, dh);
}
const DataContainer& AbstractProcessor::getDataContainer() const {
return _data;
return _dataContainer;
}
const InvalidationLevel& AbstractProcessor::getInvalidationLevel() const {
......
......@@ -66,7 +66,7 @@ namespace TUMVis {
/**
* Returns the local DataContainer of this Processor.
* \returns Processor::_data
* \return _dataContainer
**/
const DataContainer& getDataContainer() const;
......@@ -100,7 +100,7 @@ namespace TUMVis {
protected:
DataContainer _data; ///< DataContainer containing local working set of data for this Processor
DataContainer _dataContainer; ///< DataContainer containing local working set of data for this Processor
InvalidationLevel _invalidationLevel; ///< current invalidation level of this processor
PropertyCollection _properties; ///< PropertyCollection of this processor
......
......@@ -29,4 +29,18 @@ namespace TUMVis {
void AbstractProperty::setInvalidationLevel(const InvalidationLevel& il) {
_invalidationLevel = il;
}
void AbstractProperty::addSharedProperty(AbstractProperty* prop) {
tgtAssert(prop != 0, "Shared property must not be 0!");
_sharedProperties.insert(prop);
}
void AbstractProperty::removeSharedProperty(AbstractProperty* prop) {
tgtAssert(prop != 0, "Shared property must not be 0!");
_sharedProperties.erase(prop);
}
const std::set<AbstractProperty*>& AbstractProperty::getSharedProperties() const {
return _sharedProperties;
}
}
......@@ -5,6 +5,7 @@
#include "core/tools/invalidationlevel.h"
#include "core/tools/observer.h"
#include <set>
#include <string>
#include <vector>
......@@ -77,12 +78,43 @@ namespace TUMVis {
void setInvalidationLevel(const InvalidationLevel& il);
/**
* Adds the given property \a prop to the set of shared properties.
* All shared properties will be changed when this property changes.
* Overload in subclasses to make sure that shared properties are of the same type.
* \note Make sure not to build circular sharing or you will encounter endless loops!
* \param prop Property to add.
*/
virtual void addSharedProperty(AbstractProperty* prop);
/**
* Removes the given property \a prop from the set of shared properties.
* \param prop Property to remove.
*/
void removeSharedProperty(AbstractProperty* prop);
/**
* Returns the list of shared properties, which will be changed when this property changes.
* \note Property sharing only works in one direction, i.e. shared properties act as child properties.
* Make sure not to build circular sharing structures or you will encounter endless loops.
* \return _sharedProperties
*/
const std::set<AbstractProperty*>& getSharedProperties() const;
protected:
// DO NOT REMOVE THE CONSTNESS OF _name. PropertyCollection relies on it!
const std::string _name; ///< Property name (unchangable on purpose!)
std::string _title; ///< Property title (e.g. used for GUI)
InvalidationLevel _invalidationLevel; ///< Invalidation level that this property triggers
/**
* List of shared properties that will be changed when this property changes.
* \note Property sharing only works in one direction, i.e. shared properties act as child properties.
* Make sure not to build circular sharing structures or you will encounter endless loops.
*/
std::set<AbstractProperty*> _sharedProperties;
static const std::string loggerCat_;
};
......
......@@ -34,6 +34,14 @@ namespace TUMVis {
virtual ~GenericProperty();
/**
* Adds the given property \a prop to the set of shared properties.
* All shared properties will be changed when this property changes.
* \note Make sure not to build circular sharing or you will encounter endless loops!
* \param prop Property to add, must be of the same type as this property.
*/
virtual void addSharedProperty(AbstractProperty* prop);
/**
* Returns the current value of this property.
* \return _value
......@@ -49,6 +57,7 @@ namespace TUMVis {
protected:
T _value; ///< value of the property
static const std::string loggerCat_;
};
......@@ -66,6 +75,17 @@ namespace TUMVis {
}
template<typename T>
void TUMVis::GenericProperty<T>::addSharedProperty(AbstractProperty* prop) {
// make type check first, then call base method.
tgtAssert(prop != 0, "Shared property must not be 0!");
if (dynamic_cast< GenericProperty<T>* >(prop) == 0) {
tgtAssert(false, "Shared property must be of the same type as this property!");
return;
}
AbstractProperty::addSharedProperty(prop);
}
template<typename T>
const T TUMVis::GenericProperty<T>::getValue() const {
return _value;
......@@ -74,6 +94,14 @@ namespace TUMVis {
template<typename T>
void TUMVis::GenericProperty<T>::setValue(const T& value) {
_value = value;
// TODO: think about the correct/reasonable order of observer notification
// thread-safety might play a role thereby...
for (std::set<AbstractProperty*>::iterator it = _sharedProperties.begin(); it != _sharedProperties.end(); ++it) {
// We ensure all shared properties to be of type GenericProperty<T> in the addSharedProperty overload.
// Hence, static_cast ist safe.
GenericProperty<T>* child = static_cast< GenericProperty<T>* >(*it);
child->setValue(value);
}
notifyObservers(PropertyObserverArgs(this, _invalidationLevel));
}
......
......@@ -15,8 +15,9 @@ namespace TUMVis {
MhdImageReader::MhdImageReader()
: AbstractProcessor()
, _url("url", "Image URL", "")
{
_properties.addProperty(&_url);
}
MhdImageReader::~MhdImageReader() {
......@@ -24,7 +25,7 @@ namespace TUMVis {
}
void MhdImageReader::process() {
TextFileParser tfp(_url, true, "=");
TextFileParser tfp(_url.getValue(), true, "=");
tfp.parse<TextFileParser::ItemSeparatorLines>();
std::string url;
......@@ -92,11 +93,11 @@ namespace TUMVis {
// get raw image location:
url = tfp.getString("ElementDataFile");
if (url == "LOCAL") {
url = _url;
url = _url.getValue();
// find beginning of local data:
tgt::File* file = FileSys.open(_url);
tgt::File* file = FileSys.open(_url.getValue());
if (!file || !file->isOpen())
throw tgt::FileException("Could not open file " + _url + " for reading.", _url);
throw tgt::FileException("Could not open file " + _url.getValue() + " for reading.", _url.getValue());
while (!file->eof()) {
std::string line = StringUtils::trim(file->getLine());
......@@ -115,7 +116,7 @@ namespace TUMVis {
// all parsing done - lets create the image:
ImageDataDisk* image = new ImageDataDisk(url, dimensionality, size, pt, offset, e);
_data.addData("output.image.read", image);
_dataContainer.addData("output.image.read", image);
}
catch (tgt::Exception& e) {
LERROR("Error while parsing MHD header: " << e.what());
......
......@@ -4,6 +4,7 @@
#include <string>
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/genericproperty.h"
namespace TUMVis {
/**
......@@ -30,7 +31,7 @@ namespace TUMVis {
void parseHeader();
// TODO make this a property as soon as the property system exists
std::string _url;
GenericProperty<std::string> _url;
static const std::string loggerCat_;
};
......
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