2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 12f36262 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Added a field _pipelineName to AutoEvaluationPipeline. This allows to...

Added a field _pipelineName to AutoEvaluationPipeline. This allows to implement AutoEvaluationPipeline::getName() so that AutoEvaluationPipeline is no longer abstract. Consequently, the LuaPipeline is no longer needed.

This change was also used to change the AbstractPipeline constructor signature to pass-by-reference instead of pass-by-pointer for the pipeline's DataContainer. This presents the semantics more clearly since the DataContainer must not be 0.
parent 50c0b05d
...@@ -159,7 +159,7 @@ namespace campvis { ...@@ -159,7 +159,7 @@ namespace campvis {
} }
else { else {
DataContainer* dc = createAndAddDataContainer("DataContainer #" + StringUtils::toString(_dataContainers.size() + 1)); DataContainer* dc = createAndAddDataContainer("DataContainer #" + StringUtils::toString(_dataContainers.size() + 1));
AbstractPipeline* p = PipelineFactory::getRef().createPipeline(pipelinesToAdd[i].toStdString(), dc); AbstractPipeline* p = PipelineFactory::getRef().createPipeline(pipelinesToAdd[i].toStdString(), *dc);
if (p != nullptr) if (p != nullptr)
addPipeline(pipelinesToAdd[i].toStdString(), p); addPipeline(pipelinesToAdd[i].toStdString(), p);
} }
......
...@@ -425,7 +425,7 @@ namespace campvis { ...@@ -425,7 +425,7 @@ namespace campvis {
if (dc == 0) { if (dc == 0) {
dc = _application->createAndAddDataContainer("DataContainer #" + StringUtils::toString(_application->_dataContainers.size() + 1)); dc = _application->createAndAddDataContainer("DataContainer #" + StringUtils::toString(_application->_dataContainers.size() + 1));
} }
AbstractPipeline* p = PipelineFactory::getRef().createPipeline(name, dc); AbstractPipeline* p = PipelineFactory::getRef().createPipeline(name, *dc);
_application->addPipeline(name, p); _application->addPipeline(name, p);
} }
......
...@@ -13,7 +13,7 @@ LuaDemo = {} ...@@ -13,7 +13,7 @@ LuaDemo = {}
-- create DataContainer and Pipeline -- create DataContainer and Pipeline
LuaDemo.dc = application:createAndAddDataContainer("This DataContainer was created by Lua.") LuaDemo.dc = application:createAndAddDataContainer("This DataContainer was created by Lua.")
LuaDemo.pipeline = campvis.LuaPipeline("A pipeline created by Lua", LuaDemo.dc) LuaDemo.pipeline = campvis.AutoEvaluationPipeline(LuaDemo.dc, "A pipeline created by Lua")
local pipeline = LuaDemo.pipeline; local pipeline = LuaDemo.pipeline;
-- create the processors we need -- create the processors we need
...@@ -51,7 +51,7 @@ local initCallback = function() ...@@ -51,7 +51,7 @@ local initCallback = function()
-- alternative 2 to automatically adjust the camera to the data -- alternative 2 to automatically adjust the camera to the data
local callback = function(arg) local callback = function(arg)
local data_container = LuaDemo.getDataContainer(instance) local data_container = pipeline:getDataContainer()
local img_data = data_container:getData(LuaDemo.image_reader.p_targetImageID:getValue()):getData() local img_data = data_container:getData(LuaDemo.image_reader.p_targetImageID:getValue()):getData()
LuaDemo.tcp:reinitializeCamera(img_data:getWorldBounds()) LuaDemo.tcp:reinitializeCamera(img_data:getWorldBounds())
end end
......
...@@ -210,14 +210,6 @@ namespace campvis { ...@@ -210,14 +210,6 @@ namespace campvis {
void selectById(const std::string& id); void selectById(const std::string& id);
}; };
/* Downcast the return value of selectById to appropriate subclass */
%factory(void campvis::AbstractOptionProperty::selectById,
campvis::GenericOptionProperty);
/* Downcast the return value of getOptionId to appropriate subclass */
%factory(void campvis::AbstractOptionProperty::getOptionId,
campvis::GenericOptionProperty);
/* TFGeometry1D */ /* TFGeometry1D */
%nodefaultctor TFGeometry1D; %nodefaultctor TFGeometry1D;
...@@ -332,6 +324,9 @@ namespace campvis { ...@@ -332,6 +324,9 @@ namespace campvis {
/* DataHandle */ /* DataHandle */
/* Downcast the return value of DataHandle::getData to appropriate subclass */
%factory(const AbstractData* campvis::DataHandle::getData, const campvis::ImageData);
class DataHandle { class DataHandle {
public: public:
explicit DataHandle(AbstractData* data = 0); explicit DataHandle(AbstractData* data = 0);
...@@ -371,9 +366,6 @@ namespace campvis { ...@@ -371,9 +366,6 @@ namespace campvis {
virtual cgt::Bounds getWorldBounds() const; virtual cgt::Bounds getWorldBounds() const;
}; };
/* Downcast the return value of DataHandle::getData to appropriate subclass */
%factory(AbstractData* campvis::DataHandle::getData, campvis::ImageData);
/* DataContainer */ /* DataContainer */
class DataContainer { class DataContainer {
...@@ -454,10 +446,10 @@ namespace campvis { ...@@ -454,10 +446,10 @@ namespace campvis {
class AbstractPipeline : public HasPropertyCollection { class AbstractPipeline : public HasPropertyCollection {
public: public:
AbstractPipeline(DataContainer* dc); AbstractPipeline(DataContainer& dc);
virtual ~AbstractPipeline(); virtual ~AbstractPipeline();
virtual const std::string getName() const = 0; virtual std::string getName() const = 0;
const DataContainer& getDataContainer() const; const DataContainer& getDataContainer() const;
DataContainer& getDataContainer(); DataContainer& getDataContainer();
...@@ -475,6 +467,10 @@ namespace campvis { ...@@ -475,6 +467,10 @@ namespace campvis {
class AutoEvaluationPipeline : public AbstractPipeline { class AutoEvaluationPipeline : public AbstractPipeline {
public: public:
AutoEvaluationPipeline(DataContainer& dataContainer, const std::string& pipelineName);
virtual ~AutoEvaluationPipeline();
std::string getName() const;
virtual void addProcessor(AbstractProcessor* processor); virtual void addProcessor(AbstractProcessor* processor);
void addEventListenerToBack(cgt::EventListener* e); void addEventListenerToBack(cgt::EventListener* e);
...@@ -512,23 +508,6 @@ namespace campvis { ...@@ -512,23 +508,6 @@ namespace campvis {
}; };
} }
%inline{
namespace campvis {
class LuaPipeline : public campvis::AutoEvaluationPipeline {
public:
const std::string _name;
LuaPipeline(const std::string& name, campvis::DataContainer* dc)
: campvis::AutoEvaluationPipeline(dc)
, _name(name)
{
};
virtual const std::string getName() const { return _name; };
};
}
}
%luacode { %luacode {
function campvis.newPipeline (name, o) function campvis.newPipeline (name, o)
if not name then if not name then
...@@ -542,3 +521,4 @@ namespace campvis { ...@@ -542,3 +521,4 @@ namespace campvis {
print("Module campvis-core loaded") print("Module campvis-core loaded")
} }
...@@ -40,17 +40,17 @@ ...@@ -40,17 +40,17 @@
namespace campvis { namespace campvis {
const std::string AbstractPipeline::loggerCat_ = "CAMPVis.core.datastructures.AbstractPipeline"; const std::string AbstractPipeline::loggerCat_ = "CAMPVis.core.datastructures.AbstractPipeline";
AbstractPipeline::AbstractPipeline(DataContainer* dc) AbstractPipeline::AbstractPipeline(DataContainer& dc)
: HasPropertyCollection() : HasPropertyCollection()
, cgt::EventHandler() , cgt::EventHandler()
, cgt::EventListener() , cgt::EventListener()
, _data(dc) , _dataContainer(&dc)
, _canvas(0) , _canvas(0)
, _canvasSize("CanvasSize", "Canvas Size", cgt::ivec2(128, 128), cgt::ivec2(1, 1), cgt::ivec2(4096, 4096)) , _canvasSize("CanvasSize", "Canvas Size", cgt::ivec2(128, 128), cgt::ivec2(1, 1), cgt::ivec2(4096, 4096))
, _ignoreCanvasSizeUpdate(false) , _ignoreCanvasSizeUpdate(false)
, _renderTargetID("renderTargetID", "Render Target ID", "AbstractPipeline.renderTarget", DataNameProperty::READ) , _renderTargetID("renderTargetID", "Render Target ID", "AbstractPipeline.renderTarget", DataNameProperty::READ)
{ {
cgtAssert(_data != 0, "Pointer to the DataContainer for this pipeline must not be 0!"); cgtAssert(_dataContainer != nullptr, "Pointer to the DataContainer for this pipeline must not be 0!");
_painter.reset(new PipelinePainter(nullptr, this)); _painter.reset(new PipelinePainter(nullptr, this));
...@@ -65,7 +65,7 @@ namespace campvis { ...@@ -65,7 +65,7 @@ namespace campvis {
} }
void AbstractPipeline::init() { void AbstractPipeline::init() {
_data->s_dataAdded.connect(this, &AbstractPipeline::onDataContainerDataAdded); _dataContainer->s_dataAdded.connect(this, &AbstractPipeline::onDataContainerDataAdded);
_painter->init(); _painter->init();
initAllProperties(); initAllProperties();
...@@ -85,7 +85,7 @@ namespace campvis { ...@@ -85,7 +85,7 @@ namespace campvis {
} }
void AbstractPipeline::deinit() { void AbstractPipeline::deinit() {
_data->s_dataAdded.disconnect(this); _dataContainer->s_dataAdded.disconnect(this);
// use trigger signal to enforce blocking call // use trigger signal to enforce blocking call
s_deinit.triggerSignal(); s_deinit.triggerSignal();
...@@ -106,7 +106,7 @@ namespace campvis { ...@@ -106,7 +106,7 @@ namespace campvis {
// clear DataContainer // clear DataContainer
_data->clear(); _dataContainer->clear();
} }
void AbstractPipeline::run() { void AbstractPipeline::run() {
...@@ -153,11 +153,11 @@ namespace campvis { ...@@ -153,11 +153,11 @@ namespace campvis {
} }
const DataContainer& AbstractPipeline::getDataContainer() const { const DataContainer& AbstractPipeline::getDataContainer() const {
return *_data; return *_dataContainer;
} }
DataContainer& AbstractPipeline::getDataContainer() { DataContainer& AbstractPipeline::getDataContainer() {
return *_data; return *_dataContainer;
} }
void AbstractPipeline::executeProcessor(AbstractProcessor* processor) { void AbstractPipeline::executeProcessor(AbstractProcessor* processor) {
...@@ -171,7 +171,7 @@ namespace campvis { ...@@ -171,7 +171,7 @@ namespace campvis {
startTime = tbb::tick_count::now(); startTime = tbb::tick_count::now();
try { try {
processor->process(*_data); processor->process(*_dataContainer);
} }
catch (std::exception& e) { catch (std::exception& e) {
LERROR("Caught unhandled exception while executing processor " << processor->getName() << ": " << e.what()); LERROR("Caught unhandled exception while executing processor " << processor->getName() << ": " << e.what());
......
...@@ -64,10 +64,10 @@ namespace campvis { ...@@ -64,10 +64,10 @@ namespace campvis {
* If you derive from AbstractPipeline, you will have to implement the pipeline evaluation * If you derive from AbstractPipeline, you will have to implement the pipeline evaluation
* logic yourself. You might want to have a look at AutoEvaluationPipeline. * logic yourself. You might want to have a look at AutoEvaluationPipeline.
* *
* \param dc Pointer to the DataContainer containing local working set of data for this * \param dataContainer Reference to the DataContainer containing local working set of data
* pipeline, must not be 0, must be valid the whole lifetime of this pipeline. * for this pipeline, must be valid the whole lifetime of this pipeline.
*/ */
explicit AbstractPipeline(DataContainer* dc); explicit AbstractPipeline(DataContainer& dataContainer);
/** /**
* Virtual Destructor * Virtual Destructor
...@@ -78,7 +78,7 @@ namespace campvis { ...@@ -78,7 +78,7 @@ namespace campvis {
* Gets the name of this very pipeline. To be defined by every subclass. * Gets the name of this very pipeline. To be defined by every subclass.
* \return The name of this pipeline. * \return The name of this pipeline.
*/ */
virtual const std::string getName() const = 0; virtual std::string getName() const = 0;
/** /**
...@@ -143,13 +143,13 @@ namespace campvis { ...@@ -143,13 +143,13 @@ namespace campvis {
/** /**
* Returns the DataContainer of this pipeline, const version. * Returns the DataContainer of this pipeline, const version.
* \return _data * \return _dataContainer
*/ */
const DataContainer& getDataContainer() const; const DataContainer& getDataContainer() const;
/** /**
* Returns the DataContainer of this pipeline, non-const version. * Returns the DataContainer of this pipeline, non-const version.
* \return _data * \return _dataContainer
*/ */
DataContainer& getDataContainer(); DataContainer& getDataContainer();
...@@ -213,7 +213,7 @@ namespace campvis { ...@@ -213,7 +213,7 @@ namespace campvis {
* Returns the canvas size * Returns the canvas size
* \return The IVec2Property with current canvas size on it * \return The IVec2Property with current canvas size on it
*/ */
IVec2Property& getCanvasSize() {return _canvasSize;} IVec2Property& getCanvasSize() { return _canvasSize; }
/** /**
* Returns this pipelines PipelinePainter. * Returns this pipelines PipelinePainter.
...@@ -263,7 +263,7 @@ namespace campvis { ...@@ -263,7 +263,7 @@ namespace campvis {
/// Pointer to the DataContainer containing local working set of data for this Pipeline, must not be 0. /// Pointer to the DataContainer containing local working set of data for this Pipeline, must not be 0.
DataContainer* _data; DataContainer* _dataContainer;
std::vector<AbstractProcessor*> _processors; ///< List of all processors of this pipeline std::vector<AbstractProcessor*> _processors; ///< List of all processors of this pipeline
......
...@@ -34,14 +34,19 @@ ...@@ -34,14 +34,19 @@
namespace campvis { namespace campvis {
const std::string AutoEvaluationPipeline::loggerCat_ = "CAMPVis.core.datastructures.AutoEvaluationPipeline"; const std::string AutoEvaluationPipeline::loggerCat_ = "CAMPVis.core.datastructures.AutoEvaluationPipeline";
AutoEvaluationPipeline::AutoEvaluationPipeline(DataContainer* dc) AutoEvaluationPipeline::AutoEvaluationPipeline(DataContainer& dataContainer, const std::string& pipelineName)
: AbstractPipeline(dc) : AbstractPipeline(dataContainer)
, _pipelineName(pipelineName)
{ {
} }
AutoEvaluationPipeline::~AutoEvaluationPipeline() { AutoEvaluationPipeline::~AutoEvaluationPipeline() {
} }
std::string AutoEvaluationPipeline::getName() const {
return _pipelineName;
}
void AutoEvaluationPipeline::init() { void AutoEvaluationPipeline::init() {
AbstractPipeline::init(); AbstractPipeline::init();
} }
......
...@@ -38,16 +38,17 @@ namespace campvis { ...@@ -38,16 +38,17 @@ namespace campvis {
* Specializtaion of AbstractPipeline performing automatic execution of invalidated processors. * Specializtaion of AbstractPipeline performing automatic execution of invalidated processors.
* AutoEvaluationPipeline connects to the s_(in)validated signals of all of its processors and * AutoEvaluationPipeline connects to the s_(in)validated signals of all of its processors and
* executes processors with invalid results using the correct threads. * executes processors with invalid results using the correct threads.
*
* \param dc Pointer to the DataContainer containing local working set of data for this
* pipeline, must not be 0, must be valid the whole lifetime of this pipeline.
*/ */
class CAMPVIS_CORE_API AutoEvaluationPipeline : public AbstractPipeline { class CAMPVIS_CORE_API AutoEvaluationPipeline : public AbstractPipeline {
public: public:
/** /**
* Creates a AutoEvaluationPipeline. * Creates a AutoEvaluationPipeline.
*
* \param dataContainer Reference to the DataContainer containing local working set of data
* for this pipeline, must be valid the whole lifetime of this pipeline.
* \param pipelineName Name of this pipeline.
*/ */
explicit AutoEvaluationPipeline(DataContainer* dc); AutoEvaluationPipeline(DataContainer& dataContainer, const std::string& pipelineName);
/** /**
* Virtual Destructor * Virtual Destructor
...@@ -55,16 +56,18 @@ namespace campvis { ...@@ -55,16 +56,18 @@ namespace campvis {
virtual ~AutoEvaluationPipeline(); virtual ~AutoEvaluationPipeline();
/// \see AbstractPipeline::getName()
virtual std::string getName() const override;
/// \see AbstractPipeline::init() /// \see AbstractPipeline::init()
virtual void init(); virtual void init() override;
/// \see AbstractPipeline::deinit() /// \see AbstractPipeline::deinit()
virtual void deinit(); virtual void deinit() override;
/// \see AbstractPipeline::addProcessor() /// \see AbstractPipeline::addProcessor()
virtual void addProcessor(AbstractProcessor* processor); virtual void addProcessor(AbstractProcessor* processor) override;
/// \see AbstractPipeline::executePipeline() /// \see AbstractPipeline::executePipeline()
virtual void executePipeline(); virtual void executePipeline() override;
protected: protected:
...@@ -75,6 +78,8 @@ namespace campvis { ...@@ -75,6 +78,8 @@ namespace campvis {
*/ */
virtual void onProcessorInvalidated(AbstractProcessor* processor); virtual void onProcessorInvalidated(AbstractProcessor* processor);
std::string _pipelineName; ///< Name of this pipeline
static const std::string loggerCat_; static const std::string loggerCat_;
private: private:
......
...@@ -60,7 +60,7 @@ namespace campvis { ...@@ -60,7 +60,7 @@ namespace campvis {
return toReturn; return toReturn;
} }
AbstractPipeline* PipelineFactory::createPipeline(const std::string& id, DataContainer* dc) const { AbstractPipeline* PipelineFactory::createPipeline(const std::string& id, DataContainer& dc) const {
tbb::spin_mutex::scoped_lock lock(_mutex); tbb::spin_mutex::scoped_lock lock(_mutex);
auto it = _pipelineMap.find(id); auto it = _pipelineMap.find(id);
......
...@@ -62,7 +62,7 @@ namespace campvis { ...@@ -62,7 +62,7 @@ namespace campvis {
std::vector<std::string> getRegisteredPipelines() const; std::vector<std::string> getRegisteredPipelines() const;
AbstractPipeline* createPipeline(const std::string& id, DataContainer* dc) const; AbstractPipeline* createPipeline(const std::string& id, DataContainer& dc) const;
AbstractWorkflow* createWorkflow(const std::string& id) const; AbstractWorkflow* createWorkflow(const std::string& id) const;
...@@ -73,7 +73,7 @@ namespace campvis { ...@@ -73,7 +73,7 @@ namespace campvis {
* \return The registration index. * \return The registration index.
*/ */
template<typename T> template<typename T>
size_t registerPipeline(std::function<AbstractPipeline*(DataContainer*)> callee) { size_t registerPipeline(std::function<AbstractPipeline*(DataContainer&)> callee) {
tbb::spin_mutex::scoped_lock lock(_mutex); tbb::spin_mutex::scoped_lock lock(_mutex);
auto it = _pipelineMap.lower_bound(T::getId()); auto it = _pipelineMap.lower_bound(T::getId());
...@@ -112,7 +112,7 @@ namespace campvis { ...@@ -112,7 +112,7 @@ namespace campvis {
mutable tbb::spin_mutex _mutex; mutable tbb::spin_mutex _mutex;
static tbb::atomic<PipelineFactory*> _singleton; ///< the singleton object static tbb::atomic<PipelineFactory*> _singleton; ///< the singleton object
std::map< std::string, std::function<AbstractPipeline*(DataContainer*)> > _pipelineMap; std::map< std::string, std::function<AbstractPipeline*(DataContainer&)> > _pipelineMap;
std::map< std::string, std::function<AbstractWorkflow*()> > _workflowMap; std::map< std::string, std::function<AbstractWorkflow*()> > _workflowMap;
}; };
...@@ -128,7 +128,7 @@ namespace campvis { ...@@ -128,7 +128,7 @@ namespace campvis {
* \param dc DataContainer for the created pipeline to work on. * \param dc DataContainer for the created pipeline to work on.
* \return A newly created pipeline of type T. Caller has to take ownership of the pointer. * \return A newly created pipeline of type T. Caller has to take ownership of the pointer.
*/ */
static AbstractPipeline* create(DataContainer* dc) { static AbstractPipeline* create(DataContainer& dc) {
return new T(dc); return new T(dc);
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include "tbb/recursive_mutex.h" #include "tbb/recursive_mutex.h"
#include "ext/cgt/logmanager.h"
#include "ext/sigslot/sigslot.h" #include "ext/sigslot/sigslot.h"
%} %}
...@@ -52,7 +53,7 @@ namespace sigslot { ...@@ -52,7 +53,7 @@ namespace sigslot {
swig_type_info* typeInfo = SWIG_TypeQuery(typeName); swig_type_info* typeInfo = SWIG_TypeQuery(typeName);
if (typeInfo == nullptr) { if (typeInfo == nullptr) {
std::cerr << "SWIG wrapper for " << typeName << " not found" << std::endl; LogMgr.log("Lua", cgt::LuaError, "SWIG wrapper for " + std::string(typeName) + " not found");
} }
return std::make_pair(arg, typeInfo); return std::make_pair(arg, typeInfo);
...@@ -232,9 +233,9 @@ namespace sigslot { ...@@ -232,9 +233,9 @@ namespace sigslot {
const char* errorMsg = lua_tostring(_slot_fn.L, -1); const char* errorMsg = lua_tostring(_slot_fn.L, -1);
if (errorMsg == nullptr) if (errorMsg == nullptr)
std::cerr << "(error object is not a string)" << std::endl; LogMgr.log("Lua", cgt::LuaError, "(error object is not a string)");
else else
std::cerr << "An error occured while calling a Lua slot function: " << errorMsg << std::endl; LogMgr.log("Lua", cgt::LuaError, "An error occured while calling a Lua slot function: " + std::string(errorMsg));
lua_pop(_slot_fn.L, 1); lua_pop(_slot_fn.L, 1);
} }
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
namespace campvis { namespace campvis {
AdvancedUsVis::AdvancedUsVis(DataContainer* dc) AdvancedUsVis::AdvancedUsVis(DataContainer& dc)
: AutoEvaluationPipeline(dc) : AutoEvaluationPipeline(dc, getId())
, _usReader() , _usReader()
, _confidenceReader() , _confidenceReader()
, _usFusion1(&_canvasSize) , _usFusion1(&_canvasSize)
......
...@@ -38,9 +38,11 @@ namespace campvis { ...@@ -38,9 +38,11 @@ namespace campvis {
class CAMPVIS_MODULES_API AdvancedUsVis : public AutoEvaluationPipeline { class CAMPVIS_MODULES_API AdvancedUsVis : public AutoEvaluationPipeline {
public: public: