[Insight-users] DataObject inheritance problems

Luis Ibanez luis.ibanez@kitware.com
Fri, 21 Mar 2003 18:17:42 -0500


Hi Aaron,

The only visible strange thing is the line

 >
 > itkTypeMacro(itkUnaryCorrespondenceMatrix, DataObject);
 >


It probably should be:

   itkTypeMacro( UnaryCorrespondenceMatrix, DataObject);


but... still...
that shouldn't generate the error
you are receiveing..

Also note that your constructor and destructore should
be protected. while the UpdateOutputInformation() method
should be publid.



    Luis



------------------------
Aaron Cois wrote:
> I am attempting to create an object which derives from DataObject. Right 
> now the class has no real functionality to it, and the definition looks 
> like:
> 
> template<typename TItemType>
> class UnaryCorrespondenceMatrix : public DataObject{
> public:
> /** Standard class typedefs. */
> typedef UnaryCorrespondenceMatrix Self;
> typedef DataObject Superclass;
> typedef SmartPointer<Self>   Pointer;
> typedef SmartPointer<const Self>  ConstPointer;
> 
> /** Method for creation through the object factory */
> itkNewMacro(Self);
> 
> /** Run-time type information (and related methods) */
> itkTypeMacro(itkUnaryCorrespondenceMatrix, DataObject);
> 
> /** Default Constructor */
> UnaryCorrespondenceMatrix();
> 
> /** Default Destructor */
> ~UnaryCorrespondenceMatrix() {};
> 
> protected:
> 
> /** Virtual methods required by DataObject interface.   */
> void UpdateOutputInformation() {}
> bool VerifyRequestedRegion() { return true; }
> void SetRequestedRegionToLargestPossibleRegion () {}
> bool RequestedRegionIsOutsideOfTheBufferedRegion () { return false; }
> void SetRequestedRegion (DataObject *) {}
> 
> };
> 
> 
>   As far as i can tell this is all correct (I also have another class 
> similar to this one which works fine) but when i try to declare an 
> object using:
> 
> typedef itk::UnaryCorrespondenceMatrix<double> CorrespondenceMatrixType;
> typedef itk::UnaryCorrespondenceMatrix<double>::Pointer 
> CorrespondenceMatrixPointer;
> 
> CorrespondenceMatrixPointer corr_matrix;
> corr_matrix = CorrespondenceMatrixType::New();
> 
>   I get a linker error looking like:
> 
> ChimeraTest error LNK2001: unresolved external symbol "protected: 
> virtual void __thiscall 
> itk::UnaryCorrespondenceMatrix<double>::UpdateOutputInformation(void)" 
> (?UpdateOutputInformation@?$UnaryCorrespondenceMatrix@N@itk@@MAEXXZ)
> 
> 
> This is baffling me, since I have another class inheriting from 
> DataObject which is almost identical and works perfectly.  I only get 
> the linker error when I attempt to create the object using New() (if i 
> comment it out the error disappears).  Any help or information would be 
> sincerely appreciated.
> 
>   -Aaron
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>