to 0.
* DicomEntry (thus, DictEntry) inherits from RefCounter... next stage to do,
all classes inherit from RefCounter
* Remove the VirtualDictEntry use, now useless due to the reference
counting. So, there will be no memory leaks.
-- BeNours
Program: gdcm
Module: $RCSfile: TestDataEntry.cxx,v $
Language: C++
- Date: $Date: 2005/10/20 08:58:15 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2005/10/20 15:24:05 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
gdcm::DataEntry *entry;
//------------------------------------------------------------------
- dict = new gdcm::DictEntry(0x0000,0x0000);
+ dict = gdcm::DictEntry::New(0x0000,0x0000);
entry = new gdcm::DataEntry(dict);
dict->SetVR("US");
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: 1" << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: 2" << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: 0" << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
std::cout << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
//------------------------------------------------------------------
- dict = new gdcm::DictEntry(0x0000,0x0000);
+ dict = gdcm::DictEntry::New(0x0000,0x0000);
entry = new gdcm::DataEntry(dict);
dict->SetVR("LT");
<< " Size of string is incorrect" << std::endl
<< " Found: " << entry->GetLength()
<< " - Must be: " << strlen(data) + strlen(data)%2 << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
{
std::cout << " Failed" << std::endl
<< " Content of bin area is incorrect" << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of string is incorrect" << std::endl
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of entry's values is incorrect : id " << i << std::endl
<< " Found " << entry->GetValue(i)
<< " - Must be " << svalue[i] << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
}
std::cout << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
//------------------------------------------------------------------
- dict = new gdcm::DictEntry(0x0000,0x0000);
+ dict = gdcm::DictEntry::New(0x0000,0x0000);
entry = new gdcm::DataEntry(dict);
dict->SetVR("US");
<< " BinArea length is incorrect" << std::endl
<< " Found: " << entry->GetLength()
<< " - Must be: " << nbvalue*sizeof(uint16_t) << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of string is incorrect" << std::endl
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of entry's values is incorrect : id " << i << std::endl
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << svalue[i] << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of string is incorrect" << std::endl
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of entry's values is incorrect : id " << i << std::endl
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << svalue[i] << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
}
std::cout << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
//------------------------------------------------------------------
- dict = new gdcm::DictEntry(0x0000,0x0000);
+ dict = gdcm::DictEntry::New(0x0000,0x0000);
entry = new gdcm::DataEntry(dict);
dict->SetVR("UL");
<< " BinArea length is incorrect" << std::endl
<< " Found: " << entry->GetLength()
<< " - Must be: " << nbvalue*sizeof(uint32_t) << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of string is incorrect" << std::endl
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of entry's values is incorrect : id " << i << std::endl
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << lvalue[i] << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of string is incorrect" << std::endl
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of entry's values is incorrect : id " << i << std::endl
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << lvalue[i] << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
}
std::cout << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
//------------------------------------------------------------------
- dict = new gdcm::DictEntry(0x0000,0x0000);
+ dict = gdcm::DictEntry::New(0x0000,0x0000);
entry = new gdcm::DataEntry(dict);
dict->SetVR("FL");
<< " BinArea length is incorrect" << std::endl
<< " Found: " << entry->GetLength()
<< " - Must be: " << nbvalue*sizeof(float) << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of string is incorrect" << std::endl
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << fdata << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of entry's values is incorrect : id " << i << std::endl
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << fvalue[i] << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of string is incorrect" << std::endl
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << fdata << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of entry's values is incorrect : id " << i << std::endl
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << fvalue[i] << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
}
std::cout << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
//------------------------------------------------------------------
- dict = new gdcm::DictEntry(0x0000,0x0000);
+ dict = gdcm::DictEntry::New(0x0000,0x0000);
entry = new gdcm::DataEntry(dict);
dict->SetVR("FD");
<< " BinArea length is incorrect" << std::endl
<< " Found: " << entry->GetLength()
<< " - Must be: " << nbvalue*sizeof(double) << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of string is incorrect" << std::endl
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << fdata << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of entry's values is incorrect : id " << i << std::endl
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << dvalue[i] << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of string is incorrect" << std::endl
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << fdata << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Number of content values is incorrect" << std::endl
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
<< " Content of entry's values is incorrect : id " << i << std::endl
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << dvalue[i] << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
return(1);
}
}
std::cout << std::endl;
- delete dict;
+ dict->Delete();
delete entry;
//------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: TestDict.cxx,v $
Language: C++
- Date: $Date: 2005/07/11 14:53:15 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2005/10/20 15:24:05 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
std::cout<<"DictSet content :\n";
- gdcm::Dict *d = dicts->GetFirstEntry();
+ gdcm::Dict *d = dicts->GetFirstDict();
if (!d)
{
std::cout << "Dictset is empty" << std::endl;
{
std::cout << "------------- a Dict is found : ----------" << std::endl;
d->Print();
- d = dicts->GetNextEntry();
+ d = dicts->GetNextDict();
}
// Print the Dict (public)
#include "gdcmCommon.h"
#include "gdcmBase.h"
+#include "gdcmRefCounter.h"
#include "gdcmTagKey.h"
#include "gdcmVRKey.h"
#include "gdcmDict.h"
// Warning: Order matters !
%include "gdcmCommon.h"
%include "gdcmBase.h"
+%include "gdcmRefCounter.h"
%include "gdcmTagKey.h"
%include "gdcmVRKey.h"
%include "gdcmDicomEntry.h"
gdcmOrientation.cxx
gdcmPixelReadConvert.cxx
gdcmPixelWriteConvert.cxx
+ gdcmRefCounter.cxx
gdcmRLEFrame.cxx
gdcmRLEFramesInfo.cxx
gdcmSeqEntry.cxx
Program: gdcm
Module: $RCSfile: gdcmBase.cxx,v $
Language: C++
- Date: $Date: 2005/02/01 10:29:54 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
//-------------------------------------------------------------------------
// Constructor / Destructor
-/**
- * \brief canonical constructor
- */
-Base::Base( )
-{
- PrintLevel = 0;
-}
-
-/**
- * \brief canonical destructor
- * \note If the Header was created by the File constructor,
- * it is destroyed by the File
- */
-Base::~Base()
-{
-}
//-----------------------------------------------------------------------------
// Public
//-----------------------------------------------------------------------------
// Print
-/**
- * \brief Print all the object
- * @param os The output stream to be written to.
- * @param indent Indentation string to be prepended during printing
- */
-void Base::Print(std::ostream &, std::string const & )
-{
-}
//-----------------------------------------------------------------------------
} // end namespace gdcm
Program: gdcm
Module: $RCSfile: gdcmBase.h,v $
Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.8 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
class GDCM_EXPORT Base
{
public:
- Base( );
- virtual ~Base();
+ Base( ) {PrintLevel = 0;}
+ virtual ~Base() {}
virtual void Print(std::ostream &os = std::cout,
- std::string const & indent = "" );
+ std::string const & indent = "" ) {};
/// \brief Sets the print level for the Dicom Header Elements
/// \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy Print
Program: gdcm
Module: $RCSfile: gdcmCommon.h,v $
Language: C++
- Date: $Date: 2005/10/19 13:17:04 $
- Version: $Revision: 1.99 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.100 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmConfigure.h"
#include "gdcmSystem.h"
+#include "gdcmMacro.h"
#include <string>
Program: gdcm
Module: $RCSfile: gdcmDefaultDicts.cxx.in,v $
Language: C++
- Date: $Date: 2005/10/19 12:01:50 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void FillDefaultDataDict(Dict *d)
{
+ DictEntry *e;
unsigned int i = 0;
DICT_ENTRY n = datadir[i];
while( n.name != 0 )
{
- const DictEntry e( n.group, n.element, n.vr, n.vm, n.name);
+ e = DictEntry::New( n.group, n.element, n.vr, n.vm, n.name);
d->AddEntry( e );
+ e->Delete();
n = datadir[++i];
}
}
Program: gdcm
Module: $RCSfile: gdcmDicomEntry.h,v $
Language: C++
- Date: $Date: 2005/10/19 13:17:05 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#define GDCMDICOMENTRY_H
#include "gdcmCommon.h"
-#include "gdcmBase.h"
+#include "gdcmRefCounter.h"
#include "gdcmVRKey.h"
#include "gdcmTagKey.h"
* - the VM (Value Multplicity)
* - the corresponding name in english
*/
-class GDCM_EXPORT DicomEntry : public Base
+class GDCM_EXPORT DicomEntry : public RefCounter
{
public:
- DicomEntry(const uint16_t &group,const uint16_t &elt,
- const VRKey &vr = GDCM_VRUNKNOWN);
- ~DicomEntry();
+ gdcmTypeMacro(DicomEntry);
+public:
// Print
void Print(std::ostream &os = std::cout, std::string const &indent = "");
// Key creation
static TagKey TranslateToKey(uint16_t group, uint16_t elem);
+protected:
+ DicomEntry(const uint16_t &group,const uint16_t &elt,
+ const VRKey &vr = GDCM_VRUNKNOWN);
+ ~DicomEntry();
+
private:
/// Dicom \ref TagKey. Contains DicomGroup number and DicomElement number
TagKey Tag;
Program: gdcm
Module: $RCSfile: gdcmDict.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 12:58:27 $
- Version: $Revision: 1.80 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.81 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// from >> std::ws; //remove white space
std::getline(from, name);
- RemoveEntry(DictEntry::TranslateToKey(group, elem));
+ RemoveEntry(group,elem);
}
from.close();
return true;
* @param newEntry entry to add
* @return false if Dicom Element already exists
*/
-bool Dict::AddEntry(DictEntry const &newEntry)
+bool Dict::AddEntry(DictEntry *newEntry)
{
- const TagKey &key = newEntry.GetKey();
+ const TagKey &key = newEntry->GetKey();
if ( KeyHt.count(key) == 1 )
{
}
else
{
- KeyHt.insert( TagKeyHT::value_type(newEntry.GetKey(), newEntry));
+ newEntry->Register();
+ KeyHt.insert( TagKeyHT::value_type(key, newEntry));
return true;
}
}
* @param newEntry new entry (overwrites any previous one with same tag)
* @return false if Dicom Element doesn't exist
*/
-bool Dict::ReplaceEntry(DictEntry const &newEntry)
+bool Dict::ReplaceEntry(DictEntry *newEntry)
{
- if ( RemoveEntry(newEntry.GetKey()) )
+ const TagKey &key = newEntry->GetKey();
+ if ( RemoveEntry(key) )
{
- KeyHt.insert( TagKeyHT::value_type(newEntry.GetKey(), newEntry));
- return true;
+ newEntry->Register();
+ KeyHt.insert( TagKeyHT::value_type(key, newEntry));
+ return true;
}
return false;
}
TagKeyHT::const_iterator it = KeyHt.find(key);
if ( it != KeyHt.end() )
{
+ it->second->Unregister();
KeyHt.erase(key);
return true;
{
// we assume all the pointed DictEntries are already cleaned-up
// when we clean KeyHt.
+ TagKeyHT::const_iterator it;
+ for(it = KeyHt.begin();it!=KeyHt.end();++it)
+ it->second->Unregister();
KeyHt.clear();
}
{
return 0;
}
- return &(it->second);
+ return it->second;
}
DictEntry *Dict::GetEntry(uint16_t group, uint16_t elem)
{
return 0;
}
- return &(it->second);
+ return it->second;
}
/**
{
ItKeyHt = KeyHt.begin();
if ( ItKeyHt != KeyHt.end() )
- return &(ItKeyHt->second);
+ return ItKeyHt->second;
return NULL;
}
++ItKeyHt;
if (ItKeyHt != KeyHt.end())
- return &(ItKeyHt->second);
+ return ItKeyHt->second;
return NULL;
}
TagName vm;
TagName name;
+ DictEntry *newEntry;
while (!from.eof() && from)
{
from >> std::hex;
from >> std::ws; //remove white space
std::getline(from, name);
- DictEntry newEntry(group, elem, vr, vm, name);
+ newEntry = DictEntry::New(group, elem, vr, vm, name);
AddEntry(newEntry);
+ newEntry->Delete();
}
from.close();
}
for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag)
{
s << "Entry : ";
- s << "(" << std::hex << std::setw(4) << tag->second.GetGroup() << ',';
- s << std::hex << std::setw(4) << tag->second.GetElement() << ") = "
+ s << "(" << tag->second->GetKey() << ") = "
<< std::dec;
- s << tag->second.GetVR() << ", ";
- s << tag->second.GetVM() << ", ";
- s << tag->second.GetName() << "." << std::endl;
+ s << tag->second->GetVR() << ", ";
+ s << tag->second->GetVM() << ", ";
+ s << tag->second->GetName() << "." << std::endl;
}
os << s.str();
}
Program: gdcm
Module: $RCSfile: gdcmDict.h,v $
Language: C++
- Date: $Date: 2005/10/20 08:58:18 $
- Version: $Revision: 1.42 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.43 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
typedef std::string DictKey;
-typedef std::map<TagKey, DictEntry> TagKeyHT;
+typedef std::map<TagKey, DictEntry *> TagKeyHT;
//-----------------------------------------------------------------------------
/**
void Print(std::ostream &os = std::cout, std::string const &indent = "");
// Entries
- bool AddEntry(DictEntry const &newEntry);
- bool ReplaceEntry(DictEntry const &newEntry);
+ bool AddEntry(DictEntry *newEntry);
+ bool ReplaceEntry(DictEntry *newEntry);
bool RemoveEntry (TagKey const &key);
bool RemoveEntry (uint16_t group, uint16_t elem);
void ClearEntry();
Program: gdcm
Module: $RCSfile: gdcmDictEntry.cxx,v $
Language: C++
- Date: $Date: 2005/10/19 13:17:04 $
- Version: $Revision: 1.53 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.54 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param vm Value Multiplicity
* @param name description of the element
*/
-
DictEntry::DictEntry(uint16_t group, uint16_t elem,
VRKey const &vr,
TagName const &vm,
//-----------------------------------------------------------------------------
// Public
+/**
+ * \brief Class allocator
+ * @param group DICOM-Group Number
+ * @param elem DICOM-Element Number
+ * @param vr Value Representation
+ * @param vm Value Multiplicity
+ * @param name description of the element
+*/
+DictEntry *DictEntry::New(uint16_t group, uint16_t elem,
+ VRKey const &vr,
+ TagName const &vm,
+ TagName const &name)
+{
+ return new DictEntry(group,elem,vr,vm,name);
+}
+
/**
* \brief If-and only if-the V(alue) R(epresentation)
* \ is unset then overwrite it.
Program: gdcm
Module: $RCSfile: gdcmDictEntry.h,v $
Language: C++
- Date: $Date: 2005/10/19 13:17:04 $
- Version: $Revision: 1.38 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.39 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
class GDCM_EXPORT DictEntry : public DicomEntry
{
public:
- DictEntry(uint16_t group,
- uint16_t elem,
+ gdcmTypeMacro(DictEntry);
+
+public:
+ static DictEntry *New(uint16_t group, uint16_t elem,
VRKey const &vr = GDCM_VRUNKNOWN,
TagName const &vm = GDCM_UNKNOWN,
TagName const &name = GDCM_UNKNOWN);
/// e.g. "Patient Name" for Dicom Tag (0x0010, 0x0010)
/// @return the Dicom Name
const TagName &GetName() const { return Name; }
-
+
+protected:
+ DictEntry(uint16_t group, uint16_t elem,
+ VRKey const &vr = GDCM_VRUNKNOWN,
+ TagName const &vm = GDCM_UNKNOWN,
+ TagName const &name = GDCM_UNKNOWN);
+
private:
/// \brief Value Multiplicity (e.g. "1", "1-n", "6")
TagName VM;
Program: gdcm
Module: $RCSfile: gdcmDictSet.cxx,v $
Language: C++
- Date: $Date: 2005/10/20 09:23:24 $
- Version: $Revision: 1.70 $
+ Date: $Date: 2005/10/20 15:24:08 $
+ Version: $Revision: 1.71 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
tag->second = NULL;
}
Dicts.clear();
-
- // Remove virtual dictionary entries
- VirtualEntries.clear();
}
//-----------------------------------------------------------------------------
}
/**
- * \brief Create a DictEntry which will be referenced in no dictionary
- * @param group Group number of the Entry
- * @param elem Element number of the Entry
- * @param vr Value Representation of the Entry
- * @param vm Value Multiplicity of the Entry
- * @param name English name of the Entry
- * @return virtual entry
- */
-DictEntry *DictSet::NewVirtualDictEntry( uint16_t group,
- uint16_t elem,
- const VRKey &vr,
- const TagName &vm,
- const TagName &name)
-{
- DictEntry *entry;
-
- // Let's follow 'Purify' advice
- // const std::string tag = DictEntry::TranslateToKey(group,elem)
- // + "#" + vr + "#" + vm + "#" + name;
- ExtendedTagKey tag = DictEntry::TranslateToKey(group,elem).str();
- tag += "#" + vr.str() + "#" + vm + "#" + name;
-
- ExtendedTagKeyHT::iterator it;
-
- it = VirtualEntries.find(tag);
- if ( it != VirtualEntries.end() )
- {
- entry = &(it->second);
- }
- else
- {
- DictEntry ent(group, elem, vr, vm, name);
- VirtualEntries.insert(
- ExtendedTagKeyHT::value_type(tag, ent) );
- entry = &(VirtualEntries.find(tag)->second);
- }
-
- return entry;
-}
-
-/**
- * \brief Get the first entry while visiting the DictSet
+ * \brief Get the first dictionary while visiting the DictSet
* \return The first Dict if found, otherwhise NULL
*/
-Dict *DictSet::GetFirstEntry()
+Dict *DictSet::GetFirstDict()
{
ItDictHt = Dicts.begin();
if ( ItDictHt != Dicts.end() )
}
/**
- * \brief Get the next entry while visiting the Hash table (DictSetHT)
+ * \brief Get the next dictionary while visiting the Hash table (DictSetHT)
* \note : meaningfull only if GetFirstEntry already called
* \return The next Dict if found, otherwhise NULL
*/
-Dict *DictSet::GetNextEntry()
+Dict *DictSet::GetNextDict()
{
gdcmAssertMacro (ItDictHt != Dicts.end());
Program: gdcm
Module: $RCSfile: gdcmDictSet.h,v $
Language: C++
- Date: $Date: 2005/10/18 12:58:28 $
- Version: $Revision: 1.46 $
+ Date: $Date: 2005/10/20 15:24:09 $
+ Version: $Revision: 1.47 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
+//-----------------------------------------------------------------------------
typedef std::map<DictKey, Dict*> DictSetHT;
-typedef std::string ExtendedTagKey;
-typedef std::map<ExtendedTagKey, DictEntry> ExtendedTagKeyHT;
//-----------------------------------------------------------------------------
/**
// \ warning : not end user intended
// Dict *GetVirtualDict() { return &VirtualEntries; }
- DictEntry *NewVirtualDictEntry(uint16_t group, uint16_t elem,
- const VRKey &vr = GDCM_VRUNKNOWN,
- const TagName &vm = GDCM_UNKNOWN,
- const TagName &name = GDCM_UNKNOWN);
-
- Dict *GetFirstEntry();
- Dict *GetNextEntry();
+ Dict *GetFirstDict();
+ Dict *GetNextDict();
static std::string BuildDictPath();
/// Directory path to dictionaries
std::string DictPath;
-
- /// H table for the on the fly created DictEntries
- ExtendedTagKeyHT VirtualEntries;
};
} // end namespace gdcm
Program: gdcm
Module: $RCSfile: gdcmDocEntry.cxx,v $
Language: C++
- Date: $Date: 2005/10/20 07:29:43 $
- Version: $Revision: 1.74 $
+ Date: $Date: 2005/10/20 15:24:09 $
+ Version: $Revision: 1.75 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// init some variables
ReadLength = 0;
Length = 0;
+
+ gdcmAssertMacro(DicomDict);
+ DicomDict->Register();
+}
+
+/**
+ * \brief Destructor from a given DictEntry
+ */
+DocEntry::~DocEntry()
+{
+ gdcmAssertMacro(DicomDict);
+
+ DicomDict->Unregister();
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmDocEntry.h,v $
Language: C++
- Date: $Date: 2005/10/19 13:17:04 $
- Version: $Revision: 1.52 $
+ Date: $Date: 2005/10/20 15:24:09 $
+ Version: $Revision: 1.53 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
public:
DocEntry(DictEntry*);
- /// \brief Canonical Destructor
- virtual ~DocEntry() {}
+ virtual ~DocEntry();
virtual void Print (std::ostream &os = std::cout, std::string const &indent = "");
virtual void WriteContent(std::ofstream *fp, FileType filetype);
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 12:58:28 $
- Version: $Revision: 1.61 $
+ Date: $Date: 2005/10/20 15:24:09 $
+ Version: $Revision: 1.62 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
VRKey const &vr)
{
DictEntry *dictEntry = GetDictEntry(group, elem, vr);
- gdcmAssertMacro(dictEntry);
DataEntry *newEntry = new DataEntry(dictEntry);
+ dictEntry->Unregister(); // GetDictEntry register it
if (!newEntry)
{
gdcmWarningMacro( "Failed to allocate DataEntry");
SeqEntry* DocEntrySet::NewSeqEntry(uint16_t group, uint16_t elem)
{
DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
- gdcmAssertMacro(dictEntry);
SeqEntry *newEntry = new SeqEntry( dictEntry );
+ dictEntry->Unregister(); // GetDictEntry register it
if (!newEntry)
{
gdcmWarningMacro( "Failed to allocate SeqEntry");
return newEntry;
}
-/**
- * \brief Request a new virtual dict entry to the dict set
- * @param group Group number of the underlying DictEntry
- * @param elem Element number of the underlying DictEntry
- * @param vr V(alue) R(epresentation) of the underlying DictEntry
- * @param vm V(alue) M(ultiplicity) of the underlying DictEntry
- * @param name english name
- */
-DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group, uint16_t elem,
- VRKey const &vr,
- TagName const &vm,
- TagName const &name )
-{
- return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,vm,name);
-}
-
//-----------------------------------------------------------------------------
// Protected
/**
* @param group Group number of the searched DictEntry
* @param elem Element number of the searched DictEntry
* @return Corresponding DictEntry when it exists, NULL otherwise.
+ * \remarks The returned DictEntry is registered when existing
*/
DictEntry *DocEntrySet::GetDictEntry(uint16_t group,uint16_t elem)
{
}
else
{
- found = pubDict->GetEntry(group, elem);
+ found = pubDict->GetEntry(group, elem);
+ if( found )
+ found->Register();
}
return found;
}
* @param elem element number of the searched DictEntry
* @param vr V(alue) R(epresentation) to use, if necessary
* @return Corresponding DictEntry when it exists, NULL otherwise.
+ * \remarks The returned DictEntry is registered
*/
DictEntry *DocEntrySet::GetDictEntry(uint16_t group, uint16_t elem,
VRKey const &vr)
DictEntry *goodEntry = dictEntry;
VRKey goodVR = vr;
- if (elem == 0x0000) goodVR="UL";
+ if (elem == 0x0000)
+ goodVR="UL";
if ( goodEntry )
{
{
if (dictEntry)
{
- goodEntry = NewVirtualDictEntry(group, elem, goodVR, "FIXME",
- dictEntry->GetName() );
+ goodEntry = DictEntry::New(group, elem, goodVR, "FIXME",
+ dictEntry->GetName() );
}
else
{
- goodEntry = NewVirtualDictEntry(group, elem, goodVR);
+ goodEntry = DictEntry::New(group, elem, goodVR);
}
}
+ else
+ {
+ goodEntry->Register();
+ }
return goodEntry;
}
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.h,v $
Language: C++
- Date: $Date: 2005/10/19 13:17:05 $
- Version: $Revision: 1.59 $
+ Date: $Date: 2005/10/20 15:24:09 $
+ Version: $Revision: 1.60 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
VRKey const &vr = GDCM_VRUNKNOWN);
SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem);
-// DictEntry related utilities
- DictEntry *NewVirtualDictEntry(uint16_t group,uint16_t elem,
- VRKey const &vr = GDCM_VRUNKNOWN,
- TagName const &vm = GDCM_UNKNOWN,
- TagName const &name = GDCM_UNKNOWN );
-
protected:
// DictEntry related utilities
DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/10/20 13:55:05 $
- Version: $Revision: 1.300 $
+ Date: $Date: 2005/10/20 15:24:09 $
+ Version: $Revision: 1.301 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
if ( dictEntry )
{
realVR = dictEntry->GetVR();
+ dictEntry->Unregister();
}
}
}
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2005/10/19 19:36:54 $
- Version: $Revision: 1.283 $
+ Date: $Date: 2005/10/20 15:24:09 $
+ Version: $Revision: 1.284 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Change only made if usefull
if ( PixelVR != oldEntry->GetVR() )
{
- DictEntry* newDict = NewVirtualDictEntry(GrPixel,NumPixel,
- PixelVR,"1","Pixel Data");
+ DictEntry* newDict = DictEntry::New(GrPixel,NumPixel,
+ PixelVR,"1","Pixel Data");
DataEntry *newEntry = new DataEntry(newDict);
+ newDict->Delete();
newEntry->Copy(entry);
newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea());
oldEntry->SetSelfArea(false);
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmMacro.h,v $
+ Language: C++
+ Date: $Date: 2005/10/20 15:24:09 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef GDCMMACRO_H
+#define GDCMMACRO_H
+
+//-----------------------------------------------------------------------------
+#define gdcmTypeMacro(type) \
+ private : \
+ type(type &); /* Not implemented */ \
+ type &operator=(type &); /* Not implemented */
+
+//-----------------------------------------------------------------------------
+#endif
--- /dev/null
+ /*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmRefCounter.cxx,v $
+ Language: C++
+ Date: $Date: 2005/10/20 15:24:10 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#include "gdcmRefCounter.h"
+
+namespace gdcm
+{
+//-------------------------------------------------------------------------
+// Constructor / Destructor
+
+//-----------------------------------------------------------------------------
+// Public
+
+//-----------------------------------------------------------------------------
+// Protected
+
+//-----------------------------------------------------------------------------
+// Private
+
+//-----------------------------------------------------------------------------
+// Print
+
+//-----------------------------------------------------------------------------
+} // end namespace gdcm
+
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmRefCounter.h,v $
+ Language: C++
+ Date: $Date: 2005/10/20 15:24:10 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef GDCMREFCOUNTER_H
+#define GDCMREFCOUNTER_H
+
+#include "gdcmBase.h"
+#include "gdcmDebug.h"
+
+namespace gdcm
+{
+//-----------------------------------------------------------------------------
+/**
+ * \brief Integration of reference counting with a destruction of the
+ * object only when the reference is to zero
+ */
+class GDCM_EXPORT RefCounter : public Base
+{
+public:
+ gdcmTypeMacro(RefCounter);
+
+public:
+// Allocator / Unallocator
+ /// Delete the object
+ /// \remarks The object is deleted only if its reference counting is to zero
+ inline virtual void Delete(void)
+ {
+ Unregister();
+ }
+
+// Reference count
+ /// Register the object
+ /// \remarks It increments the reference counting
+ inline void Register(void)
+ {
+ RefCount++;
+ }
+ /// Unregister the object
+ /// \remarks It decrements the reference counting
+ inline void Unregister(void)
+ {
+ RefCount--;
+ if(RefCount==0)
+ {
+ delete this;
+ }
+ }
+ /// Get the reference counting
+ /// \return Reference count
+ inline const unsigned long &GetRefCount(void) const
+ {
+ return(RefCount);
+ }
+
+protected:
+ /// Constructor
+ RefCounter() { RefCount = 1; }
+ /// Destructor
+ virtual ~RefCounter() {}
+
+private:
+ /// \brief Reference count
+ unsigned long RefCount;
+};
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+#endif