if(!_name_service->Change_Directory("/Study")) MESSAGE( "Unable to access the study directory" )
else _name_service->Register(Study, CORBA::string_dup(aStudyImpl->Name().c_str()));
- SALOMEDS::SComponent_ptr aNotebookComponent = Study->FindComponent( "NOTEBOOK" );
- SALOMEDS::StudyBuilder_var aBuilder = Study->NewBuilder();
- aBuilder->LoadWith( aNotebookComponent, SALOME_NotebookDriver::getInstance() );
+ // Notebook creation
+ SALOME::Notebook_var aNotebookVar = Study->GetNotebook();
+ SALOME_Notebook* aNotebook = dynamic_cast<SALOME_Notebook*>(_poa->reference_to_servant( aNotebookVar._retn() ) );
+
+ // Parsing of old style notebook data
+ list<int> keys;
+ std::map<int, std::list<std::string> > vars = _impl->GetOldStyleNotebookData();
+ std::map<int, std::list<std::string> >::const_iterator it = vars.begin(), last = vars.end();
+ for( ; it!=last; it++ )
+ keys.push_back( it->first );
+ keys.sort();
+
+ list<int>::const_iterator kit = keys.begin(), klast = keys.end();
+ for( ; kit!=klast; kit++ )
+ {
+ std::list<std::string>::const_iterator lit = vars[*kit].begin();
+ std::string aName = *lit; lit++;
+ std::string aType = *lit; lit++;
+ std::string aVal = *lit;
+
+ aNotebook->ParseOldStyleParam( aName, aType, aVal );
+ }
+
+ //Old style object parsing: creation of dependencies in the notebook
+ SALOMEDS::SComponentIterator_var aCompIt = Study->NewComponentIterator();
+ for( ; aCompIt->More(); aCompIt->Next() )
+ {
+ SALOMEDS::SComponent_var aComp = aCompIt->Value();
+ CORBA::String_var aCompDataType = aComp->ComponentDataType();
+ std::string aCompName = aCompDataType.in();
+
+ SALOMEDS::ChildIterator_var anObjIt = Study->NewChildIterator( aComp._retn() );
+ for( ; anObjIt->More(); anObjIt->Next() )
+ {
+ SALOMEDS::SObject_var anObj = anObjIt->Value();
+ std::string anEntry = anObj->GetID();
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ if( anObj->FindAttribute( anAttr, "AttributeString" ) )
+ {
+ SALOMEDS::AttributeString_var aStrAttr = SALOMEDS::AttributeString::_narrow( anAttr );
+ std::string aData = aStrAttr->Value();
+ aNotebook->ParseOldStyleObject( aCompName, anEntry, aData );
+ }
+ }
+ }
return Study._retn();
}
#include "SALOMEDSImpl_Tool.hxx"
#include "SALOMEDSImpl_SComponent.hxx"
#include "SALOMEDSImpl_GenericAttribute.hxx"
-#include <map>
#include "HDFOI.hxx"
#include <iostream>
static void BuildTree (SALOMEDSImpl_Study*, HDFgroup*);
static void Translate_IOR_to_persistentID (const SALOMEDSImpl_SObject&,
SALOMEDSImpl_Driver*, bool isMultiFile, bool isASCII);
+static void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup, std::map<int, std::list<std::string> >& theVarsMap );
//============================================================================
/*! Function : SALOMEDSImpl_StudyManager
// open the HDFFile
HDFfile *hdf_file =0;
HDFgroup *hdf_group_study_structure =0;
+ HDFgroup *hdf_notebook_vars = 0;
char* aC_HDFUrl;
string aHDFUrl;
return NULL;
}
+ //Read and create notebook variables
+ if( hdf_file->ExistInternalObject( "NOTEBOOK_VARIABLES" ) )
+ {
+ hdf_notebook_vars = new HDFgroup( "NOTEBOOK_VARIABLES", hdf_file );
+ ReadNoteBookVariables( Study, hdf_notebook_vars, myVariables );
+ hdf_notebook_vars = 0; //will be deleted by hdf_sco_group destructor
+ }
+
hdf_file->CloseOnDisk();
hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file);
hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor
}
- /*ASL
- //-----------------------------------------------------------------------
- //5 - Write the NoteBook Variables
- //-----------------------------------------------------------------------
-
- //5.1 Create group to store all note book variables
- hdf_notebook_vars = new HDFgroup("NOTEBOOK_VARIABLES",hdf_file);
- hdf_notebook_vars->CreateOnDisk();
-
- string varValue;
- string varType;
- string varIndex;
-
- for(int i=0 ;i < aStudy->myNoteBookVars.size(); i++ ){
- // For each variable create HDF group
- hdf_notebook_var = new HDFgroup((char*)aStudy->myNoteBookVars[i]->Name().c_str(),hdf_notebook_vars);
- hdf_notebook_var->CreateOnDisk();
-
- // Save Variable type
- varType = aStudy->myNoteBookVars[i]->SaveType();
- name_len = (hdf_int32) varType.length();
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("VARIABLE_TYPE",hdf_notebook_var,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((char*)varType.c_str());
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
-
- char buffer[256];
- sprintf(buffer,"%d",i);
- varIndex= string(buffer);
- name_len = (hdf_int32) varIndex.length();
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("VARIABLE_INDEX",hdf_notebook_var,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((char*)varIndex.c_str());
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
-
-
- // Save Variable value
- varValue = aStudy->myNoteBookVars[i]->Save();
- name_len = (hdf_int32) varValue.length();
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("VARIABLE_VALUE",hdf_notebook_var,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((char*)varValue.c_str());
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- hdf_notebook_var->CloseOnDisk();
- hdf_notebook_var = 0; //will be deleted by hdf_sco_group destructor
- }
- hdf_notebook_vars->CloseOnDisk();
- hdf_notebook_vars = 0; //will be deleted by hdf_sco_group destructor
-
- if (aLocked) aStudy->GetProperties()->SetLocked(true);
- */
-
//-----------------------------------------------------------------------
//6 - Write the Study Properties
//-----------------------------------------------------------------------
return SALOMEDSImpl_Study::SObject(aStartLabel);
}
+//============================================================================
+/*! Function : GetOldStyleNotebookData
+ * Purpose :
+ */
+//============================================================================
+std::map<int, std::list<std::string> > SALOMEDSImpl_StudyManager::GetOldStyleNotebookData() const
+{
+ return myVariables;
+}
+
//#######################################################################################################
//# STATIC PRIVATE FUNCTIONS
//#######################################################################################################
Translate_IOR_to_persistentID (current, engine, isMultiFile, isASCII);
}
}
+
+void ReadNoteBookVariables( SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup, std::map<int, std::list<std::string> >& theVarsMap )
+{
+ theVarsMap.clear();
+ if(!theGroup)
+ return;
+
+ HDFgroup* new_group =0;
+ HDFdataset* new_dataset =0;
+
+ char aVarName[HDF_NAME_MAX_LEN+1];
+ char *currentVarType = 0;
+ char *currentVarValue = 0;
+ char *currentVarIndex = 0;
+ int order = 0;
+ //Open HDF group with notebook variables
+ theGroup->OpenOnDisk();
+
+ //Get Nb of variables
+ int aNbVars = theGroup->nInternalObjects();
+
+ for( int iVar = 0; iVar < aNbVars; iVar++ )
+ {
+ theGroup->InternalObjectIndentify(iVar, aVarName);
+ hdf_object_type type = theGroup->InternalObjectType(aVarName);
+ if(type == HDF_GROUP) {
+
+ //Read Variable
+ new_group = new HDFgroup(aVarName,theGroup);
+ new_group->OpenOnDisk();
+
+ //Read Type
+ new_dataset = new HDFdataset("VARIABLE_TYPE",new_group);
+ new_dataset->OpenOnDisk();
+ currentVarType = new char[new_dataset->GetSize()+1];
+ new_dataset->ReadFromDisk(currentVarType);
+ new_dataset->CloseOnDisk();
+ new_dataset = 0; //will be deleted by hdf_sco_group destructor
+
+ //Read Order
+ if(new_group->ExistInternalObject("VARIABLE_INDEX")) {
+ new_dataset = new HDFdataset("VARIABLE_INDEX",new_group);
+ new_dataset->OpenOnDisk();
+ currentVarIndex = new char[new_dataset->GetSize()+1];
+ new_dataset->ReadFromDisk(currentVarIndex);
+ new_dataset->CloseOnDisk();
+ new_dataset = 0; //will be deleted by hdf_sco_group destructor
+ order = atoi(currentVarIndex);
+ delete [] currentVarIndex;
+ }
+ else
+ order = iVar;
+
+ //Read Value
+ new_dataset = new HDFdataset("VARIABLE_VALUE",new_group);
+ new_dataset->OpenOnDisk();
+ currentVarValue = new char[new_dataset->GetSize()+1];
+ new_dataset->ReadFromDisk(currentVarValue);
+ new_dataset->CloseOnDisk();
+ new_dataset = 0; //will be deleted by hdf_sco_group destructor
+
+ new_group->CloseOnDisk();
+ new_group = 0; //will be deleted by hdf_sco_group destructor
+
+ std::list<std::string> var_data;
+ var_data.push_back( aVarName );
+ var_data.push_back( currentVarType );
+ var_data.push_back( currentVarValue );
+ theVarsMap[order] = var_data;
+ }
+ }
+
+ theGroup->CloseOnDisk();
+}
+