14#include "mitkUIDGenerator.h"
18#include <usGetModuleContext.h>
20#include <usServiceProperties.h>
21#include <usModuleContext.h>
29:
itk::ProcessObject(), m_Name(
"NavigationDataSource (no defined type)"), m_IsFrozen(false), m_ToolMetaDataCollection(
mitk::
NavigationToolStorage::New())
39 if (this->GetNumberOfIndexedOutputs() < 1)
42 return static_cast<NavigationData*
>(this->ProcessObject::GetPrimaryOutput());
48 if ( out ==
nullptr && this->ProcessObject::GetOutput(idx) !=
nullptr )
50 itkWarningMacro (<<
"Unable to convert output number " << idx <<
" to type " <<
typeid(
NavigationData ).name () );
57 DataObjectPointerArray outputs = this->GetOutputs();
58 for (DataObjectPointerArray::iterator it = outputs.begin(); it != outputs.end(); ++it)
59 if (navDataName == (
static_cast<NavigationData*
>(it->GetPointer()))->GetName())
66 DataObjectPointerArray outputs = this->GetOutputs();
67 for (DataObjectPointerArray::size_type i = 0; i < outputs.size(); ++i)
68 if (navDataName == (
static_cast<NavigationData*
>(outputs.at(i).GetPointer()))->GetName())
70 throw std::invalid_argument(
"output name does not exist");
75 us::ModuleContext* context = us::GetModuleContext();
78 us::ServiceProperties props;
79 mitk::UIDGenerator uidGen = mitk::UIDGenerator (
"org.mitk.services.NavigationDataSource.id_");
80 props[ US_PROPKEY_ID ] = uidGen.GetUID();
81 props[ US_PROPKEY_DEVICENAME ] = m_Name;
82 m_ServiceRegistration = context->RegisterService(
this, props);
86 if (m_ServiceRegistration !=
nullptr) m_ServiceRegistration.Unregister();
87 m_ServiceRegistration = 0;
91 return this->m_ServiceRegistration.GetReference().GetProperty(US_PROPKEY_ID).ToString();
96 this->GraftNthOutput(0, graft);
101 if ( idx >= this->GetNumberOfIndexedOutputs() )
103 itkExceptionMacro(<<
"Requested to graft output " << idx <<
104 " but this filter only has " << this->GetNumberOfIndexedOutputs() <<
" Outputs.");
109 itkExceptionMacro(<<
"Requested to graft output with a nullptr pointer object" );
112 itk::DataObject* output = this->GetOutput(idx);
115 itkExceptionMacro(<<
"Requested to graft output that is a nullptr pointer" );
118 output->Graft( graft );
123 return mitk::NavigationData::New().GetPointer();
128 itkDebugMacro(
"MakeOutput(" << name <<
")");
129 if( this->IsIndexedOutputName(name) )
131 return this->MakeOutput( this->MakeIndexFromOutputName(name) );
133 return static_cast<itk::DataObject *
>(mitk::NavigationData::New().GetPointer());
138 mitk::PropertyList::Pointer p = mitk::PropertyList::New();
141 return mitk::PropertyList::ConstPointer(p);
156 if (idx >= this->GetNumberOfIndexedOutputs()) {
return mitk::NavigationTool::New(); }
157 else {
return GetToolMetaData(this->GetOutput(idx)->GetName()); }
162 mitk::NavigationTool::Pointer returnValue = m_ToolMetaDataCollection->GetToolByName(navDataName);
163 if (returnValue ==
nullptr) { returnValue = mitk::NavigationTool::New(); }
~NavigationDataSource() override
virtual void GraftOutput(itk::DataObject *graft)
Graft the specified DataObject onto this ProcessObject's output.
itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
virtual void GraftNthOutput(unsigned int idx, itk::DataObject *graft)
Graft the specified DataObject onto this ProcessObject's output.
NavigationData * GetOutput(void)
return the output (output with id 0) of the filter
std::string GetMicroserviceID()
Returns the id that this device is registered with. The id will only be valid, if the NavigationDataS...
virtual void RegisterAsMicroservice()
Registers this object as a Microservice, making it available to every module and/or plugin....
static const std::string US_PROPKEY_ID
virtual mitk::PropertyList::ConstPointer GetParameters() const
Get all filter parameters as a PropertyList.
DataObjectPointerArraySizeType GetOutputIndex(std::string navDataName)
return the index of the output with name navDataName, -1 if no output with that name was found
static const std::string US_PROPKEY_DEVICENAME
static const std::string US_PROPKEY_ISACTIVE
virtual void UnRegisterMicroservice()
Registers this object as a Microservice, making it available to every module and/or plugin.
static const std::string US_INTERFACE_NAME
These Constants are used in conjunction with Microservices.
NavigationTool::Pointer GetToolMetaData(DataObjectPointerArraySizeType idx)