コード例 #1
0
Stg_Component* _Stg_ComponentFactory_ConstructByNameWithKeyFallback( 
   void*         cf, 
   Name          parentComponentName, 
   Name                 componentTrialName, 
   Dictionary_Entry_Key fallbackKey, 
   Type         type, 
   Bool         isEssential,
   void*         data ) 
{
   Stg_ComponentFactory*   self              = (Stg_ComponentFactory*)cf;
   Stg_Component*      component;
   Stream*         stream            = self->infoStream;

   Journal_PrintfL( stream, 2, "First Trying to find component by name '%s': ", componentTrialName );
   component = LiveComponentRegister_Get( self->LCRegister, componentTrialName );
   
   if (component) {
      Journal_PrintfL( stream, 2, "Found.\n" );

      if ( !component->isConstructed ) {
         Journal_Printf( stream, "%s has not been constructed yet. Constructing now.\n", componentTrialName );
         Stream_Indent( stream );
         Stg_Component_AssignFromXML( component, self, data, True );
         Stream_UnIndent( stream );
      }
   }
   else {
      Journal_PrintfL( stream, 2, "Not found.\n" );
      Journal_PrintfL( stream, 2, "Fallback - Trying to find component by key '%s'.\n", fallbackKey );

      component = self->constructByKey( self, parentComponentName, fallbackKey, type, isEssential, data );
   }
      
   return component;
}
コード例 #2
0
void Stg_ComponentFactory_ConstructComponents( Stg_ComponentFactory* self, void* data ) {
   Stg_Component*                         component                    = NULL;
   Index                                  component_I;
   Stream*                                stream;
   
   assert( self );
   
   stream = self->infoStream;

   if( self->componentDict ){
      Journal_Printf( stream, "\nConstructing Stg_Components from the live-component register\n\n" );
      Stream_Indent( stream );
   
      for( component_I = 0; component_I < LiveComponentRegister_GetCount( self->LCRegister ); component_I++ ){
         /* Grab component from register */
         component = LiveComponentRegister_At( self->LCRegister, component_I );
         if( component && !component->isConstructed ){
            Stg_Component_AssignFromXML( component, self, data, True );
         }
      }
      Stream_UnIndent( stream );
   }
   else{
      Journal_Printf( stream, "No Stg_ComponentList found..!\n" );
   }
}
コード例 #3
0
void _DomainContext_AssignFromXML( void* context, Stg_ComponentFactory* cf, void* data ) {
   DomainContext* self = (DomainContext*)context;
   Dictionary     *contextDict = NULL;

   _AbstractContext_AssignFromXML( context, cf, data );

   self->dim          = Dictionary_GetUnsignedInt_WithDefault( self->dictionary, "dim", 2 );
   self->verticalAxis = Dictionary_GetUnsignedInt_WithDefault( self->dictionary, "VerticalAxis", 1 );

   /* try grab the scaling component and put it on the context 
    * check for the contextDict first as ConstructByKey NEEDS the conextDict 
    * and in units tests the contextDict sometime doesn't exist */
   contextDict = Dictionary_GetDictionary( cf->componentDict, self->name );
   if( contextDict ) {
      self->scaling = Stg_ComponentFactory_ConstructByKey(
         cf,
         self->name, 
         (Dictionary_Entry_Key)"Scaling",
         Scaling,
         False,
         data );
   }
   if( !self->scaling ) {
      self->scaling = Stg_ComponentFactory_ConstructByName(
         cf,
         (Name)"default_scaling", 
         Scaling, False, data ); 
   }

       /* The following is for backward compatiblity with old (GALE) xml files. */
   {
      /* Post change 1d3dc4e00549 in this repositroy, the old style of DofLayout 
       * XML definition was illegal. This change allows for the old style.
       *
       * Here we build all 'MeshVariable' components first.
       *
       * This is a hack, selective construction of general component over other is
       * a weakness to the object model and should be avoided. This section should
       * be removed in future and xml files updated in accordance with change 1d3dc4e00549  
       */

      Stg_Component *component=NULL;
      Index         component_I;
      for( component_I = 0; component_I < LiveComponentRegister_GetCount( cf->LCRegister ); component_I++ ){
         /* Grab component from register */
         component = LiveComponentRegister_At( cf->LCRegister, component_I ); 
         /* if not a "MeshVariable" do nothing */
         if( strcmp( component->type, MeshVariable_Type ) ) continue;

         if( component && !component->isConstructed ){
            Journal_Printf( cf->infoStream, "Constructing %s as %s\n", component->type, component->name );
            Stg_Component_AssignFromXML( component, cf, data, True );
         }

      }
   }

   _DomainContext_Init( self );
}
コード例 #4
0
Stg_Component* _Stg_ComponentFactory_ConstructByName( void* cf, Name componentName, Type type, Bool isEssential, void* data ) {
   Stg_ComponentFactory*   self              = (Stg_ComponentFactory*)cf;
   Stg_Component*      component;
   Stream*         stream            = self->infoStream;

   Journal_PrintfL( stream, 2, "Looking for %sessential component '%s': ", (isEssential ? "" : "non-"), componentName );

   component = LiveComponentRegister_Get( self->LCRegister, componentName );

   /* Checking */
   if (component) {
      Journal_PrintfL( stream, 2, "Found.\n" );

      if ( !component->isConstructed ) {
         /* Journal_Printf( stream, "%s has not been constructed yet. Constructing now.\n", componentName ); */
         Stream_Indent( stream );
         Stg_Component_AssignFromXML( component, self, data, True );
         Stream_UnIndent( stream );
      }

      Stg_Class_CheckType( component, type );

   }
   else {
      Name         redirect;

      /* If we can find the component's name in the root dictionary, use that value instead. */
      if( self->rootDict ) {
         redirect = Dictionary_GetString_WithDefault( self->rootDict, componentName, "" );
         if( strcmp( redirect, "" ) ) {
            componentName = redirect;
            return self->constructByName( self, componentName, type, isEssential, data );
         }
      }

      Journal_PrintfL( stream, 2, "Not found.\n" );

      if ( isEssential ) {
         Stream* errorStream = Journal_Register( Error_Type, self->type );

         Journal_Printf( errorStream, "In func %s: Cannot find essential component '%s'.\n", __func__, componentName );

         Journal_Printf( errorStream, "Could you have meant one of these?\n" );

         Stream_Indent( errorStream );
         LiveComponentRegister_PrintSimilar( self->LCRegister, componentName, errorStream, 5 );
         Journal_Firewall( 0, errorStream, "" );
      }
   }
   
   return component;
}
コード例 #5
0
PyObject* Context_Python_AssignFromXML( PyObject* self, PyObject* args ) {
	PyObject*	pyContext;
	Context*	context;

	/* Obtain arguements */
	if( !PyArg_ParseTuple( args, "O:", &pyContext ) ) {
		return NULL;
	}
	context = (Context*)( PyCObject_AsVoidPtr( pyContext ) );

	Stg_Component_AssignFromXML( context, 0 /* dummy */, &context, True );

	/* Return */
	Py_INCREF( Py_None );
	return PyCObject_FromVoidPtr( context, 0 );
	}