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 */
}
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;
}
Index LiveComponentRegister_Add( LiveComponentRegister *self, Stg_Component *component ) {
   assert( self );
   // check if component is already there. If so don't append to objectList
   if( Stg_ObjectList_Get( self->componentList, component->name ) ) {
      Index id = Stg_ObjectList_GetIndex( self->componentList, component->name );
      // lets just silence this for now
      return id;
   }
   return Stg_ObjectList_Append( self->componentList, component );
}
Index LiveComponentRegister_Add( LiveComponentRegister *self, Stg_Component *component ) {
   assert( self );
   // check if component is already there. If so don't append to objectList
   if( Stg_ObjectList_Get( self->componentList, component->name ) ) {
      Index id = Stg_ObjectList_GetIndex( self->componentList, component->name );
      // lets just silence this for now
      //Journal_Printf( global_error_stream, "### Trying to add component '%s'. But it already exist on the LiveComponentRegister at index %d\n", component->name, id );
      return id;
   }
   return Stg_ObjectList_Append( self->componentList, component );
}
Bool _ToolboxesManager_LoadToolbox( void* toolboxesManager, Module* toolbox ) {
    ToolboxesManager* self = (ToolboxesManager*)toolboxesManager;

    /* if not Loaded call the Initialise() and Register() */
    if( !Stg_ObjectList_Get( self->initTB, toolbox->name ) ) {

        ((Toolbox*)toolbox)->Initialise( self, self->argc, self->argv );
        ((Toolbox*)toolbox)->Register( self );

        Stg_ObjectList_Append( self->initTB, toolbox );
    }
    return True;
}
Index Stg_ObjectList_PointerAppend( 
   void*                                    objectList, 
   void*                                    objectPtr, 
   Name                                     name, 
   Stg_ObjectAdaptor_DeletePointerFunction* ptrDelete,
   Stg_ObjectAdaptor_PrintPointerFunction*  ptrPrint,
   Stg_ObjectAdaptor_CopyPointerFunction*   ptrCopy )
{
   Stg_ObjectList* self = (Stg_ObjectList*) objectList;
   
   return Stg_ObjectList_Append( self,
      Stg_ObjectAdaptor_NewOfPointer( objectPtr, name, True, False, ptrDelete, ptrPrint, ptrCopy ) );
}
void TimeIntegrator_AppendFinishEP( void* timeIntegrator, Name name, Func_Ptr funcPtr, char* addedBy, void* data ) {
	TimeIntegrator*        self            = (TimeIntegrator*)timeIntegrator;

	EntryPoint_Append( self->finishEP, name, funcPtr, addedBy );
	Stg_ObjectList_Append( self->finishData, data );
}
Index Stg_ObjectList_GlobalPointerAppend( void* objectList, void* objectPtr, Name name ) {
   Stg_ObjectList* self = (Stg_ObjectList*) objectList;
   
   return Stg_ObjectList_Append( self, Stg_ObjectAdaptor_NewOfPointer( objectPtr, name, False, True, 0, GlobalPrint, 0 ) );
}
Index Stg_ObjectList_ClassAppend( void* objectList, void* objectPtr, Name name ) {
   Stg_ObjectList* self = (Stg_ObjectList*) objectList;
   
   return Stg_ObjectList_Append( self, Stg_ObjectAdaptor_NewOfClass( objectPtr, name, True, False ) );
}