[Insight-developers] MetaDataObject Checkins

Miller, James V (Research) millerjv@crd.ge.com
Mon, 10 Mar 2003 12:23:00 -0500


What is wrong with relying on having operator<< defined?



> -----Original Message-----
> From: Hans Johnson [mailto:hjohnson@mail.psychiatry.uiowa.edu]
> Sent: Monday, March 10, 2003 11:06 AM
> To: Insight-developers@public.kitware.com
> Subject: Re: [Insight-developers] MetaDataObject Checkins
> 
> 
> Bill,
> 
> 2)-------------
> Can you tell me what part of the specializations is not portable?
> 
> The idea behind the itkMetaDataObject is that it can encapsulate
> anything.  Because of that I made a default
> itk::MetaDataObject<T>::PrintSelf that just printed a string stating
> that the type can not print itself.  Then specializations of that
> function could be written for cases where print self was well defined.
> 
> For example, encapsulating a native C types would be done with the
> trivial implementations of:
> itk::MetaDataObject<int>
> ::PrintSelf(std::ostream& os, Indent indent) const
> {
>     os << indent << this->m_MetaDataObjectValue << std::endl;
> }
> 
> whereas encapsulating an itk::Image would use:
> 
> itk::MetaDataObject<int>
> ::PrintSelf(std::ostream& os, Indent indent) const
> {
>     this->m_MetaDataObjectValue->PrintSelf(os,indent);
> }
> 
> and non itk-application developers could write:
> itk::MetaDataObject<MyElephantClass>
> ::PrintSelf(std::ostream& os, Indent indent) const
> {
>     std::cout << indent
>               << this->m_MetaDataObjectValue->GetTrunk()
>               << " "
>               << this->m_MetaDataObjectValue->GetEars()
>               << " "
>               << this->m_MetaDataObjectValue->GetTail()
>               << std::endl;
> }
> 
> The current implementation will have to be changed, because 
> it will work
> only for classes that have the operator<< defined to work 
> with ostreams.
> 
> If you or anyone else has a portable way of doing this, please let me
> know, and I will implement it right away.
> 
> Again, sorry about causing all these problems.
> 
> Regards,
> Hans J. Johnson
> hans-johnson@uiowa.edu
> 
> 
> 
> Lorensen, William E (Research) wrote:
>  > Hans,
>  >
>  > I corrected a couple of problems with your checkins.
>  >
>  > 1) itkMetaDataObject.txx did not have #define guards 
> around the code. 
> In itk, all .txx files must be
>  > includable on their own. To enforce this, the header test 
> generator 
> will include the .txx file if one
>  > exists. I added guards.
>  >
>  > 2) I removed the specialization of the printself methods. 
> The usage 
> was not portable, but looking
>  > into at the code it l;ooks like you don't need the 
> specialization. I 
> moved the output into the
>  > class's PrintSelf. I lalso removed all the code form the 
> itkMetaDataObject.cxx file. I did not remove
>  > that file form CMakeLists.txt file because I wasn't sure 
> if you have 
> future plans for this file.
>  >
>  > I made the changes so that we can get some clean continuous builds 
> early today. I know that Bill Hoff
>  > is ready to check in his vnl changes.
>  >
>  > Bill
>  >
>  > _______________________________________________
>  > Insight-developers mailing list
>  > Insight-developers@public.kitware.com
>  > http://public.kitware.com/mailman/listinfo/insight-developers
> 
> 
> -- 
> ===================================================================
> Hans J. Johnson                              W294 GH
> hans-johnson@uiowa.edu                       Dept. of Psychiatry
> http://www.psychiatry.uiowa.edu/~hjohnson    The University of Iowa
> (319) 353-8587                               Iowa City, IA 52242
> ===================================================================
> 
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>