ITK  4.6.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 class ProcessObject;
39 class DataObject;
40 
41 /*--------------------Data Object Exceptions---------------------------*/
42 
47 class ITKCommon_EXPORT DataObjectError:public ExceptionObject
48 {
49 public:
53 
55  virtual ~DataObjectError()
56  throw( ) {}
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 
105  throw( ) {}
106 
108  InvalidRequestedRegionError(const char *file, unsigned int lineNumber);
109 
111  InvalidRequestedRegionError(const std::string & file, unsigned int lineNumber);
112 
115 
118 
121 
122 protected:
127  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
128 };
129 
130 /*----------------------------Data Object--------------------------------*/
131 
275 class ITKCommon_EXPORT DataObject:public Object
276 {
277 public:
279  typedef DataObject Self;
283 
284  typedef std::string DataObjectIdentifierType;
285 
287  itkTypeMacro(DataObject, Object);
288 
294  void DisconnectPipeline();
295 
309 
311  const DataObjectIdentifierType & GetSourceOutputName() const;
312 
314  typedef std::vector< Pointer >::size_type DataObjectPointerArraySizeType;
315  DataObjectPointerArraySizeType GetSourceOutputIndex() const;
316 
319  virtual void Initialize();
320 
323  void SetReleaseDataFlag(bool flag)
324  {
325  m_ReleaseDataFlag = flag;
326  }
327 
328  itkGetConstReferenceMacro(ReleaseDataFlag, bool);
329  itkBooleanMacro(ReleaseDataFlag);
330 
334  static void SetGlobalReleaseDataFlag(bool val);
335 
336  static bool GetGlobalReleaseDataFlag();
337 
339  { Self::SetGlobalReleaseDataFlag(true); }
341  { Self::SetGlobalReleaseDataFlag(false); }
342 
347  void ReleaseData();
348 
351  bool ShouldIReleaseData() const;
352 
354  bool GetDataReleased() const
355  { return m_DataReleased; }
356 
367  virtual void Update();
368 
378  virtual void UpdateOutputInformation();
379 
382  virtual void PropagateRequestedRegion();
383 
384  virtual void UpdateOutputData();
385 
389  virtual void ResetPipeline();
390 
394  { m_PipelineMTime = time; }
395  itkGetConstReferenceMacro(PipelineMTime, ModifiedTimeType);
397 
399  virtual ModifiedTimeType GetUpdateMTime() const;
400 
406  itkSetMacro( RealTimeStamp, RealTimeStamp );
407  itkGetConstReferenceMacro( RealTimeStamp, RealTimeStamp );
409 
418  virtual void PrepareForNewData()
419  { this->Initialize(); }
420 
425  virtual void DataHasBeenGenerated();
426 
431 
442  { return false; }
443 
456  virtual bool VerifyRequestedRegion() { return true; }
457 
467  virtual void CopyInformation(const DataObject *) {}
468 
474  virtual void SetRequestedRegion(const DataObject *) {}
475 
481  virtual void Graft(const DataObject *) {}
482 
483 protected:
484  DataObject();
485  ~DataObject();
486  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
487 
489  virtual void PropagateResetPipeline();
490 
491 private:
492  DataObject(const Self &); //purposely not implemented
493  void operator=(const Self &); //purposely not implemented
494 
498 
504 
507 
508  bool m_ReleaseDataFlag; //Data will release after use by a filter if on
509  bool m_DataReleased; //Keep track of data release during pipeline execution
510 
514 
517 
522  bool ConnectSource(ProcessObject *s, const DataObjectIdentifierType & name);
523 
532  bool DisconnectSource(ProcessObject *s, const DataObjectIdentifierType & name);
533 
535  friend class ProcessObject;
536  friend class DataObjectError;
537 };
538 } // end namespace itk
539 
540 #endif
void SetPipelineMTime(ModifiedTimeType time)
std::string DataObjectIdentifierType
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:164
std::vector< Pointer >::size_type DataObjectPointerArraySizeType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
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
RealTimeStamp m_RealTimeStamp
void SetReleaseDataFlag(bool flag)
Standard exception handling object.
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:58
Exception object for DataObject exceptions.
Definition: itkDataObject.h:47
static void GlobalReleaseDataFlagOff()
WeakPointer< ProcessObject > m_Source
virtual void SetRequestedRegion(const DataObject *)
bool GetDataReleased() const
virtual void CopyInformation(const DataObject *)
static bool m_GlobalReleaseDataFlag
virtual void PrepareForNewData()
Control indentation during Print() invocation.
Definition: itkIndent.h:49
TimeStamp m_UpdateMTime
DataObjectIdentifierType m_SourceOutputName
virtual bool VerifyRequestedRegion()
DataObject * m_DataObject
Definition: itkDataObject.h:87
Base class for most ITK classes.
Definition: itkObject.h:57
ModifiedTimeType m_PipelineMTime
virtual ~DataObjectError()
Definition: itkDataObject.h:55
Implements transparent reference counting in situations where forward references / cyclic include dep...
virtual void SetRequestedRegionToLargestPossibleRegion()
Base class for all data objects in ITK.