void _TimeIntegrator_Init( 
	void*						timeIntegrator, 
	unsigned int			order, 
	Bool						simultaneous, 
	EntryPoint_Register*	entryPoint_Register,
	AbstractContext*		context )
{
	TimeIntegrator* self = (TimeIntegrator*)timeIntegrator;

	self->context = (DomainContext*)context;
	self->debug = Journal_Register( Debug_Type, (Name)self->type  );
	self->info = Journal_Register( Info_Type, (Name)self->type );
		
	self->integrandRegister = NamedObject_Register_New( );
	self->order = order;
	self->simultaneous = simultaneous;

	/* Entry Point Stuff */
	Stg_asprintf( &self->_setupEPName, "%s-Setup", self->name );
	Stg_asprintf( &self->_finishEPName, "%s-Finish", self->name );
	self->setupEP  = EntryPoint_New( self->_setupEPName,  EntryPoint_VoidPtr_CastType );
	self->finishEP = EntryPoint_New( self->_finishEPName, EntryPoint_VoidPtr_CastType );

	if ( entryPoint_Register ) {
		EntryPoint_Register_Add( entryPoint_Register, self->setupEP );
		EntryPoint_Register_Add( entryPoint_Register, self->finishEP );
	}

	self->setupData = Stg_ObjectList_New();
	self->finishData = Stg_ObjectList_New();

	if ( context ) {
		EP_AppendClassHook( Context_GetEntryPoint( context, AbstractContext_EP_UpdateClass ), TimeIntegrator_UpdateClass, self );
	}
}
void _ModulesManager_Init( void* modulesManager ) {
   ModulesManager* self = (ModulesManager*)modulesManager;
   
   /* General and Virtual info should already be set */
   /* Modules info */

   self->modules = Stg_ObjectList_New();
   self->codelets = Stg_ObjectList_New();
}
void _ForceVector_Init( void* forceVector, Dimension_Index dim, EntryPoint_Register* entryPoint_Register ) {
	ForceVector* self = (ForceVector*)  forceVector;
	
	/* ForceVector info */
	self->dim = dim;
	self->entryPoint_Register = entryPoint_Register;
	
	/* Create Stream */
	self->debug = Stream_RegisterChild( StgFEM_SLE_SystemSetup_Debug, self->type );
	
	/* Create Entry Point for assembleForceVector */
	Stg_asprintf( &self->_assembleForceVectorEPName, "%s-%s", self->name, ForceVector_assembleForceVectorStr );
	self->assembleForceVector = FeEntryPoint_New( self->_assembleForceVectorEPName, FeEntryPoint_AssembleForceVector_CastType );
	EntryPoint_Register_Add( self->entryPoint_Register, self->assembleForceVector );	

	/* Add default hook to assembleForceVector entry point */
	EP_ReplaceAll( self->assembleForceVector, ForceVector_GlobalAssembly_General );

	self->forceTermList = Stg_ObjectList_New();

	self->bcAsm = Assembler_New();
	self->inc = IArray_New();

	self->nModifyCBs = 0;
 	self->modifyCBs = NULL;
}
Stg_ObjectList* stgParseInputPathCmdLineArg( int* argc, char** argv[] ) {
	Index                   arg_I;
	Stg_ObjectList*		allInputPaths = Stg_ObjectList_New();

	/* Loop over all the arguments from command line and reads all arguments of form "--help topic" */
	for( arg_I = 1 ; arg_I < *argc; arg_I++ ) {
		char*                   valueString = 0;
		char*                   argumentString = (*argv)[arg_I];
		const char*             preceedingString = "--inputPath";
		unsigned int            preceedingStringLength = strlen( preceedingString );

		/* Check is string has preceeding string is "--inputPath" if not then continue in loop */
		if( strncmp( preceedingString, argumentString , preceedingStringLength ) != 0 ) {
			continue;
		}
		if( strlen( argumentString ) <= (strlen( preceedingString ) + 1) ) {
			/* i.e. it has = sign (maybe) but not an input path itself */
			continue;
		}
		if( strncmp( "=", &argumentString[preceedingStringLength], 1 ) != 0 ) {
			/* i.e. no = sign */
			continue;
		}

		valueString = StG_Strdup( &(*argv)[arg_I][preceedingStringLength+1] );
		stgRemoveCmdLineArg( argc, argv, arg_I ); /* name=value: --inputPath=??? */
		Stg_ObjectList_Append( allInputPaths, Stg_ObjectAdaptor_NewOfPointer( valueString, 0, True, False, deleteInputPathItem, 0, 0 ) );
	}

	return allInputPaths;
}
void _ToolboxesManager_Init( void* toolboxesManager, int* argc, char*** argv ) {
    ToolboxesManager* self = (ToolboxesManager*)toolboxesManager;

    self->initTB = Stg_ObjectList_New();
    self->argc = argc;
    self->argv = argv;
}
/** add a path to the search paths */
void File_AddPath( char* directory ) {
	Bool found;
	Index dir_i;

	/* Check if it is a valid path */
	if( !directory ) {
		return;
	}

	/* Check if dictionary already exists */
	if( _stgFilePaths == NULL ) {
		_stgFilePaths = Stg_ObjectList_New();
	}
	
	/* Add path to global list */
	found = False;
	for( dir_i =  0; dir_i < _stgFilePaths->count; dir_i++ ){
		if( strcmp( directory, (char*)Stg_ObjectList_ObjectAt( _stgFilePaths, dir_i ) ) == 0 ) {
			found = True;
		}
	}
	
	if( !found ) {
		Stg_ObjectList_PointerAppend( _stgFilePaths, StG_Strdup( directory ), directory, deleteInputPathItem, 0, 0 ); 
	}
}
int main(int argc, char *argv[])
{
	int			rank;
	int			procCount;
	int			procToWatch;
	Stream*			stream;

	/* Initialise MPI, get world info */
	MPI_Init(&argc, &argv);
	MPI_Comm_size(MPI_COMM_WORLD, &procCount);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);

	BaseFoundation_Init( &argc, &argv );

	RegressionTest_Init( "Base/Foundation/PrimitiveObject" );

	stream = Journal_Register( "info", "myStream" );
	
	if( argc >= 2 ) {
		procToWatch = atoi( argv[1] );
	}
	else {
		procToWatch = 0;
	}

	{
		Stg_ObjectList* list;

		list = Stg_ObjectList_New();

		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_UnsignedChar( 'a', "char item" ) );
		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_UnsignedShort( 123, "short item" ) );
		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_UnsignedInt( 456, "int item" ) );
		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_UnsignedLong( 789, "long item" ) );
		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_Char( 'a', "char item" ) );
		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_Short( -123, "short item" ) );
		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_Int( -456, "int item" ) );
		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_Long( -789, "long item" ) );
		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_Float( 1.2f, "float item" ) );
		Stg_ObjectList_Append( list, Stg_PrimitiveObject_New_Double( 2.4, "double item" ) );

		Stg_ObjectList_PrintAllObjects( list, stream );

		Stg_Class_Delete( list );
	}
	
	RegressionTest_Finalise();
	BaseFoundation_Finalise();
	
	/* Close off MPI */
	MPI_Finalize();
	
	return 0; /* success */
}
void _EntryPoint_Init( EntryPoint* self, unsigned int castType ){
   /* General and Virtual info should already be set */
   
   /* EntryPoint info */
   self->castType = castType;
   self->run = self->_getRun( self );
   
   /* Initialise the hooklist */
   self->hooks = Stg_ObjectList_New(); 
   self->alwaysFirstHook = NULL;
   self->alwaysLastHook = NULL;
}
Beispiel #9
0
int main( int argc, char* argv[] ) {
	MPI_Comm CommWorld;
	int rank;
	int numProcessors;
	Stream* stream;

	Stg_ObjectList* directories;
	PluginLoader* plugin;

	/* Initialise MPI, get world info */
	MPI_Init( &argc, &argv );
	MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
	MPI_Comm_size( CommWorld, &numProcessors );
	MPI_Comm_rank( CommWorld, &rank );

	BaseFoundation_Init( &argc, &argv );
	BaseIO_Init( &argc, &argv );
	BaseContainer_Init( &argc, &argv );
	BaseAutomation_Init( &argc, &argv );
	BaseExtensibility_Init( &argc, &argv );

	/* creating a stream */
	stream =  Journal_Register( Info_Type, __FILE__ );

	directories = Stg_ObjectList_New();
	Stg_ObjectList_PointerAppend( directories, StG_Strdup(LIB_DIR), "default dir", 0, 0, 0 );
	
	plugin = PluginLoader_NewLocal( "LocalPlugin", directories );

	Journal_Firewall( plugin != NULL, stream, "Failed!\n" );

	Journal_Printf( stream, "PluginLoader_GetName(): %s\n", PluginLoader_GetName( plugin ) );
	Print( plugin, stream );

	Stg_Class_Delete( plugin );
	Stg_Class_Delete( directories );
	
	BaseExtensibility_Finalise();
	BaseAutomation_Finalise();
	BaseContainer_Finalise();
	BaseIO_Finalise();
	BaseFoundation_Finalise();

	/* Close off MPI */
	MPI_Finalize();
                                                                                                                                    

	return 0;
}
void _NamedObject_Register_Init( NamedObject_Register* self ) {
   self->objects = Stg_ObjectList_New();
}
void LiveComponentRegister_Init( LiveComponentRegister *self ) {
   assert( self );

   self->componentList = Stg_ObjectList_New( );
}