ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkDataObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
37 namespace itk
38 {
39 // Forward reference because of circular dependencies
40 class ITK_FORWARD_EXPORT ProcessObject;
41 class ITK_FORWARD_EXPORT DataObject;
42 
43 /*--------------------Data Object Exceptions---------------------------*/
44 
49 class ITKCommon_EXPORT DataObjectError:public ExceptionObject
50 {
51 public:
54  DataObjectError() noexcept;
55 
57  ~DataObjectError() noexcept override = default;
58 
60  DataObjectError(const char *file, unsigned int lineNumber);
61 
63  DataObjectError(const std::string & file, unsigned int lineNumber);
64 
66  DataObjectError(const DataObjectError & orig) noexcept;
67 
69  DataObjectError & operator=(const DataObjectError & orig) noexcept;
70 
72  itkTypeMacro(DataObjectError, ExceptionObject);
73 
75  void SetDataObject(DataObject *dobj) noexcept;
76 
78  DataObject * GetDataObject() noexcept;
79 
80 protected:
85  virtual void PrintSelf(std::ostream & os, Indent indent) const;
86 
87 private:
88  DataObject *m_DataObject{nullptr};
89 };
90 
97 class ITKCommon_EXPORT InvalidRequestedRegionError:public DataObjectError
98 {
99 public:
102  InvalidRequestedRegionError() noexcept;
103 
105  ~InvalidRequestedRegionError() noexcept override = default;
106 
108  InvalidRequestedRegionError(const char *file, unsigned int lineNumber);
109 
111  InvalidRequestedRegionError(const std::string & file, unsigned int lineNumber);
112 
115 
117  InvalidRequestedRegionError & operator=(const InvalidRequestedRegionError & orig) noexcept;
118 
121 
122 protected:
127  void PrintSelf(std::ostream & os, Indent indent) const override;
128 };
129 
130 /*----------------------------Data Object--------------------------------*/
131 
275 class ITK_FORCE_EXPORT_MACRO(ITKCommon) DataObject:public Object
276 {
277 public:
278  ITK_DISALLOW_COPY_AND_ASSIGN(DataObject);
279 
281  using Self = DataObject;
285 
286  using DataObjectIdentifierType = std::string;
287 
289  itkTypeMacro(DataObject, Object);
290 
296  void DisconnectPipeline();
297 
305  SmartPointer< ProcessObject > GetSource() const;
306 
308  const DataObjectIdentifierType & GetSourceOutputName() const;
309 
311  using DataObjectPointerArraySizeType = std::vector< Pointer >::size_type;
312  DataObjectPointerArraySizeType GetSourceOutputIndex() const;
313 
316  virtual void Initialize();
317 
320  void SetReleaseDataFlag(bool flag)
321  {
322  m_ReleaseDataFlag = flag;
323  }
324 
325  itkGetConstReferenceMacro(ReleaseDataFlag, bool);
326  itkBooleanMacro(ReleaseDataFlag);
327 
331  static void SetGlobalReleaseDataFlag(bool val);
332 
333  static bool GetGlobalReleaseDataFlag();
334 
336  { Self::SetGlobalReleaseDataFlag(true); }
338  { Self::SetGlobalReleaseDataFlag(false); }
339 
344  void ReleaseData();
345 
348  bool ShouldIReleaseData() const;
349 
351  bool GetDataReleased() const
352  { return m_DataReleased; }
353 
364  virtual void Update();
365 
375  virtual void UpdateOutputInformation();
376 
379  virtual void PropagateRequestedRegion();
380 
381  virtual void UpdateOutputData();
382 
386  virtual void ResetPipeline();
387 
391  { m_PipelineMTime = time; }
392  itkGetConstReferenceMacro(PipelineMTime, ModifiedTimeType);
394 
396  virtual ModifiedTimeType GetUpdateMTime() const;
397 
403  itkSetMacro( RealTimeStamp, RealTimeStamp );
404  itkGetConstReferenceMacro( RealTimeStamp, RealTimeStamp );
406 
415  virtual void PrepareForNewData()
416  { this->Initialize(); }
417 
422  virtual void DataHasBeenGenerated();
423 
428 
439  { return false; }
440 
453  virtual bool VerifyRequestedRegion() { return true; }
454 
464  virtual void CopyInformation(const DataObject *) {}
465 
471  virtual void SetRequestedRegion(const DataObject *) {}
472 
478  virtual void Graft(const DataObject *) {}
479 
480 protected:
481  DataObject();
482  ~DataObject() override;
483  void PrintSelf(std::ostream & os, Indent indent) const override;
484 
486  virtual void PropagateResetPipeline();
487 
488 private:
492 
498 
501 
502  bool m_ReleaseDataFlag; //Data will release after use by a filter if on
503  bool m_DataReleased; //Keep track of data release during pipeline execution
504 
508 
511 
516  bool ConnectSource(ProcessObject *s, const DataObjectIdentifierType & name);
517 
526  bool DisconnectSource(ProcessObject *s, const DataObjectIdentifierType & name);
527 
529  itkGetGlobalDeclarationMacro(bool, GlobalReleaseDataFlag);
530 
531 
533  friend class ProcessObject;
534  friend class DataObjectError;
535 };
536 } // end namespace itk
537 
538 #endif
void SetPipelineMTime(ModifiedTimeType time)
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
static bool * m_GlobalReleaseDataFlag
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:41
Implements a weak reference to an object.
virtual void Graft(const DataObject *)
The RealTimeStamp is a data structure for representing time with high precision and a large dynamic r...
static void GlobalReleaseDataFlagOn()
#define itkGetGlobalDeclarationMacro(Type, VarName)
RealTimeStamp m_RealTimeStamp
void SetReleaseDataFlag(bool flag)
Standard exception handling object.
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
Exception object for DataObject exceptions.
Definition: itkDataObject.h:49
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:104
static void GlobalReleaseDataFlagOff()
WeakPointer< ProcessObject > m_Source
std::vector< Pointer >::size_type DataObjectPointerArraySizeType
virtual void SetRequestedRegion(const DataObject *)
bool GetDataReleased() const
virtual void CopyInformation(const DataObject *)
virtual void PrepareForNewData()
Control indentation during Print() invocation.
Definition: itkIndent.h:49
TimeStamp m_UpdateMTime
DataObjectIdentifierType m_SourceOutputName
virtual bool VerifyRequestedRegion()
Base class for most ITK classes.
Definition: itkObject.h:60
ModifiedTimeType m_PipelineMTime
std::string DataObjectIdentifierType
virtual void SetRequestedRegionToLargestPossibleRegion()
Base class for all data objects in ITK.