[Dcmlib] static ::New() / Factory

Benoit Regrain benoit.regrain at creatis.insa-lyon.fr
Mon Nov 14 10:19:38 CET 2005


Hi,

I have introduced this static method for the same reasons that
it exits in VTK or ITK : the REFERENCE COUNTING !!!

The New static method isn't alone. It has some friends :
 - the Delete method to destroy the object (but only if the object
   is not used by other objects)
 - the Register/Unregister methods to inform the object that it is
   used by an other method, and must exist while it is used !

Now, there is 
 - no virtual DictEntry created in a part and never destroyed
   (other than at the end of the application)
 - no risk to destroy an object used by an other (like it was the
   case for DocEntry at the beginning of gdcm when we use
   it in 2 object
 - there is no more methods call DeleteNoDestroy to avoid a
   bad intern code.

And it will introduce my futures changes that will more break the
interface of gdcm :
 - have Converter objects to convert a read document to a 
   DicomDir, Image or other Dicom structure
 - have Decorator object to interpret the content of a DataObject,
   like an ImageInformation decorator that will search and take us
   the size and other information from an Image or a DicomDirImage
   This will be used to get the image pixel datas from the Image
   and with a special decorator, we will get only a part of the image,
   and not all.
- have Reader and Writer separated from the DataObject that is 
   actually the Document.

Mathieu, like Luis has said us, the API can't be always kept. 
At few time, we must break the interface to integrate some
usefull changes. It's in the laws of the life... see the Darwin 
explains on the evolution of the life ;-)
I would that gdcm goes up and integrates the changes that we 
have speaken 6 month ago.

Benoit


----- Original Message ----- 
From: "Mathieu Malaterre" <mathieu.malaterre at kitware.com>
To: "Mailing list gdcm" <dcmlib at creatis.insa-lyon.fr>
Sent: Wednesday, November 09, 2005 2:49 PM
Subject: [Dcmlib] static ::New() / Factory


> Benoit,
> 
> So what is the deal with New ? What purpose does it do (except Yet 
> Another API change) ? I have to explain why `we' needed that to the ITK 
> group ?
> 
> Also one thing that I hate is the complete inconsistency:
> 
> new gdcm::SerieHelper()
> new gdcm::ArgMgr(argc, argv)
> new gdcm::Validator();
> 
> but
> 
> gdcm::FileHelper::New(e1);
> gdcm::File::New( );
> 
> 
> Also most of the internals of gdcm still use `new'. So why did you 
> introduce the ugly New static function ?
> 
> Thanks for comments,
> Mathieu
> _______________________________________________
> Dcmlib mailing list
> Dcmlib at creatis.insa-lyon.fr
> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib



More information about the Dcmlib mailing list