ITK  5.2.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  * http://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  itkTypeMacro(DataObjectError, ExceptionObject);
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 
91 
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 
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  itkTypeMacro(DataObject, Object);
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 
341  virtual void
342  Initialize();
343 
346  void
348  {
349  m_ReleaseDataFlag = flag;
350  }
351 
352  itkGetConstReferenceMacro(ReleaseDataFlag, bool);
353  itkBooleanMacro(ReleaseDataFlag);
354 
358  static void
359  SetGlobalReleaseDataFlag(bool val);
360 
361  static bool
362  GetGlobalReleaseDataFlag();
363 
364  static void
366  {
367  Self::SetGlobalReleaseDataFlag(true);
368  }
369  static void
371  {
372  Self::SetGlobalReleaseDataFlag(false);
373  }
374 
379  void
380  ReleaseData();
381 
384  bool
385  ShouldIReleaseData() const;
386 
388  bool
390  {
391  return m_DataReleased;
392  }
393 
404  virtual void
405  Update();
406 
416  virtual void
417  UpdateOutputInformation();
418 
421  virtual void
422  PropagateRequestedRegion();
423 
424  virtual void
425  UpdateOutputData();
426 
430  virtual void
431  ResetPipeline();
432 
435  void
437  {
438  m_PipelineMTime = time;
439  }
440  itkGetConstReferenceMacro(PipelineMTime, ModifiedTimeType);
442 
444  virtual ModifiedTimeType
445  GetUpdateMTime() const;
446 
452  itkSetMacro(RealTimeStamp, RealTimeStamp);
453  itkGetConstReferenceMacro(RealTimeStamp, RealTimeStamp);
455 
464  virtual void
466  {
467  this->Initialize();
468  }
469 
474  virtual void
475  DataHasBeenGenerated();
476 
480  virtual void
482  {}
483 
493  virtual bool
495  {
496  return false;
497  }
498 
511  virtual bool
513  {
514  return true;
515  }
516 
526  virtual void
528  {}
529 
535  virtual void
537  {}
538 
544  virtual void
545  Graft(const DataObject *)
546  {}
547 
548 protected:
549  DataObject();
550  ~DataObject() override;
551  void
552  PrintSelf(std::ostream & os, Indent indent) const override;
553 
555  virtual void
556  PropagateResetPipeline();
557 
558 private:
562 
568 
571 
572  bool m_ReleaseDataFlag; // Data will release after use by a filter if on
573  bool m_DataReleased; // Keep track of data release during pipeline execution
574 
578 
580  static bool * m_GlobalReleaseDataFlag;
581 
586  bool
587  ConnectSource(ProcessObject * arg, const DataObjectIdentifierType & name);
588 
597  bool
598  DisconnectSource(ProcessObject * arg, const DataObjectIdentifierType & name);
599 
601  itkGetGlobalDeclarationMacro(bool, GlobalReleaseDataFlag);
602 
603 
605  friend class ProcessObject;
606  friend class DataObjectError;
607 };
608 } // end namespace itk
609 
610 #endif
itk::DataObject::SetRequestedRegionToLargestPossibleRegion
virtual void SetRequestedRegionToLargestPossibleRegion()
Definition: itkDataObject.h:481
itkObjectFactory.h
itk::DataObject::RequestedRegionIsOutsideOfTheBufferedRegion
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
Definition: itkDataObject.h:494
itk::DataObject::CopyInformation
virtual void CopyInformation(const DataObject *)
Definition: itkDataObject.h:527
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:102
itkWeakPointer.h
itk::DataObject::SetPipelineMTime
void SetPipelineMTime(ModifiedTimeType time)
Definition: itkDataObject.h:436
itk::DataObject::m_ReleaseDataFlag
bool m_ReleaseDataFlag
Definition: itkDataObject.h:572
itk::DataObject::PrepareForNewData
virtual void PrepareForNewData()
Definition: itkDataObject.h:465
itk::DataObject::DataObjectPointerArraySizeType
std::vector< Pointer >::size_type DataObjectPointerArraySizeType
Definition: itkDataObject.h:335
itk::DataObject::Graft
virtual void Graft(const DataObject *)
Definition: itkDataObject.h:545
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::m_DataReleased
bool m_DataReleased
Definition: itkDataObject.h:573
itk::DataObject::GetDataReleased
bool GetDataReleased() const
Definition: itkDataObject.h:389
itk::DataObject::m_GlobalReleaseDataFlag
static bool * m_GlobalReleaseDataFlag
Definition: itkDataObject.h:580
itk::DataObject::GlobalReleaseDataFlagOff
static void GlobalReleaseDataFlagOff()
Definition: itkDataObject.h:370
itk::DataObject::m_RealTimeStamp
RealTimeStamp m_RealTimeStamp
Definition: itkDataObject.h:570
itk::DataObject::m_SourceOutputName
DataObjectIdentifierType m_SourceOutputName
Definition: itkDataObject.h:561
itkMacro.h
itk::DataObject::SetReleaseDataFlag
void SetReleaseDataFlag(bool flag)
Definition: itkDataObject.h:347
itk::DataObject::m_PipelineMTime
ModifiedTimeType m_PipelineMTime
Definition: itkDataObject.h:577
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::DataObject::m_Source
WeakPointer< ProcessObject > m_Source
Definition: itkDataObject.h:560
itk::DataObject::m_UpdateMTime
TimeStamp m_UpdateMTime
Definition: itkDataObject.h:567
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:512
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: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itkGetGlobalDeclarationMacro
#define itkGetGlobalDeclarationMacro(Type, VarName)
Definition: itkSingletonMacro.h:35
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::DataObject::GlobalReleaseDataFlagOn
static void GlobalReleaseDataFlagOn()
Definition: itkDataObject.h:365
itk::DataObject::SetRequestedRegion
virtual void SetRequestedRegion(const DataObject *)
Definition: itkDataObject.h:536
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itkRealTimeStamp.h