ITK  4.13.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"
33 #include "itkMacro.h"
34 #include "itkRealTimeStamp.h"
35 
36 namespace itk
37 {
38 // Forward reference because of circular dependencies
39 class ITK_FORWARD_EXPORT ProcessObject;
40 class ITK_FORWARD_EXPORT DataObject;
41 
42 /*--------------------Data Object Exceptions---------------------------*/
43 
48 class ITKCommon_EXPORT DataObjectError:public ExceptionObject
49 {
50 public:
54 
56  virtual ~DataObjectError() ITK_NOEXCEPT ITK_OVERRIDE {}
57 
59  DataObjectError(const char *file, unsigned int lineNumber);
60 
62  DataObjectError(const std::string & file, unsigned int lineNumber);
63 
65  DataObjectError(const DataObjectError & orig);
66 
68  DataObjectError & operator=(const DataObjectError & orig);
69 
71  itkTypeMacro(DataObjectError, ExceptionObject);
72 
74  void SetDataObject(DataObject *dobj);
75 
77  DataObject * GetDataObject();
78 
79 protected:
84  virtual void PrintSelf(std::ostream & os, Indent indent) const;
85 
86 private:
88 };
89 
96 class ITKCommon_EXPORT InvalidRequestedRegionError:public DataObjectError
97 {
98 public:
102 
104  virtual ~InvalidRequestedRegionError() ITK_NOEXCEPT ITK_OVERRIDE {}
105 
107  InvalidRequestedRegionError(const char *file, unsigned int lineNumber);
108 
110  InvalidRequestedRegionError(const std::string & file, unsigned int lineNumber);
111 
114 
117 
120 
121 protected:
126  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
127 };
128 
129 /*----------------------------Data Object--------------------------------*/
130 
274 class ITK_FORCE_EXPORT_MACRO(ITKCommon) DataObject:public Object
275 {
276 public:
278  typedef DataObject Self;
282 
283  typedef std::string DataObjectIdentifierType;
284 
286  itkTypeMacro(DataObject, Object);
287 
293  void DisconnectPipeline();
294 
308 
310  const DataObjectIdentifierType & GetSourceOutputName() const;
311 
313  typedef std::vector< Pointer >::size_type DataObjectPointerArraySizeType;
314  DataObjectPointerArraySizeType GetSourceOutputIndex() const;
315 
318  virtual void Initialize();
319 
322  void SetReleaseDataFlag(bool flag)
323  {
324  m_ReleaseDataFlag = flag;
325  }
326 
327  itkGetConstReferenceMacro(ReleaseDataFlag, bool);
328  itkBooleanMacro(ReleaseDataFlag);
329 
333  static void SetGlobalReleaseDataFlag(bool val);
334 
335  static bool GetGlobalReleaseDataFlag();
336 
338  { Self::SetGlobalReleaseDataFlag(true); }
340  { Self::SetGlobalReleaseDataFlag(false); }
341 
346  void ReleaseData();
347 
350  bool ShouldIReleaseData() const;
351 
353  bool GetDataReleased() const
354  { return m_DataReleased; }
355 
366  virtual void Update();
367 
377  virtual void UpdateOutputInformation();
378 
381  virtual void PropagateRequestedRegion();
382 
383  virtual void UpdateOutputData();
384 
388  virtual void ResetPipeline();
389 
393  { m_PipelineMTime = time; }
394  itkGetConstReferenceMacro(PipelineMTime, ModifiedTimeType);
396 
398  virtual ModifiedTimeType GetUpdateMTime() const;
399 
405  itkSetMacro( RealTimeStamp, RealTimeStamp );
406  itkGetConstReferenceMacro( RealTimeStamp, RealTimeStamp );
408 
417  virtual void PrepareForNewData()
418  { this->Initialize(); }
419 
424  virtual void DataHasBeenGenerated();
425 
430 
441  { return false; }
442 
455  virtual bool VerifyRequestedRegion() { return true; }
456 
466  virtual void CopyInformation(const DataObject *) {}
467 
473  virtual void SetRequestedRegion(const DataObject *) {}
474 
480  virtual void Graft(const DataObject *) {}
481 
482 protected:
483  DataObject();
484  virtual ~DataObject() ITK_OVERRIDE;
485  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
486 
488  virtual void PropagateResetPipeline();
489 
490 private:
491  ITK_DISALLOW_COPY_AND_ASSIGN(DataObject);
492 
494  WeakPointer< ProcessObject > m_Source;
495  DataObjectIdentifierType m_SourceOutputName;
496 
501  TimeStamp m_UpdateMTime;
502 
504  RealTimeStamp m_RealTimeStamp;
505 
506  bool m_ReleaseDataFlag; //Data will release after use by a filter if on
507  bool m_DataReleased; //Keep track of data release during pipeline execution
508 
511  ModifiedTimeType m_PipelineMTime;
512 
514  static bool m_GlobalReleaseDataFlag;
515 
520  bool ConnectSource(ProcessObject *s, const DataObjectIdentifierType & name);
521 
530  bool DisconnectSource(ProcessObject *s, const DataObjectIdentifierType & name);
531 
533  friend class ProcessObject;
534  friend class DataObjectError;
535 };
536 } // end namespace itk
537 
538 #endif
void SetPipelineMTime(ModifiedTimeType time)
std::string DataObjectIdentifierType
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:164
virtual ~DataObjectError() noexceptoverride
Definition: itkDataObject.h:56
std::vector< Pointer >::size_type DataObjectPointerArraySizeType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:40
SmartPointer< Self > Pointer
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()
SmartPointer< const Self > ConstPointer
DataObject Self
void SetReleaseDataFlag(bool flag)
Standard exception handling object.
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:59
Exception object for DataObject exceptions.
Definition: itkDataObject.h:48
static void GlobalReleaseDataFlagOff()
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
virtual bool VerifyRequestedRegion()
DataObject * m_DataObject
Definition: itkDataObject.h:87
Base class for most ITK classes.
Definition: itkObject.h:59
Implements transparent reference counting in situations where forward references / cyclic include dep...
virtual void SetRequestedRegionToLargestPossibleRegion()
virtual ~InvalidRequestedRegionError() noexceptoverride
Base class for all data objects in ITK.