ITK  6.0.0
Insight Toolkit
itkDataObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkDataObject_h
29 #define itkDataObject_h
30 
31 #include "itkObject.h"
32 #include "itkMacro.h"
33 #include "itkSingletonMacro.h"
34 #include "itkWeakPointer.h"
35 #include "itkRealTimeStamp.h"
36 #include "itkObjectFactory.h"
37 
38 namespace itk
39 {
40 // Forward reference because of circular dependencies
41 class ITK_FORWARD_EXPORT ProcessObject;
42 class ITK_FORWARD_EXPORT DataObject;
43 
44 /*--------------------Data Object Exceptions---------------------------*/
45 
51 class ITKCommon_EXPORT DataObjectError : public ExceptionObject
52 {
53 public:
54 
57  DataObjectError() noexcept;
58 
60  ~DataObjectError() noexcept override = default;
61 
63  DataObjectError(const char * file, unsigned int lineNumber);
64 
66  DataObjectError(const std::string & file, unsigned int lineNumber);
67 
69  DataObjectError(const DataObjectError & orig) noexcept;
70 
73  operator=(const DataObjectError & orig) noexcept;
74 
76  itkOverrideGetNameOfClassMacro(DataObjectError);
77 
79  void
80  SetDataObject(DataObject * dobj) noexcept;
81 
82 
84  const DataObject *
85  GetDataObject() const noexcept;
86 #if !defined(ITK_LEGACY_REMOVE)
87  DataObject *
88  GetDataObject() noexcept;
89 #endif
90 
92 protected:
97  virtual void
98  PrintSelf(std::ostream & os, Indent indent) const;
99 
100 private:
101  DataObject * m_DataObject{ nullptr };
102 };
103 
111 class ITKCommon_EXPORT InvalidRequestedRegionError : public DataObjectError
112 {
113 public:
114 
117  InvalidRequestedRegionError() noexcept;
118 
120  ~InvalidRequestedRegionError() noexcept override = default;
121 
123  InvalidRequestedRegionError(const char * file, unsigned int lineNumber);
124 
126  InvalidRequestedRegionError(const std::string & file, unsigned int lineNumber);
127 
130 
133  operator=(const InvalidRequestedRegionError & orig) noexcept;
134 
136  itkOverrideGetNameOfClassMacro(InvalidRequestedRegionError);
137 
138 protected:
143  void
144  PrintSelf(std::ostream & os, Indent indent) const override;
145 };
146 
147 /*----------------------------Data Object--------------------------------*/
148 
293 class ITK_FORCE_EXPORT_MACRO(ITKCommon) DataObject : public Object
294 {
295 public:
296  ITK_DISALLOW_COPY_AND_MOVE(DataObject);
297 
299  using Self = DataObject;
303 
304  using DataObjectIdentifierType = std::string;
305 
307  itkOverrideGetNameOfClassMacro(DataObject);
308 
310  itkSimpleNewMacro(DataObject);
311 
317  void
318  DisconnectPipeline();
319 
328  GetSource() const;
329 
332  GetSourceOutputName() const;
333 
335  using DataObjectPointerArraySizeType = std::vector<Pointer>::size_type;
337  GetSourceOutputIndex() const;
338 
340  void
341  UpdateSource() const;
342 
345  virtual void
346  Initialize();
347 
350  void
352  {
353  m_ReleaseDataFlag = flag;
354  }
355 
356  itkGetConstReferenceMacro(ReleaseDataFlag, bool);
357  itkBooleanMacro(ReleaseDataFlag);
358 
362  static void
363  SetGlobalReleaseDataFlag(bool val);
364 
365  static bool
366  GetGlobalReleaseDataFlag();
367 
368  static void
370  {
371  Self::SetGlobalReleaseDataFlag(true);
372  }
373  static void
375  {
376  Self::SetGlobalReleaseDataFlag(false);
377  }
378 
383  void
384  ReleaseData();
385 
388  bool
389  ShouldIReleaseData() const;
390 
392  bool
394  {
395  return m_DataReleased;
396  }
397 
408  virtual void
409  Update();
410 
420  virtual void
421  UpdateOutputInformation();
422 
425  virtual void
426  PropagateRequestedRegion();
427 
428  virtual void
429  UpdateOutputData();
430 
434  virtual void
435  ResetPipeline();
436 
439  void
441  {
442  m_PipelineMTime = time;
443  }
444  itkGetConstReferenceMacro(PipelineMTime, ModifiedTimeType);
448  virtual ModifiedTimeType
449  GetUpdateMTime() const;
450 
456  itkSetMacro(RealTimeStamp, RealTimeStamp);
457  itkGetConstReferenceMacro(RealTimeStamp, RealTimeStamp);
468  virtual void
470  {
471  this->Initialize();
472  }
473 
478  virtual void
479  DataHasBeenGenerated();
480 
484  virtual void
486  {}
487 
497  virtual bool
499  {
500  return false;
501  }
502 
515  virtual bool
517  {
518  return true;
519  }
520 
530  virtual void
532  {}
533 
539  virtual void
541  {}
542 
548  virtual void
549  Graft(const DataObject *)
550  {}
551 
552 protected:
553  DataObject();
554  ~DataObject() override;
555  void
556  PrintSelf(std::ostream & os, Indent indent) const override;
557 
559  virtual void
560  PropagateResetPipeline();
561 
562 private:
565  DataObjectIdentifierType m_SourceOutputName{};
566 
571  TimeStamp m_UpdateMTime{};
572 
574  RealTimeStamp m_RealTimeStamp{};
575 
576  bool m_ReleaseDataFlag{}; // Data will release after use by a filter if on
577  bool m_DataReleased{}; // Keep track of data release during pipeline execution
578 
581  ModifiedTimeType m_PipelineMTime{};
582 
584  static bool * m_GlobalReleaseDataFlag;
585 
590  bool
591  ConnectSource(ProcessObject * arg, const DataObjectIdentifierType & name);
592 
601  bool
602  DisconnectSource(ProcessObject * arg, const DataObjectIdentifierType & name);
603 
605  itkGetGlobalDeclarationMacro(bool, GlobalReleaseDataFlag);
606 
607 
609  friend class ProcessObject;
610  friend class DataObjectError;
611 };
612 } // end namespace itk
613 
614 #endif
itk::DataObject::SetRequestedRegionToLargestPossibleRegion
virtual void SetRequestedRegionToLargestPossibleRegion()
Definition: itkDataObject.h:485
itkObjectFactory.h
itk::DataObject::RequestedRegionIsOutsideOfTheBufferedRegion
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
Definition: itkDataObject.h:498
itk::DataObject::CopyInformation
virtual void CopyInformation(const DataObject *)
Definition: itkDataObject.h:531
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:105
itkWeakPointer.h
itk::DataObject::SetPipelineMTime
void SetPipelineMTime(ModifiedTimeType time)
Definition: itkDataObject.h:440
itk::DataObject::PrepareForNewData
virtual void PrepareForNewData()
Definition: itkDataObject.h:469
itk::DataObject::DataObjectPointerArraySizeType
std::vector< Pointer >::size_type DataObjectPointerArraySizeType
Definition: itkDataObject.h:335
itk::DataObject::Graft
virtual void Graft(const DataObject *)
Definition: itkDataObject.h:549
itk::RealTimeStamp
The RealTimeStamp is a data structure for representing time with high precision and a large dynamic r...
Definition: itkRealTimeStamp.h:45
itkSingletonMacro.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::DataObject::GetDataReleased
bool GetDataReleased() const
Definition: itkDataObject.h:393
itk::DataObject::m_GlobalReleaseDataFlag
static bool * m_GlobalReleaseDataFlag
Definition: itkDataObject.h:584
itk::DataObject::GlobalReleaseDataFlagOff
static void GlobalReleaseDataFlagOff()
Definition: itkDataObject.h:374
itkMacro.h
itk::DataObject::SetReleaseDataFlag
void SetReleaseDataFlag(bool flag)
Definition: itkDataObject.h:351
itk::TimeStamp
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
itk::DataObject
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:42
itk::DataObject::DataObjectIdentifierType
std::string DataObjectIdentifierType
Definition: itkDataObject.h:304
itk::InvalidRequestedRegionError
Definition: itkDataObject.h:111
itk::DataObjectError
Exception object for DataObject exceptions.
Definition: itkDataObject.h:51
itkObject.h
itk::DataObject::VerifyRequestedRegion
virtual bool VerifyRequestedRegion()
Definition: itkDataObject.h:516
itk::WeakPointer
Implements a weak reference to an object.
Definition: itkWeakPointer.h:44
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itkGetGlobalDeclarationMacro
#define itkGetGlobalDeclarationMacro(Type, VarName)
Definition: itkSingletonMacro.h:34
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::DataObject::GlobalReleaseDataFlagOn
static void GlobalReleaseDataFlagOn()
Definition: itkDataObject.h:369
itk::DataObject::SetRequestedRegion
virtual void SetRequestedRegion(const DataObject *)
Definition: itkDataObject.h:540
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itkRealTimeStamp.h