13 #ifndef QmitkDataGeneratorBase_h
14 #define QmitkDataGeneratorBase_h
171 using InputPairVectorType = std::vector<std::pair<mitk::DataNode::ConstPointer, mitk::DataNode::ConstPointer>>;
268 bool m_AutoUpdate =
false;
278 mutable bool m_InGenerate =
false;
280 mutable bool m_RestartGeneration =
false;
282 mutable bool m_WIP =
false;
284 mutable bool m_AddingToStorage =
false;
289 unsigned long m_DataStorageDeletedTag;
#define MITKIMAGESTATISTICSUI_EXPORT
Base class for background data generation jobs used by QmitkDataGeneratorBase and derived classes.
std::map< std::string, mitk::BaseData::Pointer > ResultMapType
Map type for results produced by the job.
Base class that orchestrates asynchronous data generation for image/ROI pairs.
mitk::WeakPointer< mitk::DataStorage > m_Storage
virtual bool ChangedNodeIsRelevant(const mitk::DataNode *changedNode) const =0
Determines whether a changed data node is relevant and should trigger a regeneration.
void NewDataAvailable(mitk::DataStorage::SetOfObjects::ConstPointer data) const
Emitted when new final result data has been produced and added to the data storage.
itk::TimeStamp m_GenerationTime
void SetAutoUpdate(bool autoUpdate)
Enables or disables automatic update on data changes.
QmitkDataGenerationJobBase::ResultMapType JobResultMapType
Alias for the result map type produced by generation jobs.
QmitkDataGeneratorBase(QObject *parent=nullptr)
Constructs a generator without an initial data storage.
std::string GetPairDescription(const InputPairVectorType::value_type &imageAndSeg) const
Returns a human-readable description of an image/ROI pair for debug logging.
mitk::DataStorage::Pointer GetDataStorage() const
Returns the data storage used by this generator.
virtual ~QmitkDataGeneratorBase()
virtual mitk::DataNode::Pointer PrepareResultForStorage(const std::string &label, mitk::BaseData *result, const QmitkDataGenerationJobBase *job) const =0
Wraps a generation result in a data node suitable for storage.
virtual bool IsValidResultAvailable(const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0
Checks whether a valid final result exists for the given image and ROI.
bool DoGenerate() const
Core generation loop that checks validity and launches jobs for all image/ROI pairs.
void OnFinalResultsAvailable(JobResultMapType results, const QmitkDataGenerationJobBase *job) const
Handles completed job results, adds them to the data storage, and emits NewDataAvailable.
bool IsGenerating() const
Returns whether data generation jobs are currently running or pending.
void GenerationFinished() const
Emitted when all generation jobs have finished and all results are up to date.
void JobError(QString error, const QmitkDataGenerationJobBase *failedJob) const
Emitted when a generation job encounters an error.
void EnsureRecheckingAndGeneration() const
Ensures generation is (re)started, either immediately or by flagging a restart if already running.
virtual void RemoveObsoleteDataNodes(const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0
Removes obsolete result nodes for the given image/ROI pair from the data storage.
virtual void IndicateFutureResults(const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0
Adds placeholder nodes and WIP dummy data to the data storage for missing or outdated results.
void DataGenerationStarted(const mitk::DataNode *imageNode, const mitk::DataNode *roiNode, const QmitkDataGenerationJobBase *job) const
Emitted when a data generation job is started for outdated or missing data.
QmitkDataGeneratorBase(const QmitkDataGeneratorBase &other)=delete
InputPairVectorType FilterImageROICombinations(InputPairVectorType &&imageROICombinations) const
Filters image/ROI pairs to only include those whose nodes exist in the data storage.
bool GetAutoUpdate() const
Returns whether automatic updates are enabled.
bool Generate() const
Checks data validity and triggers generation of missing or outdated data.
void SetDataStorage(mitk::DataStorage *storage)
Sets the data storage for monitoring, storing WIP placeholders, and final results.
std::vector< std::pair< mitk::DataNode::ConstPointer, mitk::DataNode::ConstPointer > > InputPairVectorType
Vector of image/ROI node pairs used as input for generation.
static mitk::DataNode::Pointer CreateWIPDataNode(mitk::BaseData *dataDummy, const std::string &nodeName)
Creates a WIP placeholder data node for future results.
QmitkDataGeneratorBase & operator=(const QmitkDataGeneratorBase &other)=delete
QmitkDataGeneratorBase(mitk::DataStorage::Pointer storage, QObject *parent=nullptr)
Constructs a generator with the given data storage.
void OnJobError(QString error, const QmitkDataGenerationJobBase *failedJob) const
Handles error signals from generation jobs and re-emits JobError.
virtual std::pair< QmitkDataGenerationJobBase *, mitk::DataNode::Pointer > GetNextMissingGenerationJob(const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0
Returns the next generation job and its associated placeholder node.
virtual InputPairVectorType GetAllImageROICombinations() const =0
Returns all image/ROI pairs for which data generation is needed.
Base class of all data objects.
Central node class of the MITK data tree, associating a data object with properties and mappers.
Abstract data management class that organizes DataNode objects in a directed acyclic graph.