- ObjectID = atoi( ObjectIdString.c_str() ) ;
- // is this object already has been streamed in, return it here
- if ( genCode )
- {
- if ( Data->ObjectNames.find( ObjectID ) != Data->ObjectNames.end() )
- return ObjectID ;
- }
- else
- {
- if ( Data->Objects.find( ObjectID ) != Data->Objects.end() )
- return ObjectID ;
- }
-
- // new object, start with allocation
- Callbacks->AllocateObject(ObjectID, ClassInfo);
-
- //
- // stream back the Create parameters first
- CreateParams = new wxxVariant[ ClassInfo->GetCreateParamCount() ] ;
-
- typedef map<string, wxXmlNode *> PropertyNodes ;
- typedef vector<string> PropertyNames ;
-
- PropertyNodes propertyNodes ;
- PropertyNames propertyNames ;
-
- while( Children )
- {
- propertyNames.push_back( Children->GetName().c_str() ) ;
- propertyNodes[Children->GetName().c_str()] = Children ;
- Children = Children->GetNext() ;
- }
-
- for ( int i = 0 ; i <ClassInfo->GetCreateParamCount() ; ++i )
- {
- const wxChar* paramName = ClassInfo->GetCreateParamName(i) ;
- PropertyNodes::iterator propiter = propertyNodes.find( paramName ) ;
- // if we don't have the value of a create param set in the xml
- // we use the default value
- if ( propiter != propertyNodes.end() )
- {
- wxXmlNode* prop = propiter->second ;
- wxPropertyInfo* pi ;
- CreateParams[i] = ReadPropertyValueNoAssign( prop , ClassInfo , pi , Callbacks ) ;
- // CreateParams[i] = ClassInfo->FindPropertyInfo( ClassInfo->GetCreateParamName(i) ->GetAccessor()->ReadValue( prop ) ;
- for ( size_t j = 0 ; j < propertyNames.size() ; ++j )
- {
- if ( propertyNames[j] == paramName )
- {
- propertyNames[j] = "" ;
- break ;
- }
- }
- }
- else
- {
- CreateParams[i] = ClassInfo->FindPropertyInfo( paramName )->GetDefaultValue() ;
- }
- }
-
- // got the parameters. Call the Create method
- Callbacks->CreateObject(ObjectID,
- ClassInfo,
- ClassInfo->GetCreateParamCount(),
- &CreateParams[0]);
-
- // now stream in the rest of the properties, in the sequence their properties were written in the xml
- for ( size_t j = 0 ; j < propertyNames.size() ; ++j )
- {
- if ( propertyNames[j].length() )
- {
- PropertyNodes::iterator propiter = propertyNodes.find( propertyNames[j] ) ;
- if ( propiter != propertyNodes.end() )
- {
- wxXmlNode* prop = propiter->second ;
- string name = propiter->first ;
- ReadPropertyValue( prop , ClassInfo , ObjectID , Callbacks ) ;
- }
- }
- }
- /*
- for( PropertyNodes::iterator propiter = propertyNodes.begin() ; propiter != propertyNodes.end() ; propiter++ )
- {
- wxXmlNode* prop = propiter->second ;
- string name = propiter->first ;
- ReadPropertyValue( prop , ClassInfo , ObjectID , Callbacks ) ;
- }
- */
-
- // FIXME: if the list of children is not NULL now, then that means that
- // there were properties in the XML not represented in the meta data
- // this just needs error handling.
- assert(!Children);
-
- delete[] CreateParams ;
-
- return ObjectID;