+ progressMethod = method;
+ progressArg = arg;
+ progressMethodArgDelete = argDelete;
+}
+
+/**
+ * \ingroup gdcmDicomDir
+ * \brief Set the method to delete the argument
+ * The argument is destroyed when the method is changed or when the
+ * class is destroyed
+ * @param method Method to call to delete the argument
+ */
+void gdcmDicomDir::SetProgressMethodArgDelete(gdcmMethod *method)
+{
+ progressMethodArgDelete = method;
+}
+
+/**
+ * \ingroup gdcmDicomDir
+ * \brief Set the end method to call when the parsing of the directory ends
+ * @param method Method to call
+ * @param arg Argument to pass to the method
+ * @param argDelete Argument
+ * \warning In python : the arg parameter isn't considered
+ */
+void gdcmDicomDir::SetEndMethod(gdcmMethod *method, void *arg,
+ gdcmMethod *argDelete )
+{
+ if( endArg && endMethodArgDelete )
+ {
+ endMethodArgDelete( endArg );
+ }
+
+ endMethod = method;
+ endArg = arg;
+ endMethodArgDelete = argDelete;
+}
+
+/**
+ * \ingroup gdcmDicomDir
+ * \brief Set the method to delete the argument
+ * The argument is destroyed when the method is changed or when the class
+ * is destroyed
+ * @param method Method to call to delete the argument
+ */
+void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod *method)
+{
+ endMethodArgDelete = method;
+}
+
+/**
+ * \ingroup gdcmDicomDir
+ * \brief writes on disc a DICOMDIR
+ * \ warning does NOT add the missing elements in the header :
+ * it's up to the user doing it !
+ * \todo : to be re-written using the DICOMDIR tree-like structure
+ * *not* the chained list
+ * (does NOT exist if the DICOMDIR is user-forged !)
+ * @param fileName file to be written to
+ * @return false only when fail to open
+ */
+
+bool gdcmDicomDir::Write(std::string const & fileName)
+{
+ FILE * fp1;
+
+ fp1 = fopen(fileName.c_str(), "wb");
+ if( !fp1 )
+ {
+ printf("Failed to open(write) File [%s] \n", fileName.c_str());
+ return false;
+ }
+
+ char * filePreamble = new char[128];
+ fwrite(filePreamble,128,1,fp1);
+ fwrite("DICM",4,1,fp1);
+ delete[] filePreamble;
+ UpdateDirectoryRecordSequenceLength();
+ WriteEntries(fp1);
+
+ fclose( fp1 );
+ return true;
+}
+
+/**
+ * \brief Writes in a file using the tree-like structure.
+ * @param _fp already open file pointer
+ */
+
+void gdcmDicomDir::WriteEntries(FILE *) //_fp
+{
+ /// \todo (?) tester les echecs en ecriture
+ /// (apres chaque fwrite, dans le WriteEntry)
+
+
+/* TODO : to go on compiling
+
+ gdcmDicomDirMeta *ptrMeta;
+ ListDicomDirPatient::iterator itPatient;
+ ListDicomDirStudy::iterator itStudy;
+ ListDicomDirSerie::iterator itSerie;
+ ListDicomDirImage::iterator itImage;
+ ListTag::iterator i;
+
+ ptrMeta= GetDicomDirMeta();
+ for(i=ptrMeta->debut();i!=ptrMeta->fin();++i) {
+ WriteEntry(*i,_fp, gdcmExplicitVR);
+ }
+
+ itPatient = GetDicomDirPatients().begin();
+ while ( itPatient != GetDicomDirPatients().end() ) {
+ for(i=(*itPatient)->debut();i!=(*itPatient)->fin();++i) {
+ WriteEntry(*i,_fp, gdcmExplicitVR);
+ }
+ itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
+ while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
+ for(i=(*itStudy)->debut();i!=(*itStudy)->fin();++i) {
+ WriteEntry(*i,_fp, gdcmExplicitVR);
+ }
+ itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
+ while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) {
+ for(i=(*itSerie)->debut();i!=(*itSerie)->fin();++i) {
+ WriteEntry(*i,_fp, gdcmExplicitVR);
+ }
+ itImage = ((*itSerie)->GetDicomDirImages()).begin();
+ while (itImage != (*itSerie)->GetDicomDirImages().end() ) {
+ for(i=(*itImage)->debut();i!=(*itImage)->fin();++i) {
+ WriteEntry(*i,_fp, gdcmExplicitVR);
+ }
+ ++itImage;
+ }
+ ++itSerie;
+ }
+ ++itStudy;
+ }
+ ++itPatient;
+ }
+ */
+}
+