[Dcmlib] Loading twice the same File

Jean-Pierre Roux jpr at creatis.insa-lyon.fr
Thu Jul 7 16:05:27 CEST 2005


Mathieu Malaterre wrote:

> JP,
>
>     Excellent analysis !
>     Now maybe you don't remember but you ask me -long time ago- why we 
> need to define accessor to set member variables of a class. Here are 
> some more examples, the goal is to know when the file is supposed to 
> be read (which line du the actual reading):
>
> #1
> gdcm::File file("bla");
> file.SetLoadMode(NO_SEQ);
>
> #2
> gdcm::File file();
> file.Load("bla");
> file.SetLoadMode(NO_SEQ);
>
> #3
> gdcm::File file();
> file.SetLoadMode(NO_SEQ);
> file.Load("bla");
> file.Load("bla2");
> file.Load("bla23");
> file.Load("bla2");
> file.Load("bla");
>
> #1 and #2 are pretty straigforward to understand, the load mode is 
> never taken into account.
> #3 Is a completely degenerate case where the user don't know exactly 
> what he is doing. But anyway gdcm will read 5 files... and at the end 
> we would only need to read one. So far it is ok since the reading a 
> file is fast enough not to be troublesome.

I do agree with you.
I'm gonna add the gdcm::File::SetFileName() method.
and a 'bool Modified' private member.
JP

>
> But a good (far better) design is to decouple operations: Load is 
> doing both setting of the filename AND doing the reading of the file. 
> Now consider #3 rewriten this way:
>
> gdcm::File file();
> file.SetLoadMode(NO_SEQ);
> file.SetFileName("bla");
> file.SetFileName("bla2");
> file.SetFileName("bla23");
> file.SetFileName("bla2");
> file.SetFileName("bla");
> file.Load();
> -> how many time do we read a file now...
>
> Ok you get the picture. But my point was that gdcm is really confusing 
> because it is written -mostly- like a C interface with function 
> approach instead of object with state.

> So to answer your question, SetLoadMode, SetFileName, anythings that 
> changes the state is doing two things:
> #1 if the arg is equal to the previous one -> do nothing
> #2 if the arg is different from the previous one -> mark the object as 
> 'modified'. So that later 'Load' will realize the state has change and 
> should reread the file.
>
> 2 cents,
> Mathieu
>
>
> Jean-Pierre Roux wrote:
>
>> Hi, gdcm users.
>>
>> According to Mathieu's requirement, I make a modif, yesternight, but 
>> I'm not sure it was such a rich idea :
>> If someone loads twice the same File
>> f1->Load("myFileName.dcm");
>> ...
>> f1->Load("myFileName.dcm");
>> the second Load is effectless.
>> (File already loaded, do nothing)
>>
>> Well ...
>> If the user made a programing mistake, this new solution is OK.
>>
>> If, for some reason of its own, he removed, say the Sequences (or 
>> anything else), and wants load them again, I guess he'll feel 
>> desapointed by the result.
>> (The previous solution was to clear all the 'Entries' from the H 
>> Table, and Load again).
>>
>> Any opinion ?
>> Thx
>> JP
>
>



More information about the Dcmlib mailing list