[cig-commits] commit: merging pcu_rejig into default
Mercurial
hg at geodynamics.org
Mon Feb 1 15:33:43 PST 2010
changeset: 767:767daf30b22b
parent: 756:71b60b1562af
parent: 766:53cb4f910327
user: JulianGiordani
date: Tue Jan 12 14:38:16 2010 +1100
files: Base/Automation/src/CompositeVC.c Base/Automation/src/CompositeVC.h Base/Automation/src/CompositeVC.meta Base/Automation/src/ConditionFunction.c Base/Automation/src/ConditionFunction.h Base/Automation/src/ConditionFunction_Register.c Base/Automation/src/ConditionFunction_Register.h Base/Automation/src/DynamicVC.c Base/Automation/src/DynamicVC.h Base/Automation/src/DynamicVC.meta Base/Automation/src/SetVC.c Base/Automation/src/SetVC.h Base/Automation/src/SetVC.meta Base/Automation/src/Variable.c Base/Automation/src/Variable.h Base/Automation/src/Variable.meta Base/Automation/src/VariableAllVC.c Base/Automation/src/VariableAllVC.h Base/Automation/src/VariableAllVC.meta Base/Automation/src/VariableCondition.c Base/Automation/src/VariableCondition.h Base/Automation/src/VariableCondition.meta Base/Automation/src/VariableCondition_Register.c Base/Automation/src/VariableCondition_Register.h Base/Automation/src/VariableDumpStream.c Base/Automation/src/VariableDumpStream.h Base/Automation/src/Variable_Register.c Base/Automation/src/Variable_Register.h Base/Automation/tests/ConditionFunctionSuite.c Base/Automation/tests/ConditionFunctionSuite.h Base/Automation/tests/LiveComponentRegisterSuite.c Base/Automation/tests/LiveComponentRegisterSuite.h Base/Automation/tests/SetVC_Suite.c Base/Automation/tests/SetVC_Suite.h Base/Automation/tests/Stg_MetaSuite.c Base/Automation/tests/Stg_MetaSuite.h Base/Automation/tests/VariableAllVC_Suite.c Base/Automation/tests/VariableAllVC_Suite.h Base/Automation/tests/VariableDumpStreamSuite.c Base/Automation/tests/VariableDumpStreamSuite.h Base/Automation/tests/VariableSuite.c Base/Automation/tests/VariableSuite.h Base/Automation/tests/Variable_RegisterSuite.c Base/Automation/tests/Variable_RegisterSuite.h Base/Automation/tests/input/ComponentVCMetaDict.xml Base/Automation/tests/input/setVC.xml Base/Extensibility/src/Codelet.c Base/Extensibility/src/Codelet.h Base/Extensibility/src/Codelet.meta script/convert.py
description:
merging pcu_rejig into default
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Automation.h
--- a/Base/Automation/src/Automation.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Automation.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Automation_h__
-#define __Base_Automation_h__
+#ifndef __StGermain_Base_Automation_h__
+#define __StGermain_Base_Automation_h__
#include "types.h"
#include "shortcuts.h"
@@ -51,20 +51,9 @@
#include "LiveComponentRegister.h"
#include "Stg_ComponentFactory.h"
#include "DocumentationComponentFactory.h"
- #include "Variable.h"
- #include "Variable_Register.h"
- #include "VariableDumpStream.h"
- #include "ConditionFunction.h"
- #include "ConditionFunction_Register.h"
- #include "VariableCondition.h"
- #include "VariableCondition_Register.h"
- #include "CompositeVC.h"
- #include "SetVC.h"
- #include "VariableAllVC.h"
- #include "DynamicVC.h"
#include "HierarchyTable.h"
#include "CallGraph.h"
#include "Init.h"
#include "Finalise.h"
-#endif /* __Base_Automation_h__ */
+#endif /* __StGermain_Base_Automation_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/CallGraph.c
--- a/Base/Automation/src/CallGraph.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/CallGraph.c Tue Jan 12 14:38:16 2010 +1100
@@ -54,12 +54,14 @@ Stg_CallGraph* stgCallGraph = 0;
Stg_CallGraph* Stg_CallGraph_New() {
- return _Stg_CallGraph_New(
- sizeof(Stg_CallGraph),
- Stg_CallGraph_Type,
- _Stg_CallGraph_Delete,
- _Stg_CallGraph_Print,
- _Stg_CallGraph_Copy );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Stg_CallGraph);
+ Type type = Stg_CallGraph_Type;
+ Stg_Class_DeleteFunction* _delete = _Stg_CallGraph_Delete;
+ Stg_Class_PrintFunction* _print = _Stg_CallGraph_Print;
+ Stg_Class_CopyFunction* _copy = _Stg_CallGraph_Copy;
+
+ return _Stg_CallGraph_New( STG_CALLGRAPH_PASSARGS );
}
void Stg_CallGraph_Init( void* callGraph ) {
@@ -80,12 +82,7 @@ void Stg_CallGraph_Init( void* callGraph
_Stg_CallGraph_Init( self );
};
-Stg_CallGraph* _Stg_CallGraph_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
+Stg_CallGraph* _Stg_CallGraph_New( STG_CALLGRAPH_DEFARGS )
{
Stg_CallGraph* self;
@@ -94,7 +91,7 @@ Stg_CallGraph* _Stg_CallGraph_New(
_sizeOfSelf >= sizeof(Stg_CallGraph),
Journal_Register( Error_Type, Stg_CallGraph_Type ),
"Attempting to construct an object that is smaller than this class" );
- self = (Stg_CallGraph*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (Stg_CallGraph*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -354,3 +351,5 @@ void Stg_CallGraph_Pop( void* callGraph
self->_stack = oldStack->pop;
Memory_Free( oldStack );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/CallGraph.h
--- a/Base/Automation/src/CallGraph.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/CallGraph.h Tue Jan 12 14:38:16 2010 +1100
@@ -36,8 +36,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_Stg_CallGraph_h__
-#define __Base_Automation_Stg_CallGraph_h__
+#ifndef __StGermain_Base_Automation_Stg_CallGraph_h__
+#define __StGermain_Base_Automation_Stg_CallGraph_h__
/* Templates of virtual functions */
typedef struct {
@@ -89,12 +89,18 @@
void Stg_CallGraph_Init( void* callGraph );
/* Creation implementation */
- Stg_CallGraph* _Stg_CallGraph_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STG_CALLGRAPH_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define STG_CALLGRAPH_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ Stg_CallGraph* _Stg_CallGraph_New( STG_CALLGRAPH_DEFARGS );
/* Class Administration members ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -126,4 +132,5 @@
/** Pop the function on the stack, and finalise trace */
void Stg_CallGraph_Pop( void* callGraph );
-#endif /* __Base_Automation_Stg_CallGraph_h__ */
+#endif /* __StGermain_Base_Automation_Stg_CallGraph_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Comm.c
--- a/Base/Automation/src/Comm.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Comm.c Tue Jan 12 14:38:16 2010 +1100
@@ -330,3 +330,5 @@ void Comm_AlltoallEnd( const void* _self
self->itmSize = 0;
self->srcSizes = NULL;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Component.c
--- a/Base/Automation/src/Component.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Component.c Tue Jan 12 14:38:16 2010 +1100
@@ -116,3 +116,5 @@ Bool Component_HasExecuted( void* self )
assert( Class_IsSuper( self, stgComponent ) );
return ((stgComponent*)self)->hasExecuted;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/CompositeVC.c
--- a/Base/Automation/src/CompositeVC.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,772 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: CompositeVC.c 4298 2008-08-25 01:14:56Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "shortcuts.h"
-#include "Stg_Component.h"
-#include "Stg_ComponentFactory.h"
-#include "LiveComponentRegister.h"
-#include "Variable.h"
-#include "Variable_Register.h"
-#include "VariableCondition.h"
-#include "VariableCondition_Register.h"
-#include "CompositeVC.h"
-
-#include <string.h>
-#include <assert.h>
-
-
-const Type CompositeVC_Type = "CompositeVC";
-const Name defaultCompositeVCName = "defaultCompositeVCName";
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Constructor
-*/
-
-VariableCondition* CompositeVC_Factory(
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data )
-{
- return (VariableCondition*)CompositeVC_New( defaultCompositeVCName, variable_Register, conFunc_Register, dictionary, data );
-}
-
-
-CompositeVC* CompositeVC_New(
- Name name,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data )
-{
- return _CompositeVC_New(
- sizeof(CompositeVC),
- CompositeVC_Type,
- _CompositeVC_Delete,
- _CompositeVC_Print,
- _CompositeVC_Copy,
- (Stg_Component_DefaultConstructorFunction*)CompositeVC_DefaultNew,
- _CompositeVC_Construct,
- _CompositeVC_Build,
- _VariableCondition_Initialise,
- _VariableCondition_Execute,
- _VariableCondition_Destroy,
- name,
- True,
- NULL,
- _CompositeVC_PrintConcise,
- _CompositeVC_ReadDictionary,
- _CompositeVC_GetSet,
- _CompositeVC_GetVariableCount,
- _CompositeVC_GetVariableIndex,
- _CompositeVC_GetValueIndex,
- _CompositeVC_GetValueCount,
- _CompositeVC_GetValue,
- _CompositeVC_Apply,
- variable_Register,
- conFunc_Register,
- dictionary,
- data );
-}
-
-CompositeVC* CompositeVC_DefaultNew( Name name )
-{
- return (CompositeVC*)_CompositeVC_New(
- sizeof(CompositeVC),
- CompositeVC_Type,
- _CompositeVC_Delete,
- _CompositeVC_Print,
- _CompositeVC_Copy,
- (Stg_Component_DefaultConstructorFunction*)CompositeVC_DefaultNew,
- _CompositeVC_Construct,
- _CompositeVC_Build,
- _VariableCondition_Initialise,
- _VariableCondition_Execute,
- _VariableCondition_Destroy,
- name,
- False,
- NULL,
- _CompositeVC_PrintConcise,
- _CompositeVC_ReadDictionary,
- _CompositeVC_GetSet,
- _CompositeVC_GetVariableCount,
- _CompositeVC_GetVariableIndex,
- _CompositeVC_GetValueIndex,
- _CompositeVC_GetValueCount,
- _CompositeVC_GetValue,
- _CompositeVC_Apply,
- NULL/*variable_Register*/,
- NULL/*conFunc_Register*/,
- NULL,
- NULL );
-}
-
-void CompositeVC_Init(
- CompositeVC* self,
- Name name,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data )
-{
- /* General info */
- self->type = CompositeVC_Type;
- self->_sizeOfSelf = sizeof(CompositeVC);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _CompositeVC_Delete;
- self->_print = _CompositeVC_Print;
- self->_copy = _CompositeVC_Copy;
- self->_build = _CompositeVC_Build;
- self->_initialise = _VariableCondition_Initialise;
- self->_execute = _VariableCondition_Execute;
- self->_buildSelf = NULL;
- self->_printConcise = _CompositeVC_PrintConcise;
- self->_readDictionary = _CompositeVC_ReadDictionary;
- self->_getSet = _CompositeVC_GetSet;
- self->_getVariableCount = _CompositeVC_GetVariableCount;
- self->_getVariableIndex = _CompositeVC_GetVariableIndex;
- self->_getValueIndex = _CompositeVC_GetValueIndex;
- self->_getValueCount = _CompositeVC_GetValueCount;
- self->_getValue = _CompositeVC_GetValue;
- self->_apply = _VariableCondition_Apply;
-
- _Stg_Class_Init( (Stg_Class*)self );
- _Stg_Object_Init( (Stg_Object*)self, name, NON_GLOBAL );
- _Stg_Component_Init( (Stg_Component*)self );
- _VariableCondition_Init( (VariableCondition*)self, variable_Register, conFunc_Register, dictionary );
-
- /* Stg_Class info */
- _CompositeVC_Init( self, data );
-}
-
-
-CompositeVC* _CompositeVC_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data)
-{
- CompositeVC* self;
-
- /* Allocate memory/General info */
- assert(_sizeOfSelf >= sizeof(CompositeVC));
- self = (CompositeVC*)_VariableCondition_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _defaultConstructor,
- _construct,
- _build,
- _initialise,
- _execute,
- _destroy,
- name,
- initFlag,
- _buildSelf,
- _printConcise,
- _readDictionary,
- _getSet,
- _getVariableCount,
- _getVariableIndex,
- _getValueIndex,
- _getValueCount,
- _getValue,
- _apply,
- variable_Register,
- conFunc_Register,
- dictionary );
-
- /* Virtual info */
-
- /* Stg_Class info */
- if( initFlag ){
- _CompositeVC_Init( self, data );
- }
-
- return self;
-}
-
-
-void _CompositeVC_Init(
- void* compositeVC,
- void* data )
-{
- CompositeVC* self = (CompositeVC*)compositeVC;
-
- self->isConstructed = True;
- self->itemCount = 0;
- self->nIndepItems = 0;
- self->indepItems = NULL;
- self->_size = 8;
- self->_delta = 8;
- self->itemTbl = Memory_Alloc_Array( VariableCondition*, self->_size, "CompositeCV->itemTbl" );
- memset(self->itemTbl, 0 , sizeof(VariableCondition*)*self->_size);
- self->iOwnTbl = Memory_Alloc_Array( Bool, self->_size, "CompositeCV->iOwnTbl" );
- memset(self->iOwnTbl, 0, sizeof(Bool)*self->_size);
- self->data = data;
- self->attachedSets = 0;
- self->hasReadDictionary = False;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** General virtual functions
-*/
-
-void _CompositeVC_ReadDictionary( void* compositeVC, void* dictionary ) {
- CompositeVC* self = (CompositeVC*)compositeVC;
-
- /* View the dictionary as a list of variable conditions */
- if( dictionary && !self->hasReadDictionary ) {
- Dictionary_Entry_Value* vcList;
-
- vcList = Dictionary_Get( dictionary, "independentVCList" );
- if( vcList ) {
- Index count;
- Index entry_I;
-
- count = Dictionary_Entry_Value_GetCount(vcList);
- for (entry_I = 0; entry_I < count; entry_I++)
- {
- Dictionary_Entry_Value* vcEntry;
- Type type;
- Dictionary* dictionary;
- VariableCondition* vc;
-
- vcEntry = Dictionary_Entry_Value_GetElement(vcList, entry_I);
- type = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(vcEntry, "type"));
- dictionary = Dictionary_Entry_Value_AsDictionary(vcEntry);
- vc = VariableCondition_Register_CreateNew(variableCondition_Register, self->variable_Register,
- self->conFunc_Register, type, dictionary, self->data );
- vc->cf = self->cf;
- vc->_readDictionary( vc, dictionary );
-
- self->nIndepItems++;
- self->indepItems = ReallocArray(
- self->indepItems, VariableCondition*, self->nIndepItems );
- self->indepItems[self->nIndepItems - 1] = vc;
-
- /* Don't add so we can modify the matrix later.
- CompositeVC_Add(self, vc, True);
- */
- }
-
- }
- vcList = Dictionary_Get( dictionary, "vcList" );
- if( vcList ) {
- Index count;
- Index entry_I;
-
- count = Dictionary_Entry_Value_GetCount(vcList);
- for (entry_I = 0; entry_I < count; entry_I++)
- {
- Dictionary_Entry_Value* vcEntry;
- Type type;
- Dictionary* dictionary;
- VariableCondition* vc;
-
- vcEntry = Dictionary_Entry_Value_GetElement(vcList, entry_I);
- type = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(vcEntry, "type"));
- dictionary = Dictionary_Entry_Value_AsDictionary(vcEntry);
- vc = VariableCondition_Register_CreateNew(variableCondition_Register, self->variable_Register,
- self->conFunc_Register, type, dictionary, self->data );
- vc->_readDictionary( vc, dictionary );
- CompositeVC_Add(self, vc, True);
- }
-
- }
- self->hasReadDictionary = True;
- }
-}
-
-void _CompositeVC_Construct( void* compositeVC, Stg_ComponentFactory* cf, void* data ) {
- CompositeVC* self = (CompositeVC*)compositeVC;
- void* variableRegister = NULL;
- void* conditionFunctionRegister = NULL;
- void* initData = NULL;
- Dictionary* vcDict = NULL;
- Name vcName;
-
- self->dictionary = cf->rootDict;
-
- /* Need to store this so we can get at components
- later on when using the fucked up 'ReadDictionary' function. */
- self->cf = cf;
-
- variableRegister = (void*)Stg_ObjectList_Get( cf->registerRegister, "Variable_Register" );
- assert( variableRegister );
- conditionFunctionRegister = (void*)Stg_ObjectList_Get( cf->registerRegister, "ConditionFunction_Register" );
- assert( conditionFunctionRegister );
-
- vcName = Stg_ComponentFactory_GetString( cf, self->name, "vcName", self->name );
- if ( cf->rootDict )
- vcDict = Dictionary_GetDictionary( cf->rootDict, vcName );
-/* Journal_Firewall( */
-/* vcDict != NULL, */
-/* Journal_Register( Error_Type, self->type ), */
-/* "For %s '%s' - Cannont find variable condition dictionary '%s'\n", self->type, self->name, vcName ); */
-
- initData = Stg_ComponentFactory_ConstructByKey( cf, self->name, "Data", Stg_Component, False, data );
-
- _VariableCondition_Init( self, variableRegister, conditionFunctionRegister, vcDict );
- _CompositeVC_Init( self, initData );
-}
-
-void _CompositeVC_Delete(void* compositeVC)
-{
- CompositeVC* self = (CompositeVC*)compositeVC;
- int ii;
-
- if (self->itemTbl)
- {
- VariableCondition_Index entry_I;
-
- for (entry_I = 0; entry_I < self->itemCount; entry_I++)
- {
- if (self->iOwnTbl[entry_I] && self->itemTbl[entry_I])
- Memory_Free(self->itemTbl[entry_I]);
- }
-
- Memory_Free(self->itemTbl);
- }
-
- if( self->attachedSets ) {
- Memory_Free( self->attachedSets );
- }
-
- if( self->indepItems ) {
- for( ii = 0; ii < self->nIndepItems; ii++ )
- Stg_Class_Delete( self->indepItems[ii] );
- FreeArray( self->indepItems );
- }
-
- /* Stg_Class_Delete parent */
- _VariableCondition_Delete(self);
-}
-
-
-void _CompositeVC_Print(void* compositeVC, Stream* stream)
-{
- CompositeVC* self = (CompositeVC*)compositeVC;
- Index item_I;
-
- /* Set the Journal for printing informations */
- Stream* info = stream;
-
- /* General info */
- Journal_Printf( info, "CompositeVC (ptr): %p\n", self);
-
- /* Virtual info */
-
- /* Stg_Class info */
- Journal_Printf( info, "\tdictionary (ptr): %p\n", self->dictionary);
- Journal_Printf( info, "\titemCount: %u\n", self->itemCount );
- Journal_Printf( info, "\titemTbl (ptr): %p\n", self->itemTbl);
- if (self->itemTbl)
- {
- for (item_I = 0; item_I < self->itemCount; item_I++)
- Journal_Printf( info, "\t\titemTbl[%u] (ptr): %p\n", item_I, self->itemTbl[item_I]);
- }
- Journal_Printf( info, "\tiOwnTbl (ptr): %p\n", self->iOwnTbl);
- if (self->iOwnTbl)
- {
- for (item_I = 0; item_I < self->itemCount; item_I++)
- Journal_Printf( info, "\t\tiOwnTbl[%u]: %s\n", item_I, self->iOwnTbl[item_I] ? "True" : "False");
- }
- Journal_Printf( info, "\t_size: %lu\n", self->_size);
- Journal_Printf( info, "\t_delta: %lu\n", self->_delta);
-
- /* Print parent */
- _VariableCondition_Print(self);
-}
-
-
-void* _CompositeVC_Copy( void* compositeVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
- CompositeVC* self = (CompositeVC*)compositeVC;
- CompositeVC* newCompositeVC;
- PtrMap* map = ptrMap;
- Bool ownMap = False;
-
- if( !map ) {
- map = PtrMap_New( 10 );
- ownMap = True;
- }
-
- newCompositeVC = (CompositeVC*)_VariableCondition_Copy( self, dest, deep, nameExt, map );
-
- newCompositeVC->itemCount = self->itemCount;
- newCompositeVC->_size = self->_size;
- newCompositeVC->_delta = self->_delta;
- newCompositeVC->hasReadDictionary = self->hasReadDictionary;
- newCompositeVC->data = self->data;
-
- if( deep ) {
- if( (newCompositeVC->itemTbl = PtrMap_Find( map, self->itemTbl )) == NULL && self->itemTbl ) {
- Index item_I;
-
- newCompositeVC->itemTbl = Memory_Alloc_Array( VariableCondition*, newCompositeVC->_size, "CompositeCV->itemTbl" );
- memset( newCompositeVC->itemTbl, 0, sizeof(VariableCondition*) * newCompositeVC->_size );
- for( item_I = 0; item_I < self->itemCount; item_I++ ) {
- newCompositeVC->itemTbl[item_I] = (VariableCondition*)Stg_Class_Copy( self->itemTbl[item_I], NULL, deep, nameExt, map );
- }
- PtrMap_Append( map, newCompositeVC->itemTbl, self->itemTbl );
- }
-
- if( (newCompositeVC->iOwnTbl = PtrMap_Find( map, self->iOwnTbl )) == NULL && self->iOwnTbl ) {
- newCompositeVC->iOwnTbl = Memory_Alloc_Array( Bool, newCompositeVC->_size, "CompositeCV->iOwnTbl" );
- memcpy( newCompositeVC->iOwnTbl, self->iOwnTbl, sizeof(Bool) * newCompositeVC->_size );
- PtrMap_Append( map, newCompositeVC->iOwnTbl, self->iOwnTbl );
- }
-
- if( (newCompositeVC->attachedSets = PtrMap_Find( map, self->attachedSets )) == NULL && self->attachedSets ) {
- Index item_I;
-
- self->attachedSets = Memory_Alloc_Array( IndexSet*, newCompositeVC->itemCount, "CompositeCV->attachedSets" );
- for( item_I = 0; item_I < self->itemCount; item_I++ ) {
- newCompositeVC->attachedSets[item_I] = (IndexSet*)Stg_Class_Copy( self->attachedSets[item_I], NULL, deep, nameExt, map );
- }
- PtrMap_Append( map, newCompositeVC->attachedSets, self->attachedSets );
- }
- }
- else {
- newCompositeVC->itemTbl = self->itemTbl;
- newCompositeVC->iOwnTbl = self->iOwnTbl;
- newCompositeVC->attachedSets = self->attachedSets;
- }
-
- if( ownMap ) {
- Stg_Class_Delete( map );
- }
-
- return (void*)newCompositeVC;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Macros
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _CompositeVC_Build( void* compositeVC, void* data ) {
- CompositeVC* self = (CompositeVC*)compositeVC;
- Index index;
- int ii;
-
- /* Read the dictionary... we have to do this early to get self->itemCount filled in. Hence we keep a flag to ensure we
- dont read twice */
- self->_readDictionary( self, self->dictionary );
-
- /* Build a temporary array to store the sets of attached VCs for the build process and clear it afterward */
- if( self->itemCount ) {
- Index item_I;
-
- self->attachedSets = Memory_Alloc_Array( IndexSet*, self->itemCount, "CompositeCV->attachedSets" );
- memset( self->attachedSets, 0, sizeof(IndexSet*) * self->itemCount );
-
- /* This guy is here so that a VC that was created by the composite VC can do any
- build stuff it needs, without calling _VariableCondition_Build for itself. */
- for( item_I = 0; item_I < self->itemCount; item_I++ ) {
- VariableCondition_BuildSelf( self->itemTbl[item_I], data );
- }
-
- _VariableCondition_Build( self, data );
- for( index = 0; index < self->itemCount; index++ ) {
- Stg_Class_Delete( self->attachedSets[index] );
- }
- Memory_Free( self->attachedSets );
- self->attachedSets = 0;
- }
-
- for( ii = 0; ii < self->nIndepItems; ii++ )
- Stg_Component_Build( self->indepItems[ii], data, False );
-}
-
-
-IndexSet* _CompositeVC_GetSet( void* compositeVC ) {
- CompositeVC* self = (CompositeVC*)compositeVC;
- IndexSet* set = NULL;
- Index i;
-
- /* Use the first attachment to obtain the size, etc. Be effecient by duplicating if for the my own set */
- if( self->itemCount ) {
- self->attachedSets[0] = self->itemTbl[0]->_getSet( self->itemTbl[0] );
- set = IndexSet_Duplicate( self->attachedSets[0] );
- }
-
- /* For the remainder of the attachments, OR in their sets */
- for( i = 1; i < self->itemCount; i++ ) {
- self->attachedSets[i] = self->itemTbl[i]->_getSet( self->itemTbl[i] );
- IndexSet_Merge_OR( set, self->attachedSets[i] );
- }
-
- return set;
-}
-
-
-Variable_Index _CompositeVC_GetVariableCount( void* compositeVC, Index globalIndex ) {
- CompositeVC* self = (CompositeVC*)compositeVC;
- Variable_Index* varIndices;
- Variable_Index varIndexCount = 0;
- Index i;
-
- varIndices = Memory_Alloc_Array( Variable_Index, self->variable_Register->count, "varIndices" );
-
- for( i = 0; i < self->itemCount; i++ ) {
- if( IndexSet_IsMember( self->attachedSets[i], globalIndex ) ) {
- Index varCount = self->itemTbl[i]->_getVariableCount( self->itemTbl[i], globalIndex );
- Index j;
-
- for(j = 0; j < varCount; j++ ) {
- Index newVarIndex = self->itemTbl[i]->_getVariableIndex(self->itemTbl[i], globalIndex, j);
- Index k;
-
- for (k = 0; k < varIndexCount; k++)
- if (varIndices[k] == newVarIndex)
- break;
- if (k < varIndexCount)
- continue;
-
- varIndices[varIndexCount++] = newVarIndex;
- }
- }
- }
-
- if (varIndices) Memory_Free(varIndices);
-
- return varIndexCount;
-}
-
-
-Variable_Index _CompositeVC_GetVariableIndex(
- void* compositeVC,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex)
-{
- CompositeVC* self = (CompositeVC*)compositeVC;
- Variable_Index* varIndices;
- Variable_Index varIndexCount = 0;
- Index i;
-
- varIndices = Memory_Alloc_Array( Variable_Index, self->variable_Register->count, "varIndices" );
-
- for( i = 0; i < self->itemCount; i++ ) {
- if( IndexSet_IsMember( self->attachedSets[i], globalIndex ) ) {
- Index varCount = self->itemTbl[i]->_getVariableCount(self->itemTbl[i], globalIndex);
- Index j;
-
- for (j = 0; j < varCount; j++)
- {
- Index newVarIndex = self->itemTbl[i]->_getVariableIndex(self->itemTbl[i], globalIndex, j);
- Index k;
-
- for (k = 0; k < varIndexCount; k++)
- if (varIndices[k] == newVarIndex)
- break;
- if (k < varIndexCount)
- continue;
-
- if (varIndexCount == varIndex)
- {
- if (varIndices) Memory_Free(varIndices);
- return newVarIndex;
- }
-
- varIndices[varIndexCount++] = newVarIndex;
- }
- }
- }
-
- if (varIndices) Memory_Free(varIndices);
-
- return (Variable_Index)-1;
-}
-
-
-VariableCondition_ValueIndex _CompositeVC_GetValueIndex(
- void* compositeVC,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex)
-{
- CompositeVC* self = (CompositeVC*)compositeVC;
- VariableCondition_ValueIndex valIndex = (VariableCondition_ValueIndex)-1;
- CompositeVC_ItemIndex valItem = 0;
- Variable_Index varRegIndex = self->_getVariableIndex(self, globalIndex, varIndex);
- Index i;
-
- for( i = self->itemCount; i > 0; i-- ) {
- if( IndexSet_IsMember( self->attachedSets[i-1], globalIndex ) ) {
- Index j;
-
- for (j = 0; j < self->itemTbl[i - 1]->_getVariableCount(self->itemTbl[i - 1], globalIndex); j++)
- if (self->itemTbl[i - 1]->_getVariableIndex(self->itemTbl[i - 1], globalIndex, j) ==
- varRegIndex)
- break;
- if (j == self->itemTbl[i - 1]->_getVariableCount(self->itemTbl[i - 1], globalIndex))
- continue;
-
- valItem = i - 1;
- valIndex = self->itemTbl[valItem]->_getValueIndex(self->itemTbl[valItem], globalIndex, j);
- break;
- }
- }
-
- for (i = 0; i < valItem; i++)
- valIndex += self->itemTbl[i]->_getValueCount(self->itemTbl[i]);
-
- return valIndex;
-}
-
-
-VariableCondition_ValueIndex _CompositeVC_GetValueCount(void* compositeVC)
-{
- CompositeVC* self = (CompositeVC*)compositeVC;
- VariableCondition_ValueIndex valCount = 0;
- Index i;
-
- for (i = 0; i < self->itemCount; i++)
- valCount += self->itemTbl[i]->_getValueCount(self->itemTbl[i]);
-
- return valCount;
-}
-
-
-VariableCondition_Value _CompositeVC_GetValue(void* compositeVC, VariableCondition_ValueIndex valIndex)
-{
- CompositeVC* self = (CompositeVC*)compositeVC;
- VariableCondition_ValueIndex valPos = valIndex;
- Index i = 0;
-
- while (valPos >= self->itemTbl[i]->_getValueCount(self->itemTbl[i]))
- {
- valPos -= self->itemTbl[i]->_getValueCount(self->itemTbl[i]);
- i++;
-/* if (++i >= self->itemCount) */
- /* Then what? */
- }
-
- return self->itemTbl[i]->_getValue(self->itemTbl[i], valPos);
-}
-
-
-void _CompositeVC_PrintConcise( void* compositeVC, Stream* stream ) {
- CompositeVC* self = (CompositeVC*)compositeVC;
- Index item_I;
-
- Journal_Printf( stream, "\ttype: %s, {\n", self->type );
- if( self->itemTbl ) {
- for( item_I = 0; item_I < self->itemCount; item_I++ ) {
- VariableCondition_PrintConcise( self->itemTbl[item_I], stream );
- }
- }
- Journal_Printf( stream, "}\n" );
-}
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Build functions
-*/
-
-CompositeVC_ItemIndex CompositeVC_Add(void* compositeVC, void* variableCondition, Bool iOwn)
-{
- CompositeVC* self = (CompositeVC*)compositeVC;
- CompositeVC_ItemIndex handle;
-
- if (self->itemCount >= self->_size)
- {
- SizeT currentSize = self->_size;
-
- self->_size += self->_delta;
-
- self->itemTbl = Memory_Realloc_Array( self->itemTbl, VariableCondition*, self->_size );
- memset( (Pointer)((ArithPointer)self->itemTbl + (sizeof(VariableCondition*) * currentSize) ),
- 0, sizeof(VariableCondition*) * (self->_size - currentSize) );
-
- self->iOwnTbl = Memory_Realloc_Array( self->iOwnTbl, Bool, self->_size );
- memset( (Pointer)((ArithPointer)self->iOwnTbl + (sizeof(Bool) * currentSize )),
- 0, sizeof(Bool) * (self->_size - currentSize ) );
- }
-
- handle = self->itemCount++;
- self->itemTbl[handle] = (VariableCondition*) variableCondition;
- self->iOwnTbl[handle] = iOwn;
-
- return handle;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Functions
-*/
-
-void _CompositeVC_Apply( void* _self, void* _ctx ) {
- CompositeVC* self = (CompositeVC*)_self;
- int ii;
-
- _VariableCondition_Apply( self, _ctx );
-
- for( ii = 0; ii < self->nIndepItems; ii++ )
- VariableCondition_Apply( self->indepItems[ii], _ctx );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/CompositeVC.h
--- a/Base/Automation/src/CompositeVC.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-/** \file
-** <b>Role:</b>
-**
-** <b>Assumptions:</b>
-**
-** <b>Comments:</b>
-**
-** $Id: CompositeVC.h 4297 2008-08-19 16:54:05Z LukeHodkinson $
-**
-**/
-
-#ifndef __Base_Automation_CompositeVC_h__
-#define __Base_Automation_CompositeVC_h__
-
-
- extern const Type CompositeVC_Type;
-
-
- #define __CompositeVC \
- /* General info */ \
- __VariableCondition \
- \
- /* Virtual info */ \
- \
- /* Stg_Class info */ \
- CompositeVC_ItemIndex itemCount; \
- VariableCondition** itemTbl; \
- int nIndepItems; \
- VariableCondition** indepItems; \
- Bool* iOwnTbl; \
- SizeT _size; \
- SizeT _delta; \
- void* data; \
- IndexSet** attachedSets; \
- Bool hasReadDictionary;
-
- struct _CompositeVC { __CompositeVC };
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructor
- */
-
- VariableCondition* CompositeVC_Factory(
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data );
-
- CompositeVC* CompositeVC_New(
- Name name,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data );
-
- CompositeVC* CompositeVC_DefaultNew( Name name );
-
- void CompositeVC_Init(
- CompositeVC* self,
- Name name,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data );
-
- CompositeVC* _CompositeVC_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data );
-
- void _CompositeVC_Init(
- void* compositeVC,
- void* data );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** General virtual functions
- */
-
- void _CompositeVC_Delete( void* compositeVC );
-
- void _CompositeVC_Print( void* compositeVC, Stream* stream );
-
- /* Copy */
- #define CompositeVC_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
- #define CompositeVC_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
-
- void* _CompositeVC_Copy( void* compositeVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Macros
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _CompositeVC_Build( void* compositeVC, void* data );
-
- void _CompositeVC_Construct( void* compositeVC, Stg_ComponentFactory* cf, void* data );
-
- void _CompositeVC_ReadDictionary( void* compositeVC, void* dictionary );
-
- IndexSet* _CompositeVC_GetSet( void* compositeVC );
-
- VariableCondition_VariableIndex _CompositeVC_GetVariableCount( void* compositeVC, Index globalIndex );
-
- Variable_Index _CompositeVC_GetVariableIndex(
- void* compositeVC,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex );
-
- VariableCondition_ValueIndex _CompositeVC_GetValueIndex(
- void* compositeVC,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex );
-
- VariableCondition_ValueIndex _CompositeVC_GetValueCount( void* compositeVC );
-
- VariableCondition_Value _CompositeVC_GetValue( void* compositeVC, VariableCondition_ValueIndex valIndex );
-
- void _CompositeVC_PrintConcise( void* variableCondition, Stream* stream );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Build functions
- */
-
- CompositeVC_ItemIndex CompositeVC_Add( void* compositeVC, void* variableCondition, Bool iOwn );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Functions
- */
-
-void _CompositeVC_Apply( void* _self, void* _ctx );
-
-
-#endif /* __Base_Automation_CompositeVC_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/CompositeVC.meta
--- a/Base/Automation/src/CompositeVC.meta Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
-<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
-
-<param name="Name">CompositeVC</param>
-<param name="Author">...</param>
-<param name="Organisation">VPAC</param>
-<param name="Project">StGermain</param>
-<param name="Location">./StGermain/Base/Automation/src/</param>
-<param name="Project Web">http://www.stgermainproject.org/</param>
-<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
-<param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
-<param name="Parent">VariableCondition</param>
-<param name="Reference">...</param>
-<param name="Summary">...</param>
-
-<param name="Description">
- CompositeVC is used as a container to combine multiple variable conditions.
-</param>
-
-<list name="Params">
- <struct>
- <param name="Name">vcName</param>
- <param name="Type">String</param>
- <param name="Default">self->name</param>
- <param name="Description">
- Deprecated; should not be used.
- </param>
- </struct>
- <struct>
- <param name="Name">vcList</param>
- <param name="Type">List</param>
- <param name="Default"></param>
- <param name="Description">
- A list of other VariableCondition definitions.
- </param>
- </struct>
-</list>
-
-<list name="Dependencies">
- <struct>
- <param name="Essential">No</param>
- <param name="Name">Data</param>
- <param name="Type">Stg_Component</param>
- <param name="Description">
- User defined data in the form of a Stg_Component.
- </param>
- </struct>
-</list>
-
-<param name="Example">
- Refer to ./StgFEM/Apps/StokesMomentumUzawa/lidDrivenBCs.xml
-</param>
-
-</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/ConditionFunction.c
--- a/Base/Automation/src/ConditionFunction.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,171 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: ConditionFunction.c 3462 2006-02-19 06:53:24Z WalterLandry $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "ConditionFunction.h"
-
-#include <stdio.h>
-#include <assert.h>
-
-
-const Type ConditionFunction_Type = "ConditionFunction";
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Constructor
-*/
-
-ConditionFunction* ConditionFunction_New(ConditionFunction_ApplyFunc* apply, Name name)
-{
- return _ConditionFunction_New(sizeof(ConditionFunction), ConditionFunction_Type, _ConditionFunction_Delete,
- _ConditionFunction_Print, NULL, apply, name);
-}
-
-
-void ConditionFunction_Init(ConditionFunction* self, ConditionFunction_ApplyFunc* apply, Name name)
-{
- /* General info */
- self->type = ConditionFunction_Type;
- self->_sizeOfSelf = sizeof(ConditionFunction);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _ConditionFunction_Delete;
- self->_print = _ConditionFunction_Print;
- self->_copy = NULL;
-
- _Stg_Class_Init((Stg_Class*)self);
-
- /* Stg_Class info */
- _ConditionFunction_Init(self, apply, name);
-}
-
-
-ConditionFunction* _ConditionFunction_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ConditionFunction_ApplyFunc* apply,
- Name name)
-{
- ConditionFunction* self;
-
- /* Allocate memory */
- assert( _sizeOfSelf >= sizeof(ConditionFunction) );
- self = (ConditionFunction*)_Stg_Class_New(_sizeOfSelf, type, _delete, _print, _copy);
-
- /* General info */
-
- /* Virtual functions */
-
- /* Stg_Class info */
- _ConditionFunction_Init(self, apply, name);
-
- return self;
-}
-
-
-void _ConditionFunction_Init(void* conditionFunction, ConditionFunction_ApplyFunc* apply, Name name)
-{
- ConditionFunction* self = (ConditionFunction*)conditionFunction;
-
- self->apply = apply;
- self->name = name;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** General virtual functions
-*/
-
-void _ConditionFunction_Delete(void* conditionFunction)
-{
- ConditionFunction* self = (ConditionFunction*)conditionFunction;
-
- /* Stg_Class_Delete parent class */
- _Stg_Class_Delete(self);
-}
-
-
-void _ConditionFunction_Print(void* conditionFunction, Stream* stream)
-{
- ConditionFunction* self = (ConditionFunction*)conditionFunction;
-
- /* Set the Journal for printing informations */
- Stream* conditionFunctionStream = stream;
-
- /* General info */
- Journal_Printf( conditionFunctionStream, "ConditionFunction (ptr): %p\n", self);
-
- /* Virtual info */
-
- /* Stg_Class info */
- Journal_Printf( conditionFunctionStream, "\tapply (func ptr): %p\n", self->apply);
- Journal_Printf( conditionFunctionStream, "\tname (ptr): %p\n", self->name);
- if (self->name)
- Journal_Printf( conditionFunctionStream, "\t\tname: %s\n", self->name);
-
- /* Print parent class */
- _Stg_Class_Print( self, conditionFunctionStream );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Macros
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Build functions
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Functions
-*/
-
-void _ConditionFunction_Apply(void* conditionFunction, Index index, Variable_Index var_I, void* context, void* result)
-{
- ConditionFunction* self = (ConditionFunction*)conditionFunction;
-
- ConditionFunction_Apply(self, index, var_I, context, result);
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/ConditionFunction.h
--- a/Base/Automation/src/ConditionFunction.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-** Abstract class faciliting the Boundary Condition definition of this system.
-** Meshs should only reference this... the base class, not the implementations.
-**
-** Assumptions:
-**
-** Comments:
-**
-** $Id: ConditionFunction.h 3462 2006-02-19 06:53:24Z WalterLandry $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Base_Automation_ConditionFunction_h__
-#define __Base_Automation_ConditionFunction_h__
-
-
- typedef void (ConditionFunction_ApplyFunc) (Index index, Variable_Index var_I, void* context, void* result);
-
-
- extern const Type ConditionFunction_Type;
-
-
- #define __ConditionFunction \
- /* General info */ \
- __Stg_Class \
- \
- /* Virtual info */ \
- \
- /* Stg_Class info */ \
- Dictionary* dictionary; \
- ConditionFunction_ApplyFunc* apply; \
- Name name; \
-
- struct _ConditionFunction { __ConditionFunction };
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructor
- */
-
- ConditionFunction* ConditionFunction_New(ConditionFunction_ApplyFunc* apply, Name name);
-
- void ConditionFunction_Init(ConditionFunction* self, ConditionFunction_ApplyFunc* apply, Name name);
-
- ConditionFunction* _ConditionFunction_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ConditionFunction_ApplyFunc* apply,
- Name name);
-
- void _ConditionFunction_Init(void* conditionFunction, ConditionFunction_ApplyFunc* apply, Name name);
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** General virtual functions
- */
-
- void _ConditionFunction_Delete(void* conditionFunction);
-
- void _ConditionFunction_Print(void* conditionFunction, Stream* stream);
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Macros
- */
-
- #define ConditionFunction_Apply(self, index, var_I, context, result) \
- (self)->apply((index), (var_I), (context), (result))
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Build functions
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Functions
- */
-
- /* Apply the condition function */
- void _ConditionFunction_Apply(void* conditionFunction, Index index, Variable_Index var_I, void* context, void* result);
-
-
-#endif /* __Base_Automation_ConditionFunction_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/ConditionFunction_Register.c
--- a/Base/Automation/src/ConditionFunction_Register.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: ConditionFunction_Register.c 3462 2006-02-19 06:53:24Z WalterLandry $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "ConditionFunction.h"
-#include "ConditionFunction_Register.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-
-const Type ConditionFunction_Register_Type = "ConditionFunction_Register";
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Constructor
-*/
-
-ConditionFunction_Register* ConditionFunction_Register_New(void)
-{
- return _ConditionFunction_Register_New( sizeof(ConditionFunction_Register), ConditionFunction_Register_Type,
- _ConditionFunction_Register_Delete, _ConditionFunction_Register_Print, NULL);
-}
-
-
-void ConditionFunction_Register_Init(ConditionFunction_Register* self)
-{
- /* General info */
- self->type = ConditionFunction_Register_Type;
- self->_sizeOfSelf = sizeof(ConditionFunction_Register);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _ConditionFunction_Register_Delete;
- self->_print = _ConditionFunction_Register_Print;
- self->_copy = NULL;
-
- _Stg_Class_Init((Stg_Class*)self);
-
- /* Stg_Class info */
- _ConditionFunction_Register_Init(self);
-}
-
-
-ConditionFunction_Register* _ConditionFunction_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
-{
- ConditionFunction_Register* self;
-
- /* Allocate memory */
- self = (ConditionFunction_Register*)_Stg_Class_New(_sizeOfSelf, type, _delete, _print, _copy);
-
- /* Virtual info */
-
- /* ConditionFunction_Register info */
- _ConditionFunction_Register_Init(self);
-
- return self;
-}
-
-
-void _ConditionFunction_Register_Init(void* conditionFunction_Register)
-{
- ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
-
- self->count = 0;
- self->_size = 8;
- self->_delta = 8;
- self->_cf = Memory_Alloc_Array( ConditionFunction*, self->_size, "ConditionFunction_Register->_cf" );
- memset(self->_cf, 0, sizeof(ConditionFunction*)*self->_size);
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** General virtual functions
-*/
-
-void _ConditionFunction_Register_Delete(void* conditionFunction_Register)
-{
- ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
-
- if (self->_cf) Memory_Free(self->_cf);
-
- /* Stg_Class_Delete parent class */
- _Stg_Class_Delete(self);
-}
-
-
-void _ConditionFunction_Register_Print(void* conditionFunction_Register, Stream* stream)
-{
- ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
-
- /* Set the Journal for printing informations */
- Stream* conditionFunction_RegisterStream = stream;
-
- /* General info */
- Journal_Printf( conditionFunction_RegisterStream, "ConditionFunction_Register (ptr): %p\n", self);
-
- /* Virtual info */
-
- /* ConditionFunction_Register info */
- Journal_Printf( conditionFunction_RegisterStream, "\tcount: %u\n", self->count);
- Journal_Printf( conditionFunction_RegisterStream, "\t_size: %lu\n", self->_size);
- Journal_Printf( conditionFunction_RegisterStream, "\t_delta: %lu\n", self->_delta);
- Journal_Printf( conditionFunction_RegisterStream, "\t_cf (ptr): %p\n", self->_cf);
- if (self->_cf)
- {
- ConditionFunction_Index cf_I;
-
- for (cf_I = 0; cf_I < self->count; cf_I++)
- Journal_Printf( conditionFunction_RegisterStream, "\t\t_cf[%u]: %p\n", cf_I, self->_cf[cf_I]);
- }
-
- /* Parent class info */
- _Stg_Class_Print( self, conditionFunction_RegisterStream );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Macros
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Build functions
-*/
-
-ConditionFunction_Index ConditionFunction_Register_Add(void* conditionFunction_Register, ConditionFunction* cf)
-{
- ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
- Variable_Index handle;
-
- if (self->count >= self->_size)
- {
- SizeT currentSize = self->_size;
-
- /* Note: why is realloc not used here? */
- self->_size += self->_delta;
-
- self->_cf = Memory_Realloc_Array( self->_cf, ConditionFunction*, self->_size );
- memset( (Pointer)((ArithPointer)self->_cf + (sizeof(ConditionFunction*) * currentSize) ),
- 0, sizeof(ConditionFunction*) * (self->_size - currentSize) );
- }
-
- handle = self->count++;
- self->_cf[handle] = cf;
-
- return handle;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Functions
-*/
-
-ConditionFunction_Index ConditionFunction_Register_GetIndex(void* conditionFunction_Register, Name name)
-{
- ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
- ConditionFunction_Index cf_I;
-
- for (cf_I = 0; cf_I < self->count; cf_I++)
- {
- if (self->_cf[cf_I]->name && !strcmp(name, self->_cf[cf_I]->name))
- return cf_I;
- }
-
- return (ConditionFunction_Index)-1;
-}
-
-
-void ConditionFunction_Register_PrintNameOfEachFunc( void* conditionFunction_Register, Stream* stream ) {
- ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
- ConditionFunction_Index cf_I;
-
- for (cf_I = 0; cf_I < self->count; cf_I++)
- {
- Journal_Printf( stream, "\"%s\", ", self->_cf[cf_I]->name );
- }
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/ConditionFunction_Register.h
--- a/Base/Automation/src/ConditionFunction_Register.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-** Instantiates the ConditionFunction_Register such that there is only one set of DOF descriptions (for example, all the nodes have the same
-** DOF configuration).
-**
-** Assumptions:
-** All "adding" is done before the ConditionFunction_Register_Build(...), which will be done in the mesh's initialisation.
-**
-** Comments:
-** You "add" DOF descriptors by using the ConditionFunction_Register_Add( variable_Register, name, offset ), where the "name" is the
-** textual name for the DOF that will be used in the I/O of the DOF (e.g. for initial and boundary conditions), and "offset" is
-** the memory offset of the DOF in the construct that it will be used (e.g. node.vel[0]-node ).
-**
-** $Id: ConditionFunction_Register.h 3462 2006-02-19 06:53:24Z WalterLandry $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Base_Automation_ConditionFunction_Register_h__
-#define __Base_Automation_ConditionFunction_Register_h__
-
-
- extern const Type ConditionFunction_Register_Type;
-
-
- #define __ConditionFunction_Register \
- /* General info */ \
- __Stg_Class \
- \
- /* Virtual info */ \
- \
- /* Stg_Class info */ \
- ConditionFunction_Index count; \
- SizeT _size; \
- SizeT _delta; \
- ConditionFunction** _cf; \
-
- struct _ConditionFunction_Register { __ConditionFunction_Register };
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructor
- */
-
- ConditionFunction_Register* ConditionFunction_Register_New(void);
-
- void ConditionFunction_Register_Init(ConditionFunction_Register* self);
-
- ConditionFunction_Register* _ConditionFunction_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy );
-
- void _ConditionFunction_Register_Init(void* conditionFunction_Register);
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** General virtual functions
- */
-
- void _ConditionFunction_Register_Delete( void* conditionFunction_Register );
-
- void _ConditionFunction_Register_Print( void* conditionFunction_Register, Stream* stream );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Macros
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Build functions
- */
-
- ConditionFunction_Index ConditionFunction_Register_Add(void* conditionFunction_Register, ConditionFunction* cf);
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Functions
- */
-
- ConditionFunction_Index ConditionFunction_Register_GetIndex(void* conditionFunction_Register, Name name);
-
- void ConditionFunction_Register_PrintNameOfEachFunc( void* conditionFunction_Register, Stream* stream );
-
-
-#endif /* __Base_Automation_ConditionFunction_Register_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/DocumentationComponentFactory.c
--- a/Base/Automation/src/DocumentationComponentFactory.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/DocumentationComponentFactory.c Tue Jan 12 14:38:16 2010 +1100
@@ -62,83 +62,54 @@ const Type DocumentationComponentFactory
** Constructor
*/
-DocumentationComponentFactory* DocumentationComponentFactory_New( Stg_ObjectList* registerRegister ) {
+DocumentationComponentFactory* DocumentationComponentFactory_New( ) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( DocumentationComponentFactory );
+ Type type = DocumentationComponentFactory_Type;
+ Stg_Class_DeleteFunction* _delete = _DocumentationComponentFactory_Delete;
+ Stg_Class_PrintFunction* _print = _DocumentationComponentFactory_Print;
+ Stg_ComponentFactory_GetDoubleFunc* getDouble = _DocumentationComponentFactory_GetDouble;
+ Stg_ComponentFactory_GetIntFunc* getInt = _DocumentationComponentFactory_GetInt;
+ Stg_ComponentFactory_GetUnsignedIntFunc* getUnsignedInt = _DocumentationComponentFactory_GetUnsignedInt;
+ Stg_ComponentFactory_GetBoolFunc* getBool = _DocumentationComponentFactory_GetBool;
+ Stg_ComponentFactory_GetStringFunc* getString = _DocumentationComponentFactory_GetString;
+ Stg_ComponentFactory_GetRootDictDoubleFunc* getRootDictDouble = _DocumentationComponentFactory_GetRootDictDouble;
+ Stg_ComponentFactory_GetRootDictIntFunc* getRootDictInt = _DocumentationComponentFactory_GetRootDictInt;
+ Stg_ComponentFactory_GetRootDictUnsignedIntFunc* getRootDictUnsignedInt = _DocumentationComponentFactory_GetRootDictUnsignedInt;
+ Stg_ComponentFactory_GetRootDictBoolFunc* getRootDictBool = _DocumentationComponentFactory_GetRootDictBool;
+ Stg_ComponentFactory_GetRootDictStringFunc* getRootDictString = _DocumentationComponentFactory_GetRootDictString;
+ Stg_ComponentFactory_ConstructByNameFunc* constructByName = _DocumentationComponentFactory_ConstructByName;
+ Stg_ComponentFactory_ConstructByKeyFunc* constructByKey = _DocumentationComponentFactory_ConstructByKey;
+ Stg_ComponentFactory_ConstructByNameWithKeyFallbackFunc* constructByNameWithKeyFallback = _DocumentationComponentFactory_ConstructByNameWithKeyFallback;
+ Stg_ComponentFactory_ConstructByListFunc* constructByList = _DocumentationComponentFactory_ConstructByList;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ Dictionary* rootDict = ZERO;
+ Dictionary* componentDict = ZERO;
+
DocumentationComponentFactory *self = NULL;
- self = _DocumentationComponentFactory_New(
- sizeof( DocumentationComponentFactory ),
- DocumentationComponentFactory_Type,
- _DocumentationComponentFactory_Delete,
- _DocumentationComponentFactory_Print,
- NULL,
- _DocumentationComponentFactory_GetDouble,
- _DocumentationComponentFactory_GetInt,
- _DocumentationComponentFactory_GetUnsignedInt,
- _DocumentationComponentFactory_GetBool,
- _DocumentationComponentFactory_GetString,
- _DocumentationComponentFactory_GetRootDictDouble,
- _DocumentationComponentFactory_GetRootDictInt,
- _DocumentationComponentFactory_GetRootDictUnsignedInt,
- _DocumentationComponentFactory_GetRootDictBool,
- _DocumentationComponentFactory_GetRootDictString,
- _DocumentationComponentFactory_ConstructByName,
- _DocumentationComponentFactory_ConstructByKey,
- _DocumentationComponentFactory_ConstructByNameWithKeyFallback,
- _DocumentationComponentFactory_ConstructByList,
- registerRegister );
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ self = _DocumentationComponentFactory_New( DOCUMENTATIONCOMPONENTFACTORY_PASSARGS );
return self;
}
/* Creation implementation */
-DocumentationComponentFactory* _DocumentationComponentFactory_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_ComponentFactory_GetDoubleFunc* getDouble,
- Stg_ComponentFactory_GetIntFunc* getInt,
- Stg_ComponentFactory_GetUnsignedIntFunc* getUnsignedInt,
- Stg_ComponentFactory_GetBoolFunc* getBool,
- Stg_ComponentFactory_GetStringFunc* getString,
- Stg_ComponentFactory_GetRootDictDoubleFunc* getRootDictDouble,
- Stg_ComponentFactory_GetRootDictIntFunc* getRootDictInt,
- Stg_ComponentFactory_GetRootDictUnsignedIntFunc* getRootDictUnsignedInt,
- Stg_ComponentFactory_GetRootDictBoolFunc* getRootDictBool,
- Stg_ComponentFactory_GetRootDictStringFunc* getRootDictString,
- Stg_ComponentFactory_ConstructByNameFunc* constructByName,
- Stg_ComponentFactory_ConstructByKeyFunc* constructByKey,
- Stg_ComponentFactory_ConstructByNameWithKeyFallbackFunc* constructByNameWithKeyFallback,
- Stg_ComponentFactory_ConstructByListFunc* constructByList,
- Stg_ObjectList* registerRegister )
+DocumentationComponentFactory* _DocumentationComponentFactory_New( DOCUMENTATIONCOMPONENTFACTORY_DEFARGS )
{
DocumentationComponentFactory *self = NULL;
assert( _sizeOfSelf >= sizeof( DocumentationComponentFactory ) );
- self = (DocumentationComponentFactory*) _Stg_ComponentFactory_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- getDouble,
- getInt,
- getUnsignedInt,
- getBool,
- getString,
- getRootDictDouble,
- getRootDictInt,
- getRootDictUnsignedInt,
- getRootDictBool,
- getRootDictString,
- constructByName,
- constructByKey,
- constructByNameWithKeyFallback,
- constructByList,
- NULL,
- NULL,
- registerRegister );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ rootDict = NULL;
+ componentDict = NULL;
+
+ self = (DocumentationComponentFactory*) _Stg_ComponentFactory_New( STG_COMPONENTFACTORY_PASSARGS );
return self;
}
@@ -327,8 +298,10 @@ void DocumentationComponentFactory_Docum
Journal_Printf( stream, "Parent - %s\n", GetParent( type ) );
- Stg_Component_Construct( component, (Stg_ComponentFactory*)self, 0 /* dummy */, True );
+ Stg_Component_AssignFromXML( component, (Stg_ComponentFactory*)self, 0 /* dummy */, True );
Stg_Class_Delete( component );
Stream_UnIndent( self->infoStream );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/DocumentationComponentFactory.h
--- a/Base/Automation/src/DocumentationComponentFactory.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/DocumentationComponentFactory.h Tue Jan 12 14:38:16 2010 +1100
@@ -33,8 +33,8 @@
** $Id: DocumentationComponentFactory.h 3851 2006-10-12 08:57:22Z SteveQuenette $
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_DocumentationComponentFactory_h__
-#define __Base_Automation_DocumentationComponentFactory_h__
+#ifndef __StGermain_Base_Automation_DocumentationComponentFactory_h__
+#define __StGermain_Base_Automation_DocumentationComponentFactory_h__
extern const Type DocumentationComponentFactory_Type;
@@ -52,29 +52,20 @@
** Constructor
*/
/* Creation implementation */
- DocumentationComponentFactory* DocumentationComponentFactory_New( Stg_ObjectList* registerRegister );
+ DocumentationComponentFactory* DocumentationComponentFactory_New( );
- DocumentationComponentFactory* _DocumentationComponentFactory_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_ComponentFactory_GetDoubleFunc* getDouble,
- Stg_ComponentFactory_GetIntFunc* getInt,
- Stg_ComponentFactory_GetUnsignedIntFunc* getUnsignedInt,
- Stg_ComponentFactory_GetBoolFunc* getBool,
- Stg_ComponentFactory_GetStringFunc* getString,
- Stg_ComponentFactory_GetRootDictDoubleFunc* getRootDictDouble,
- Stg_ComponentFactory_GetRootDictIntFunc* getRootDictInt,
- Stg_ComponentFactory_GetRootDictUnsignedIntFunc* getRootDictUnsignedInt,
- Stg_ComponentFactory_GetRootDictBoolFunc* getRootDictBool,
- Stg_ComponentFactory_GetRootDictStringFunc* getRootDictString,
- Stg_ComponentFactory_ConstructByNameFunc* constructByName,
- Stg_ComponentFactory_ConstructByKeyFunc* constructByKey,
- Stg_ComponentFactory_ConstructByNameWithKeyFallbackFunc* constructByNameWithKeyFallback,
- Stg_ComponentFactory_ConstructByListFunc* constructByList,
- Stg_ObjectList* registerRegister );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define DOCUMENTATIONCOMPONENTFACTORY_DEFARGS \
+ STG_COMPONENTFACTORY_DEFARGS
+
+ #define DOCUMENTATIONCOMPONENTFACTORY_PASSARGS \
+ STG_COMPONENTFACTORY_PASSARGS
+
+ DocumentationComponentFactory* _DocumentationComponentFactory_New( DOCUMENTATIONCOMPONENTFACTORY_DEFARGS );
/*-----------------------------------------------------------------------------------------------------------------
** Virtual functions
@@ -140,4 +131,5 @@
void DocumentationComponentFactory_DocumentType( void* cf, Type type ) ;
-#endif /* __Base_Automation_DocumentationComponentFactory_h__ */
+#endif /* __StGermain_Base_Automation_DocumentationComponentFactory_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/DynamicVC.c
--- a/Base/Automation/src/DynamicVC.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,442 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: DynamicVC.c 3881 2006-10-26 03:14:19Z KathleenHumble $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "shortcuts.h"
-#include "Stg_Component.h"
-#include "Stg_ComponentFactory.h"
-#include "Variable.h"
-#include "Variable_Register.h"
-#include "ConditionFunction.h"
-#include "ConditionFunction_Register.h"
-#include "VariableCondition.h"
-#include "DynamicVC.h"
-
-#include <string.h>
-#include <assert.h>
-
-
-const Type DynamicVC_Type = "DynamicVC";
-const Name defaultDynamicVCName = "defaultDynamicVCName";
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Constructor
-*/
-
-VariableCondition* DynamicVC_Factory( Variable_Register* varReg,
- ConditionFunction_Register* conFuncReg,
- Dictionary* dict,
- void* data )
-{
- return (VariableCondition*)DynamicVC_New( defaultDynamicVCName, varReg, conFuncReg, dict );
-}
-
-DynamicVC* DynamicVC_New( Name name,
- Variable_Register* varReg,
- ConditionFunction_Register* conFuncReg,
- Dictionary* dict )
-{
- return _DynamicVC_New( sizeof(DynamicVC),
- DynamicVC_Type,
- _DynamicVC_Delete,
- _DynamicVC_Print,
- _DynamicVC_Copy,
- (Stg_Component_DefaultConstructorFunction*)DynamicVC_DefaultNew,
- _DynamicVC_Construct,
- _DynamicVC_Build,
- _DynamicVC_Initialise,
- _DynamicVC_Execute,
- _DynamicVC_Destroy,
- name,
- True,
- NULL,
- _DynamicVC_PrintConcise,
- _DynamicVC_ReadDictionary,
- _DynamicVC_GetSet,
- _DynamicVC_GetVariableCount,
- _DynamicVC_GetVariableIndex,
- _DynamicVC_GetValueIndex,
- _DynamicVC_GetValueCount,
- _DynamicVC_GetValue,
- DynamicVC_Apply,
- varReg,
- conFuncReg,
- dict );
-}
-
-DynamicVC* DynamicVC_DefaultNew( Name name ) {
- return (DynamicVC*)_DynamicVC_New( sizeof(DynamicVC),
- DynamicVC_Type,
- _DynamicVC_Delete,
- _DynamicVC_Print,
- _DynamicVC_Copy,
- (Stg_Component_DefaultConstructorFunction*)DynamicVC_DefaultNew,
- _VariableCondition_Construct,
- _VariableCondition_Build,
- _VariableCondition_Initialise,
- _VariableCondition_Execute,
- _VariableCondition_Destroy,
- name,
- False,
- NULL,
- _DynamicVC_PrintConcise,
- _DynamicVC_ReadDictionary,
- _DynamicVC_GetSet,
- _DynamicVC_GetVariableCount,
- _DynamicVC_GetVariableIndex,
- _DynamicVC_GetValueIndex,
- _DynamicVC_GetValueCount,
- _DynamicVC_GetValue,
- DynamicVC_Apply,
- NULL,
- NULL,
- NULL );
-}
-
-void DynamicVC_Init( DynamicVC* self,
- Name name,
- Variable_Register* varReg,
- ConditionFunction_Register* conFuncReg,
- Dictionary* dict )
-{
- /* General info */
- self->type = DynamicVC_Type;
- self->_sizeOfSelf = sizeof(DynamicVC);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _DynamicVC_Delete;
- self->_print = _DynamicVC_Print;
- self->_copy = _DynamicVC_Copy;
- self->_build = _VariableCondition_Build;
- self->_initialise = _VariableCondition_Initialise;
- self->_execute = _VariableCondition_Execute;
- self->_buildSelf = NULL;
- self->_printConcise = _DynamicVC_PrintConcise;
- self->_readDictionary = _DynamicVC_ReadDictionary;
- self->_getSet = _DynamicVC_GetSet;
- self->_getVariableCount = _DynamicVC_GetVariableCount;
- self->_getVariableIndex = _DynamicVC_GetVariableIndex;
- self->_getValueIndex = _DynamicVC_GetValueIndex;
- self->_getValueCount = _DynamicVC_GetValueCount;
- self->_getValue = _DynamicVC_GetValue;
- self->_apply = DynamicVC_Apply;
-
- _Stg_Class_Init( (Stg_Class*)self );
- _Stg_Object_Init( (Stg_Object*)self, name, NON_GLOBAL );
- _Stg_Component_Init( (Stg_Component*)self );
- _VariableCondition_Init( (VariableCondition*)self, varReg, conFuncReg, dict );
-
- /* Stg_Class info */
- _DynamicVC_Init( self );
-}
-
-DynamicVC* _DynamicVC_New( SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc* _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Variable_Register* varReg,
- ConditionFunction_Register* conFuncReg,
- Dictionary* dict )
-{
- DynamicVC* self;
-
- /* Allocate memory/General info */
- assert(_sizeOfSelf >= sizeof(DynamicVC));
- self = (DynamicVC*)_VariableCondition_New( _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _defaultConstructor,
- _construct,
- _build,
- _initialise,
- _execute,
- _destroy,
- name,
- initFlag,
- _buildSelf,
- _printConcise,
- _readDictionary,
- _getSet,
- _getVariableCount,
- _getVariableIndex,
- _getValueIndex,
- _getValueCount,
- _getValue,
- _apply,
- varReg,
- conFuncReg,
- dict );
-
- /* Virtual info */
-
- /* Stg_Class info */
- if( initFlag )
- _DynamicVC_Init( self );
-
- return self;
-}
-
-void _DynamicVC_Init( void* vc ) {
- DynamicVC* self = (DynamicVC*)vc;
-
- assert( self );
- self->vcMap = IMap_New();
-}
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** General virtual functions
-*/
-
-void _DynamicVC_Construct( void* vc, Stg_ComponentFactory* cf, void* data ) {
-}
-
-void _DynamicVC_Build( void* vc, void* data ) {
-}
-
-void _DynamicVC_Initialise( void* vc, void* data ) {
-}
-
-void _DynamicVC_Execute( void* vc, void* data ) {
-}
-
-void _DynamicVC_Destroy( void* vc, void* data ) {
-}
-
-void _DynamicVC_ReadDictionary( void* vc, void* dict ) {
-}
-
-void _DynamicVC_Delete( void* vc ) {
- DynamicVC* self = (DynamicVC*)vc;
-
- NewClass_Delete( self->vcMap );
-
- /* Stg_Class_Delete parent */
- _VariableCondition_Delete(self);
-}
-
-void _DynamicVC_Print( void* vc, Stream* stream ) {
- _VariableCondition_Print( vc );
-}
-
-void* _DynamicVC_Copy( void* vc, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
- return NULL;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Macros
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-IndexSet* _DynamicVC_GetSet( void* vc ) {
- return NULL;
-}
-
-VariableCondition_VariableIndex _DynamicVC_GetVariableCount( void* vc, Index globalIndex ) {
- return 0;
-}
-
-Variable_Index _DynamicVC_GetVariableIndex( void* vc, Index globalIndex, VariableCondition_VariableIndex varIndex ) {
- return 0;
-}
-
-VariableCondition_ValueIndex _DynamicVC_GetValueIndex( void* vc,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex )
-{
- return 0;
-}
-
-VariableCondition_ValueIndex _DynamicVC_GetValueCount( void* vc ) {
- return 0;
-}
-
-VariableCondition_Value _DynamicVC_GetValue( void* vc, VariableCondition_ValueIndex valIndex ) {
- VariableCondition_Value val;
-
- val.type = VC_ValueType_Double;
- val.as.typeDouble = 0.0;
- return val;
-}
-
-void _DynamicVC_PrintConcise( void* vc, Stream* stream ) {
-}
-
-void DynamicVC_Apply( void* vc, void* ctx ) {
- DynamicVC* self = (DynamicVC*)vc;
- IMapIter* iter;
- int ind, valInd, varInd;
- VariableCondition_Value* val;
- ConditionFunction* cf;
- Stream *errorStrm = Journal_Register( Error_Type, self->type );
-
- varInd = Variable_Register_GetIndex( self->variable_Register, self->var->name );
- iter = IMapIter_New();
- for( IMap_First( self->vcMap, iter );
- Iter_IsValid( iter );
- IMapIter_Next( iter ) )
- {
- ind = IMapIter_GetKey( iter );
- valInd = IMapIter_GetValue( iter );
- val = self->valueTbl + valInd;
- switch( val->type ) {
- case VC_ValueType_Double:
- Journal_Firewall( self->var->dataTypeCounts[0] == 1, errorStrm,
- "Error - in %s: while applying values for variable condition "
- "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
- "which has %d components. Specify a scalar Variable instead.\n",
- __func__, self->name, ind, "double",
- self->var->name, self->var->dataTypeCounts[0] );
- Variable_SetValueDouble( self->var,
- ind,
- val->as.typeDouble );
- break;
-
- case VC_ValueType_DoubleArray:
- Variable_SetValue( self->var,
- ind,
- val->as.typeArray.array );
- break;
-
- case VC_ValueType_CFIndex:
- Journal_Firewall( val->as.typeCFIndex != (unsigned)-1, errorStrm,
- "Error - in %s: trying to apply to index %d of variable \"%s\", which "
- "is supposed to be a condition function, but the cond. func. wasn't "
- "found in the c.f. register.\n", __func__, ind, self->var->name );
- cf = self->conFunc_Register->_cf[val->as.typeCFIndex];
- ConditionFunction_Apply( cf,
- ind,
- varInd,
- ctx,
- Variable_GetStructPtr( self->var, ind ) );
- break;
-
- default:
- assert( 0 );
- break;
- }
- }
- NewClass_Delete( iter );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Build functions
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Functions
-*/
-
-void DynamicVC_SetVariable( void* vc, Variable* var ) {
- DynamicVC* self = (DynamicVC*)vc;
-
- assert( self );
- self->var = var;
-}
-
-void DynamicVC_SetMaxEntries( void* vc, int maxEntries ) {
- DynamicVC* self = (DynamicVC*)vc;
-
- assert( self );
- /*IMap_Clear( self->vcMap );*/
- IMap_SetMaxSize( self->vcMap, maxEntries );
-}
-
-int DynamicVC_GetMaxEntries( void* vc ) {
- DynamicVC* self = (DynamicVC*)vc;
-
- return IMap_GetMaxSize( self->vcMap );
-}
-
-void DynamicVC_SetValues( void* vc, int nVals, VariableCondition_Value* vals ) {
- DynamicVC* self = (DynamicVC*)vc;
-
- assert( self );
- self->valueCount = nVals;
- self->valueTbl = MemRearray( self->valueTbl, VariableCondition_Value, nVals, DynamicVC_Type );
- memcpy( self->valueTbl, vals, nVals * sizeof(VariableCondition_Value) );
-}
-
-void DynamicVC_Insert( void* vc, int index, int valIndex ) {
- DynamicVC* self = (DynamicVC*)vc;
-
- assert( self );
- if( !IMap_Has( self->vcMap, index ) )
- IMap_Insert( self->vcMap, index, valIndex );
-}
-
-void DynamicVC_Remove( void* vc, int index ) {
- DynamicVC* self = (DynamicVC*)vc;
-
- assert( self );
- if( IMap_Has( self->vcMap, index ) )
- IMap_Remove( self->vcMap, index );
-}
-
-Bool DynamicVC_Has( void* _self, int index ) {
- DynamicVC* self = (DynamicVC*)_self;
-
- assert( self );
- return IMap_Has( self->vcMap, index );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/DynamicVC.h
--- a/Base/Automation/src/DynamicVC.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** Role:
-**
-** Assumptions:
-**
-** Comments:
-**
-** $Id: DynamicVC.h 3462 2006-02-19 06:53:24Z WalterLandry $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Base_Automation_DynamicVC_h__
-#define __Base_Automation_DynamicVC_h__
-
-extern const Type DynamicVC_Type;
-
-#define __DynamicVC \
- /* General info */ \
- __VariableCondition \
- \
- /* Virtual info */ \
- \
- /* Stg_Class info */ \
- Variable* var; \
- IMap* vcMap;
-
- struct DynamicVC { __DynamicVC };
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Constructor
-*/
-
-VariableCondition* DynamicVC_Factory( Variable_Register* varReg,
- ConditionFunction_Register* conFuncReg,
- Dictionary* dict,
- void* data );
-
-DynamicVC* DynamicVC_New( Name name,
- Variable_Register* varReg,
- ConditionFunction_Register* conFuncReg,
- Dictionary* dict );
-
-DynamicVC* DynamicVC_DefaultNew( Name name );
-
-void DynamicVC_Init( DynamicVC* self,
- Name name,
- Variable_Register* varReg,
- ConditionFunction_Register* conFuncReg,
- Dictionary* dict );
-
-DynamicVC* _DynamicVC_New( SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc* _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Variable_Register* varReg,
- ConditionFunction_Register* conFuncReg,
- Dictionary* dict );
-
-void _DynamicVC_Init( void* vc );
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** General virtual functions
-*/
-
-void _DynamicVC_Delete( void* vc );
-void _DynamicVC_Print( void* vc, Stream* stream );
-
-/* Copy */
-#define DynamicVC_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
-#define DynamicVC_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
-
-void* _DynamicVC_Copy( void* vc, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
-
-void _DynamicVC_Construct( void* vc, Stg_ComponentFactory* cf, void* data );
-
-void _DynamicVC_Build( void* vc, void* data );
-
-void _DynamicVC_Initialise( void* vc, void* data );
-
-void _DynamicVC_Execute( void* vc, void* data );
-
-void _DynamicVC_Destroy( void* vc, void* data );
-
-void _DynamicVC_ReadDictionary( void* vc, void* dict );
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Macros
-*/
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _DynamicVC_ReadDictionary( void* vc, void* dict );
-
-IndexSet* _DynamicVC_GetSet( void* vc );
-
-VariableCondition_VariableIndex _DynamicVC_GetVariableCount( void* vc, Index globalIndex );
-
-Variable_Index _DynamicVC_GetVariableIndex( void* vc,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex );
-
-VariableCondition_ValueIndex _DynamicVC_GetValueIndex( void* vc,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex );
-
-VariableCondition_ValueIndex _DynamicVC_GetValueCount( void* vc );
-
-VariableCondition_Value _DynamicVC_GetValue( void* vc, VariableCondition_ValueIndex valIndex );
-
-void _DynamicVC_PrintConcise( void* vc, Stream* stream );
-
-void DynamicVC_Apply( void* vc, void* ctx );
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Build functions
-*/
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Functions
-*/
-
-void DynamicVC_SetVariable( void* vc, Variable* var );
-void DynamicVC_SetMaxEntries( void* vc, int maxEntries );
-int DynamicVC_GetMaxEntries( void* vc );
-void DynamicVC_SetValues( void* vc, int nVals, VariableCondition_Value* vals );
-void DynamicVC_Insert( void* vc, int index, int valIndex );
-void DynamicVC_Remove( void* vc, int index );
-Bool DynamicVC_Has( void* _self, int index );
-
-
-#endif /* __Base_Automation_DynamicVC_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/DynamicVC.meta
--- a/Base/Automation/src/DynamicVC.meta Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
-<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
-
-<param name="Name">DynamicVC</param>
-<param name="Author">...</param>
-<param name="Organisation">VPAC</param>
-<param name="Project">StGermain</param>
-<param name="Location">./StGermain/Base/Automation/src/</param>
-<param name="Project Web">http://www.stgermainproject.org/</param>
-<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
-<param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
-<param name="Parent">VariableCondition</param>
-<param name="Reference">...</param>
-<param name="Summary">...</param>
-
-<param name="Description">
- DynamicVC provides a mechanism to set and remove variable conditions during run-time.
- It is not intended for use through XML, but instead should be instantiated and
- manipulated by other components internally.
-</param>
-
-<list name="Params">
- n/a
-</list>
-
-<list name="Dependencies">
- n/a
- </list>
-
-<param name="Example">
- n/a
-</param>
-
-</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Finalise.c
--- a/Base/Automation/src/Finalise.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Finalise.c Tue Jan 12 14:38:16 2010 +1100
@@ -37,7 +37,6 @@
#include "shortcuts.h"
#include "Finalise.h"
-#include "VariableCondition_Register.h"
#include "Stg_Component.h"
#include "Stg_ComponentRegister.h"
#include "HierarchyTable.h"
@@ -48,9 +47,11 @@ Bool BaseAutomation_Finalise( void ) {
Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
/* Clean up global variable */
- Stg_Class_Delete( variableCondition_Register );
Stg_Class_Delete( stgComponentRegister );
Stg_Class_Delete( stgHierarchyTable );
Stg_Class_Delete( stgCallGraph );
+
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Finalise.h
--- a/Base/Automation/src/Finalise.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Finalise.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,9 +38,9 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_BaseAutomation_Finalise_h__
-#define __Base_BaseAutomation_Finalise_h__
+#ifndef __StGermain_Base_Automation_Finalise_h__
+#define __StGermain_Base_Automation_Finalise_h__
- Bool BaseAutomation_Finalise( void );
+ Bool Automation_Finalise( void );
-#endif /* __Base_BaseAutomation_Finalise_h__ */
+#endif /* __StGermain_Base_Automation_Finalise_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/HierarchyTable.c
--- a/Base/Automation/src/HierarchyTable.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/HierarchyTable.c Tue Jan 12 14:38:16 2010 +1100
@@ -112,7 +112,8 @@ void HierarchyTable_PrintChildren( void*
Stream_Flush( stream );
Stream_Indent( stream );
- for ( entry_I = 0 ; entry_I < self->max ; entry_I++ ) {
+ /* increasing terminating limit by 1 - seems to be right due to comments in HashTable.c ~line 154 */
+ for ( entry_I = 0 ; entry_I < self->max+1 ; entry_I++ ) {
hashTableEntry = self->entries[ entry_I ];
while( hashTableEntry ){
@@ -126,6 +127,17 @@ void HierarchyTable_PrintChildren( void*
Stream_UnIndent( stream );
}
+Bool Stg_Class_CompareType( const void* classPtr, Type possibleParentType ) {
+ Stg_Class* self = (Stg_Class*) classPtr;
+ /* Check if the pointer is null */
+ Journal_Firewall(
+ self != NULL,
+ Journal_Register( Error_Type, HierarchyTable_Type ),
+ "Error doing type checking against possibleParentType %s - pointer is NULL.\n",
+ possibleParentType );
+
+ return( Stg_Class_IsInstance( self, possibleParentType ) );
+}
Stg_Class* Stg_Class_CheckType( const void* classPtr, Type possibleParentType ) {
Stg_Class* self = (Stg_Class*) classPtr;
@@ -179,3 +191,5 @@ Type HierarchyTable_GetTypePtrFromName(
}
return NULL;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/HierarchyTable.h
--- a/Base/Automation/src/HierarchyTable.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/HierarchyTable.h Tue Jan 12 14:38:16 2010 +1100
@@ -37,8 +37,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_HierarchyTable_h__
-#define __Base_Automation_HierarchyTable_h__
+#ifndef __StGermain_Base_Automation_HierarchyTable_h__
+#define __StGermain_Base_Automation_HierarchyTable_h__
/* Textual name of this class */
extern const Type HierarchyTable_Type;
@@ -98,6 +98,9 @@
#define Stg_CheckType( classPtr, possibleParentTypedef ) \
(possibleParentTypedef*) Stg_Class_CheckType( (classPtr), possibleParentTypedef ## _Type )
+ #define Stg_CompareType( classPtr, possibleParentTypedef ) \
+ (possibleParentTypedef*) Stg_Class_CompareType( (classPtr), possibleParentTypedef ## _Type )
+
#ifdef DEBUG
#define Stg_DCheckType Stg_CheckType
#else
@@ -106,6 +109,7 @@
#endif
Stg_Class* Stg_Class_CheckType( const void* classPtr, Type possibleParentType );
+ Bool Stg_Class_CompareType( const void* classPtr, Type possibleParentType );
void HierarchyTable_PrintParents( void* hierarchyTable, Type childType, Stream* stream ) ;
void HierarchyTable_PrintChildren( void* hierarchyTable, Type parentType, Stream* stream ) ;
@@ -117,4 +121,4 @@
Type HierarchyTable_GetTypePtrFromName( void* hierarchyTable, Name typeName ) ;
-#endif /* __Base_Automation_HierarchyTable_h__ */
+#endif /* __StGermain_Base_Automation_HierarchyTable_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Init.c
--- a/Base/Automation/src/Init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Init.c Tue Jan 12 14:38:16 2010 +1100
@@ -37,44 +37,18 @@
#include "types.h"
#include "shortcuts.h"
#include "Init.h"
-#include "VariableCondition_Register.h"
-#include "ConditionFunction_Register.h"
-#include "Variable_Register.h"
#include "Stg_Component.h"
#include "Stg_ComponentRegister.h"
#include "Stg_ComponentFactory.h"
-#include "Variable.h"
-#include "VariableCondition.h"
-#include "SetVC.h"
-#include "CompositeVC.h"
-#include "DynamicVC.h"
-#include "ConditionFunction.h"
-#include "VariableAllVC.h"
#include "HierarchyTable.h"
#include "CallGraph.h"
-
-#include "VariableDumpStream.h"
#include <stdio.h>
Bool BaseAutomation_Init( int* argc, char** argv[] )
{
- Stream* typedStream;
-
Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
-
- variableCondition_Register = VariableCondition_Register_New();
- VariableCondition_Register_Add( variableCondition_Register, SetVC_Type, SetVC_Factory );
- VariableCondition_Register_Add( variableCondition_Register, CompositeVC_Type, CompositeVC_Factory );
- VariableCondition_Register_Add( variableCondition_Register, VariableAllVC_Type, VariableAllVC_Factory );
- typedStream = VariableDumpStream_New( VariableDumpStream_Type );
- Stream_Enable( typedStream, True );
- Stream_SetLevel( typedStream, 1 );
- Stream_SetFile( typedStream, stJournal->stdOut );
-
- Journal_RegisterTypedStream( typedStream );
-
/** Initializing the Component Register singleton */
stgComponentRegister = Stg_ComponentRegister_New( );
@@ -86,30 +60,14 @@ Bool BaseAutomation_Init( int* argc, cha
/** Initializing the ComponentRegister singleton */
- /** Adding default constructors of various components to the Stg_ComponentRegister */
- Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), Variable_Type, "0", (Stg_Component_DefaultConstructorFunction*)Variable_DefaultNew );
- Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), CompositeVC_Type, "0", (Stg_Component_DefaultConstructorFunction*)CompositeVC_DefaultNew );
- Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), SetVC_Type, "0", (Stg_Component_DefaultConstructorFunction*)SetVC_DefaultNew );
- Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), VariableAllVC_Type, "0", (Stg_Component_DefaultConstructorFunction*)VariableAllVC_DefaultNew );
- Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), DynamicVC_Type, "0",
- (Stg_Component_DefaultConstructorFunction*)DynamicVC_DefaultNew );
-
/** Register Parents for All Classes */
RegisterParent( Stg_ComponentFactory_Type, Stg_Class_Type );
RegisterParent( Stg_ComponentRegister_Type, Stg_Class_Type );
RegisterParent( Stg_Component_Type, Stg_Object_Type );
- RegisterParent( VariableCondition_Type, Stg_Component_Type );
- RegisterParent( CompositeVC_Type, VariableCondition_Type );
- RegisterParent( DynamicVC_Type, VariableCondition_Type );
- RegisterParent( ConditionFunction_Type, Stg_Class_Type );
- RegisterParent( ConditionFunction_Register_Type, Stg_Class_Type );
RegisterParent( HierarchyTable_Type, HashTable_Type );
RegisterParent( Stg_CallGraph_Type, Stg_Class_Type );
- RegisterParent( Variable_Type, Stg_Component_Type );
- RegisterParent( VariableAllVC_Type, VariableCondition_Type );
- RegisterParent( VariableCondition_Register_Type, Stg_Class_Type );
- RegisterParent( VariableDumpStream_Type, CStream_Type );
- RegisterParent( Variable_Register_Type, Stg_Class_Type );
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Init.h
--- a/Base/Automation/src/Init.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Init.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,9 +39,9 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_BaseAutomation_Init_h__
-#define __Base_BaseAutomation_Init_h__
+#ifndef __StGermain_Base_Automation_Init_h__
+#define __StGermain_Base_Automation_Init_h__
- Bool BaseAutomation_Init( int* argc, char** argv[] );
+ Bool Automation_Init( int* argc, char** argv[] );
-#endif /* __Base_BaseAutomation_Init_h__ */
+#endif /* __StGermain_Base_Automation_Init_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/LiveComponentRegister.c
--- a/Base/Automation/src/LiveComponentRegister.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/LiveComponentRegister.c Tue Jan 12 14:38:16 2010 +1100
@@ -54,30 +54,30 @@ const Type LiveComponentRegister_Type =
const Type LiveComponentRegister_Type = "LiveComponentRegister";
LiveComponentRegister* stgLiveComponentRegister = NULL;
-LiveComponentRegister* _LiveComponentRegister_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
+LiveComponentRegister* _LiveComponentRegister_New( LIVECOMPONENTREGISTER_DEFARGS )
{
LiveComponentRegister *self = NULL;
assert( _sizeOfSelf >= sizeof( LiveComponentRegister ) );
- self = (LiveComponentRegister*) _Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (LiveComponentRegister*) _Stg_Class_New( STG_CLASS_PASSARGS );
return self;
}
LiveComponentRegister* LiveComponentRegister_New( )
{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( LiveComponentRegister );
+ Type type = LiveComponentRegister_Type;
+ Stg_Class_DeleteFunction* _delete = _LiveComponentRegister_Delete;
+ Stg_Class_PrintFunction* _print = _LiveComponentRegister_Print;
+
LiveComponentRegister *self = NULL;
- self = _LiveComponentRegister_New( sizeof( LiveComponentRegister ),
- LiveComponentRegister_Type,
- _LiveComponentRegister_Delete,
- _LiveComponentRegister_Print,
- NULL);
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ self = _LiveComponentRegister_New( LIVECOMPONENTREGISTER_PASSARGS );
LiveComponentRegister_Init( self );
@@ -232,3 +232,18 @@ void LiveComponentRegister_PrintSimilar(
Stg_ObjectList_PrintSimilar( self->componentList, name, stream, number );
}
+void LiveComponentRegister_DestroyAll( void* lcReg ) {
+ LiveComponentRegister* self = (LiveComponentRegister *) lcReg;
+ Stg_Component* component;
+ unsigned index;
+
+ /* Note, if a Component is already Destroyed the, isDestroyed flag should protect the
+ code from running the _Destroy function again */
+ for ( index = 0 ; index < LiveComponentRegister_GetCount( self ) ; index++ ) {
+ component = LiveComponentRegister_At( self, index );
+ Stg_Component_Destroy( component, NULL, False );
+ }
+
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/LiveComponentRegister.h
--- a/Base/Automation/src/LiveComponentRegister.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/LiveComponentRegister.h Tue Jan 12 14:38:16 2010 +1100
@@ -33,8 +33,8 @@
** $Id: LiveComponentRegister.h 2745 2005-05-10 08:12:18Z RaquibulHassan $
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_LiveComponentRegister_h__
-#define __Base_Automation_LiveComponentRegister_h__
+#ifndef __StGermain_Base_Automation_LiveComponentRegister_h__
+#define __StGermain_Base_Automation_LiveComponentRegister_h__
extern const Type LiveComponentRegister_Type;
extern LiveComponentRegister* stgLiveComponentRegister; /**< Live components singleton. */
@@ -55,13 +55,18 @@
** Constructor
*/
/* Creation implementation */
- LiveComponentRegister* _LiveComponentRegister_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy
- );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define LIVECOMPONENTREGISTER_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define LIVECOMPONENTREGISTER_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ LiveComponentRegister* _LiveComponentRegister_New( LIVECOMPONENTREGISTER_DEFARGS );
LiveComponentRegister* LiveComponentRegister_New( );
@@ -101,4 +106,5 @@
LiveComponentRegister* LiveComponentRegister_GetLiveComponentRegister();
void LiveComponentRegister_PrintSimilar( void* liveComponentRegister, Name name, Stream* stream, unsigned int number ) ;
-#endif /* __Base_Automation_LiveComponentRegister_h__ */
+#endif /* __StGermain_Base_Automation_LiveComponentRegister_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Meta.c
--- a/Base/Automation/src/Meta.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Meta.c Tue Jan 12 14:38:16 2010 +1100
@@ -230,3 +230,5 @@ void Stg_Meta_Print( Dictionary* diction
Stream_UnIndent( stream );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Meta.h
--- a/Base/Automation/src/Meta.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Meta.h Tue Jan 12 14:38:16 2010 +1100
@@ -37,8 +37,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_Stg_ComponentMeta_h__
-#define __Base_Automation_Stg_ComponentMeta_h__
+#ifndef __StGermain_Base_Automation_Stg_ComponentMeta_h__
+#define __StGermain_Base_Automation_Stg_ComponentMeta_h__
char* Stg_Meta_GetType( Dictionary* dictionary );
char* Stg_Meta_GetCreator( Dictionary* dictionary );
@@ -67,4 +67,4 @@
char* Stg_Meta_GetAssociationNillable( Dictionary* dictionary, Index i );
char* Stg_Meta_GetAssociationDocumentation( Dictionary* dictionary, Index i );
-#endif /* __Base_Automation_Stg_ComponentMeta_h__ */
+#endif /* __StGermain_Base_Automation_Stg_ComponentMeta_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/RegisterFactory.h
--- a/Base/Automation/src/RegisterFactory.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/RegisterFactory.h Tue Jan 12 14:38:16 2010 +1100
@@ -43,8 +43,8 @@
**
**/
-#ifndef __Base_IO_RegisterFactory_h__
-#define __Base_IO_RegisterFactory_h__
+#ifndef __StGermain_Base_IO_RegisterFactory_h__
+#define __StGermain_Base_IO_RegisterFactory_h__
/** Textual name for RegisterFactory class. */
extern const Type RegisterFactory_Type;
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/SetVC.c
--- a/Base/Automation/src/SetVC.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,572 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: SetVC.c 4153 2007-07-26 02:25:22Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "shortcuts.h"
-#include "Stg_Component.h"
-#include "Stg_ComponentFactory.h"
-#include "Variable.h"
-#include "Variable_Register.h"
-#include "ConditionFunction.h"
-#include "ConditionFunction_Register.h"
-#include "VariableCondition.h"
-#include "SetVC.h"
-
-#include <string.h>
-#include <assert.h>
-
-
-const Type SetVC_Type = "SetVC";
-const Name defaultSetVCName = "defaultSetVCName";
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Constructor
-*/
-
-VariableCondition* SetVC_Factory(
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data )
-{
- return (VariableCondition*)SetVC_New( defaultSetVCName, NULL, variable_Register, conFunc_Register, dictionary );
-}
-
-
-SetVC* SetVC_New(
- Name name,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary )
-{
- return _SetVC_New(
- sizeof(SetVC),
- SetVC_Type,
- _SetVC_Delete,
- _SetVC_Print,
- _SetVC_Copy,
- (Stg_Component_DefaultConstructorFunction*)SetVC_DefaultNew,
- _VariableCondition_Construct,
- _VariableCondition_Build,
- _VariableCondition_Initialise,
- _VariableCondition_Execute,
- _VariableCondition_Destroy,
- name,
- True,
- NULL,
- _SetVC_PrintConcise,
- _SetVC_ReadDictionary,
- _SetVC_GetSet,
- _SetVC_GetVariableCount,
- _SetVC_GetVariableIndex,
- _SetVC_GetValueIndex,
- _SetVC_GetValueCount,
- _SetVC_GetValue,
- _VariableCondition_Apply,
- _dictionaryEntryName,
- variable_Register,
- conFunc_Register,
- dictionary );
-}
-
-SetVC* SetVC_DefaultNew( Name name )
-{
- return (SetVC*)_SetVC_New(
- sizeof(SetVC),
- SetVC_Type,
- _SetVC_Delete,
- _SetVC_Print,
- _SetVC_Copy,
- (Stg_Component_DefaultConstructorFunction*)SetVC_DefaultNew,
- _VariableCondition_Construct,
- _VariableCondition_Build,
- _VariableCondition_Initialise,
- _VariableCondition_Execute,
- _VariableCondition_Destroy,
- name,
- False,
- NULL,
- _SetVC_PrintConcise,
- _SetVC_ReadDictionary,
- _SetVC_GetSet,
- _SetVC_GetVariableCount,
- _SetVC_GetVariableIndex,
- _SetVC_GetValueIndex,
- _SetVC_GetValueCount,
- _SetVC_GetValue,
- _VariableCondition_Apply,
- NULL,
- NULL/*variable_Register*/,
- NULL/*conFunc_Register*/,
- NULL/*dictionary*/ );
-}
-
-void SetVC_Init(
- SetVC* self,
- Name name,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary )
-{
- /* General info */
- self->type = SetVC_Type;
- self->_sizeOfSelf = sizeof(SetVC);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _SetVC_Delete;
- self->_print = _SetVC_Print;
- self->_copy = _SetVC_Copy;
- self->_build = _VariableCondition_Build;
- self->_initialise = _VariableCondition_Initialise;
- self->_execute = _VariableCondition_Execute;
- self->_buildSelf = NULL;
- self->_printConcise = _SetVC_PrintConcise;
- self->_readDictionary = _SetVC_ReadDictionary;
- self->_getSet = _SetVC_GetSet;
- self->_getVariableCount = _SetVC_GetVariableCount;
- self->_getVariableIndex = _SetVC_GetVariableIndex;
- self->_getValueIndex = _SetVC_GetValueIndex;
- self->_getValueCount = _SetVC_GetValueCount;
- self->_getValue = _SetVC_GetValue;
- self->_apply = _VariableCondition_Apply;
-
- _Stg_Class_Init( (Stg_Class*)self );
- _Stg_Object_Init( (Stg_Object*)self, name, NON_GLOBAL );
- _Stg_Component_Init( (Stg_Component*)self );
- _VariableCondition_Init( (VariableCondition*)self, variable_Register, conFunc_Register, dictionary );
-
-
- /* Stg_Class info */
- _SetVC_Init( self, _dictionaryEntryName );
-}
-
-
-SetVC* _SetVC_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc* _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary )
-{
- SetVC* self;
-
- /* Allocate memory/General info */
- assert(_sizeOfSelf >= sizeof(SetVC));
- self = (SetVC*)_VariableCondition_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _defaultConstructor,
- _construct,
- _build,
- _initialise,
- _execute,
- _destroy,
- name,
- initFlag,
- _buildSelf,
- _printConcise,
- _readDictionary,
- _getSet,
- _getVariableCount,
- _getVariableIndex,
- _getValueIndex,
- _getValueCount,
- _getValue,
- _apply,
- variable_Register,
- conFunc_Register,
- dictionary );
-
- /* Virtual info */
-
- /* Stg_Class info */
- if( initFlag ){
- _SetVC_Init( self, _dictionaryEntryName );
- }
-
- return self;
-}
-
-void _SetVC_Init( void* setVC, Name _dictionaryEntryName ) {
- SetVC* self = (SetVC*)setVC;
-
- self->isConstructed = True;
- self->_dictionaryEntryName = _dictionaryEntryName;
-}
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** General virtual functions
-*/
-
-void _SetVC_ReadDictionary( void* setVC, void* dictionary ) {
- SetVC* self = (SetVC*)setVC;
- Dictionary_Entry_Value* vcDictVal;
- Dictionary_Entry_Value _vcDictVal;
- Dictionary_Entry_Value* varsVal;
- SetVC_Entry_Index entry_I;
-
-
- /* Find dictionary entry */
- if (self->_dictionaryEntryName)
- vcDictVal = Dictionary_Get( dictionary, self->_dictionaryEntryName );
- else
- {
- vcDictVal = &_vcDictVal;
- Dictionary_Entry_Value_InitFromStruct( vcDictVal, dictionary );
- }
-
- if (vcDictVal)
- {
- Dictionary_Entry_Value* setVal = Dictionary_Entry_Value_GetMember( vcDictVal, "indices" );
- Index indexCnt = Dictionary_Entry_Value_AsUnsignedInt(
- Dictionary_Entry_Value_GetMember( vcDictVal, "indexCount" ) );
- Index i, cnt;
-
- self->_vcset = IndexSet_New( indexCnt );
- cnt = Dictionary_Entry_Value_GetCount( setVal );
- for( i = 0; i < cnt; i++ )
- IndexSet_Add( self->_vcset, Dictionary_Entry_Value_AsUnsignedInt(
- Dictionary_Entry_Value_GetElement( setVal, i ) ) );
-
- /* Obtain the variable entries */
- varsVal = Dictionary_Entry_Value_GetMember(vcDictVal, "variables");
- self->_entryCount = Dictionary_Entry_Value_GetCount( varsVal );
- self->_entryTbl = Memory_Alloc_Array( SetVC_Entry, self->_entryCount, "SetVC->_entryTbl");
-
- for (entry_I = 0; entry_I < self->_entryCount; entry_I++)
- {
- char* valType;
- Dictionary_Entry_Value* valueEntry;
- Dictionary_Entry_Value* varDictListVal;
-
- varDictListVal = Dictionary_Entry_Value_GetElement(varsVal, entry_I);
- valueEntry = Dictionary_Entry_Value_GetMember(varDictListVal, "value");
-
- self->_entryTbl[entry_I].varName = Dictionary_Entry_Value_AsString(
- Dictionary_Entry_Value_GetMember(varDictListVal, "name"));
-
- valType = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(varDictListVal, "type"));
- if (!strcasecmp(valType, "func"))
- {
- char* funcName = Dictionary_Entry_Value_AsString(valueEntry);
-
- self->_entryTbl[entry_I].value.type = VC_ValueType_CFIndex;
- self->_entryTbl[entry_I].value.as.typeCFIndex = ConditionFunction_Register_GetIndex(
- self->conFunc_Register, funcName);
- }
- else if (!strcasecmp(valType, "array"))
- {
- Dictionary_Entry_Value* valueElement;
- Index i;
-
- self->_entryTbl[entry_I].value.type = VC_ValueType_DoubleArray;
- self->_entryTbl[entry_I].value.as.typeArray.size = Dictionary_Entry_Value_GetCount(valueEntry);
- self->_entryTbl[entry_I].value.as.typeArray.array = Memory_Alloc_Array( double,
- self->_entryTbl[entry_I].value.as.typeArray.size, "SetVC->_entryTbl[].value.as.typeArray.array" );
-
- for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++)
- {
- valueElement = Dictionary_Entry_Value_GetElement(valueEntry, i);
- self->_entryTbl[entry_I].value.as.typeArray.array[i] =
- Dictionary_Entry_Value_AsDouble(valueElement);
- }
- }
- else if( !strcasecmp( valType, "double" ) || !strcasecmp( valType, "d" ) || !strcasecmp( valType, "float" ) || !strcasecmp( valType, "f" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
- self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
- }
- else if( !strcasecmp( valType, "integer" ) || !strcasecmp( valType, "int" ) || !strcasecmp( valType, "i" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Int;
- self->_entryTbl[entry_I].value.as.typeInt = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
- }
- else if( !strcasecmp( valType, "short" ) || !strcasecmp( valType, "s" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Short;
- self->_entryTbl[entry_I].value.as.typeShort = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
- }
- else if( !strcasecmp( valType, "char" ) || !strcasecmp( valType, "c" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Char;
- self->_entryTbl[entry_I].value.as.typeChar = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
- }
- else if( !strcasecmp( valType, "pointer" ) || !strcasecmp( valType, "ptr" ) || !strcasecmp( valType, "p" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Ptr;
- self->_entryTbl[entry_I].value.as.typePtr = (void*) ((ArithPointer) Dictionary_Entry_Value_AsUnsignedInt( valueEntry ));
- }
- else {
- /* Assume double */
- Journal_DPrintf(
- Journal_Register( InfoStream_Type, "myStream" ),
- "Type to variable on variable condition not given, assuming double\n" );
- self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
- self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
- }
- }
- }
- else
- {
- self->_entryCount = 0;
- self->_entryTbl = NULL;
- }
-}
-
-void _SetVC_Delete(void* setVC)
-{
- SetVC* self = (SetVC*)setVC;
-
- if (self->_entryTbl) Memory_Free( self->_entryTbl );
-
- /* Stg_Class_Delete parent */
- _VariableCondition_Delete(self);
-}
-
-
-void _SetVC_Print(void* setVC, Stream* stream)
-{
- SetVC* self = (SetVC*)setVC;
- SetVC_Entry_Index entry_I;
- Index i;
-
- /* Set the Journal for printing informations */
- Stream* info = stream;
-
- /* General info */
- Journal_Printf( info, "SetVC (ptr): %p\n", self);
-
- /* Virtual info */
-
- /* Stg_Class info */
- Journal_Printf( info, "\tdictionary (ptr): %p\n", self->dictionary);
- Journal_Printf( info, "\t_dictionaryEntryName (ptr): %p\n", self->_dictionaryEntryName);
- if (self->_dictionaryEntryName)
- Journal_Printf( info, "\t\t_dictionaryEntryName: %s\n", self->_dictionaryEntryName);
- Journal_Printf( info, "\t_entryCount: %u\n", self->_entryCount);
- Journal_Printf( info, "\t_entryTbl (ptr): %p\n", self->_entryTbl);
- if (self->_entryTbl)
- for (entry_I = 0; entry_I < self->_entryCount; entry_I++)
- {
- Journal_Printf( info, "\t\t_entryTbl[%u]:\n", entry_I);
- Journal_Printf( info, "\t\t\tvarName (ptr): %p\n", self->_entryTbl[entry_I].varName);
- if (self->_entryTbl[entry_I].varName)
- Journal_Printf( info, "\t\t\t\tvarName: %s\n", self->_entryTbl[entry_I].varName);
- Journal_Printf( info, "\t\t\tvalue:\n");
- switch (self->_entryTbl[entry_I].value.type)
- {
- case VC_ValueType_Double:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Double\n" );
- Journal_Printf( info, "\t\t\t\tasDouble: %g\n", self->_entryTbl[entry_I].value.as.typeDouble );
- break;
-
- case VC_ValueType_Int:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Int\n" );
- Journal_Printf( info, "\t\t\t\tasInt: %i\n", self->_entryTbl[entry_I].value.as.typeInt );
- break;
-
- case VC_ValueType_Short:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Short\n" );
- Journal_Printf( info, "\t\t\t\tasShort: %i\n", self->_entryTbl[entry_I].value.as.typeShort );
- break;
-
- case VC_ValueType_Char:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Char\n");
- Journal_Printf( info, "\t\t\t\tasChar: %c\n", self->_entryTbl[entry_I].value.as.typeChar );
- break;
-
- case VC_ValueType_Ptr:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Ptr\n");
- Journal_Printf( info, "\t\t\t\tasPtr: %g\n", self->_entryTbl[entry_I].value.as.typePtr );
- break;
-
- case VC_ValueType_DoubleArray:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_DoubleArray\n");
- Journal_Printf( info, "\t\t\t\tarraySize: %u\n", self->_entryTbl[entry_I].value.as.typeArray.size);
- Journal_Printf( info, "\t\t\t\tasDoubleArray (ptr): %p\n",
- self->_entryTbl[entry_I].value.as.typeArray.array);
- if (self->_entryTbl[entry_I].value.as.typeArray.array)
- for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++)
- Journal_Printf( info, "\t\t\t\tasDoubleArray[%u]: %g\n", i,
- self->_entryTbl[entry_I].value.as.typeArray.array[i]);
- break;
-
- case VC_ValueType_CFIndex:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_CFIndex\n");
- Journal_Printf( info, "\t\t\t\tasCFIndex: %u\n", self->_entryTbl[entry_I].value.as.typeCFIndex);
- break;
- }
- }
-
- /* Print parent */
- _VariableCondition_Print(self);
-}
-
-
-void* _SetVC_Copy( void* setVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
- SetVC* self = (SetVC*)setVC;
- SetVC* newSetVC;
- PtrMap* map = ptrMap;
- Bool ownMap = False;
-
- if( !map ) {
- map = PtrMap_New( 10 );
- ownMap = True;
- }
-
- newSetVC = (SetVC*)_VariableCondition_Copy( self, dest, deep, nameExt, map );
-
- newSetVC->_dictionaryEntryName = self->_dictionaryEntryName;
- newSetVC->_entryCount = self->_entryCount;
-
- if( deep ) {
- newSetVC->_vcset = (IndexSet*)Stg_Class_Copy( self->_vcset, NULL, deep, nameExt, map );
-
- if( (newSetVC->_entryTbl = PtrMap_Find( map, self->_entryTbl )) == NULL && self->_entryTbl ) {
- newSetVC->_entryTbl = Memory_Alloc_Array( SetVC_Entry, newSetVC->_entryCount, "SetVC->_entryTbl");
- memcpy( newSetVC->_entryTbl, self->_entryTbl, sizeof(SetVC_Entry) * newSetVC->_entryCount );
- PtrMap_Append( map, newSetVC->_entryTbl, self->_entryTbl );
- }
- }
- else {
- newSetVC->_vcset = self->_vcset;
- newSetVC->_entryTbl = self->_entryTbl;
- }
-
- if( ownMap ) {
- Stg_Class_Delete( map );
- }
-
- return (void*)newSetVC;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Macros
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-IndexSet* _SetVC_GetSet( void* variableCondition ) {
- SetVC* self = (SetVC*)variableCondition;
-
- return (IndexSet*) IndexSet_Duplicate( self->_vcset );
-}
-
-
-VariableCondition_VariableIndex _SetVC_GetVariableCount( void* variableCondition, Index globalIndex ) {
- SetVC* self = (SetVC*)variableCondition;
-
- return self->_entryCount;
-}
-
-
-Variable_Index _SetVC_GetVariableIndex( void* variableCondition, Index globalIndex, VariableCondition_VariableIndex varIndex ) {
- SetVC* self = (SetVC*)variableCondition;
-
- return Variable_Register_GetIndex(self->variable_Register, self->_entryTbl[varIndex].varName);
-}
-
-
-VariableCondition_ValueIndex _SetVC_GetValueIndex(
- void* variableCondition,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex )
-{
- return varIndex;
-}
-
-
-VariableCondition_ValueIndex _SetVC_GetValueCount( void* variableCondition ) {
- SetVC* self = (SetVC*)variableCondition;
-
- return self->_entryCount;
-}
-
-
-VariableCondition_Value _SetVC_GetValue( void* variableCondition, VariableCondition_ValueIndex valIndex ) {
- SetVC* self = (SetVC*)variableCondition;
-
- return self->_entryTbl[valIndex].value;
-}
-
-
-void _SetVC_PrintConcise( void* variableCondition, Stream* stream ) {
- SetVC* self = (SetVC*)variableCondition;
- IndexSet_Index set_I;
-
- Journal_Printf( stream, "\ttype: %s, set: {", self->type );
- for( set_I = 0; set_I < self->_set->size; set_I++ ) {
- if( IndexSet_IsMember( self->_set, set_I ) ) {
- Journal_Printf( stream, "%u ", set_I );
- }
- }
- Journal_Printf( stream, "}\n" );
-}
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Build functions
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Functions
-*/
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/SetVC.h
--- a/Base/Automation/src/SetVC.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,183 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** Role:
-**
-** Assumptions:
-**
-** Comments:
-**
-** $Id: SetVC.h 4153 2007-07-26 02:25:22Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Base_Automation_SetVC_h__
-#define __Base_Automation_SetVC_h__
-
-
- extern const Type SetVC_Type;
-
-
- #define __SetVC_Entry \
- Name varName; \
- VariableCondition_Value value; \
-
- struct _SetVC_Entry { __SetVC_Entry };
-
-
- #define __SetVC \
- /* General info */ \
- __VariableCondition \
- \
- /* Virtual info */ \
- \
- /* Stg_Class info */ \
- Name _dictionaryEntryName; \
- SetVC_Entry_Index _entryCount; \
- SetVC_Entry* _entryTbl; \
- IndexSet* _vcset;
-
- struct _SetVC { __SetVC };
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructor
- */
-
- VariableCondition* SetVC_Factory(
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data );
-
- SetVC* SetVC_New(
- Name name,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary );
-
- SetVC* SetVC_DefaultNew( Name name );
-
- void SetVC_Init(
- SetVC* self,
- Name name,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary );
-
- SetVC* _SetVC_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc* _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary );
-
- void _SetVC_Init( void* setVC, Name _dictionaryEntryName );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** General virtual functions
- */
-
- void _SetVC_Delete( void* setVC );
-
- void _SetVC_Print( void* setVC, Stream* stream );
-
- /* Copy */
- #define SetVC_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
- #define SetVC_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
-
- void* _SetVC_Copy( void* setVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Macros
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _SetVC_ReadDictionary( void* setVC, void* dictionary );
-
- IndexSet* _SetVC_GetSet( void* variableCondition );
-
- VariableCondition_VariableIndex _SetVC_GetVariableCount( void* variableCondition, Index globalIndex );
-
- Variable_Index _SetVC_GetVariableIndex(
- void* variableCondition,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex);
-
- VariableCondition_ValueIndex _SetVC_GetValueIndex(
- void* variableCondition,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex);
-
- VariableCondition_ValueIndex _SetVC_GetValueCount( void* variableCondition );
-
- VariableCondition_Value _SetVC_GetValue( void* variableCondition, VariableCondition_ValueIndex valIndex );
-
- void _SetVC_PrintConcise( void* variableCondition, Stream* stream );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Build functions
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Functions
- */
-
-
-#endif /* __Base_Automation_SetVC_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/SetVC.meta
--- a/Base/Automation/src/SetVC.meta Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
-<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
-
-<param name="Name">SetVC</param>
- <param name="Author">...</param>
- <param name="Organisation">VPAC</param>
- <param name="Project">StGermain</param>
- <param name="Location">./StGermain/Base/Automation/src/</param>
- <param name="Project Web">http://www.stgermainproject.org/</param>
- <param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
- <param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
- <param name="Parent">VariableCondition</param>
- <param name="Reference">...</param>
- <param name="Summary">...</param>
-
- <param name="Description">
- Selects a definite set of entries from a variable to have a condition
- applied.
- </param>
-
- <list name="Params">
- <struct>
- <param name="Name">indexCount</param>
- <param name="Type">Integer</param>
- <param name="Default"></param>
- <param name="Description">
- The number of entries in the index set.
- </param>
- </struct>
- <struct>
- <param name="Name">indices</param>
- <param name="Type">List</param>
- <param name="Default"></param>
- <param name="Description">
- A list of integers representing the indices in the set to be applied to.
- </param>
- </struct>
- <struct>
- <param name="Name">variables</param>
- <param name="Type">List</param>
- <param name="Default"></param>
- <param name="Description">
- A list of variable structures describing a Variable object to have values set and
- the values to apply. Each structure has three parameters: 'name' (the name of the
- Variable object), 'type' (the type of the value, either double or func) and 'value'
- (for a double this is a number and for a func this is the name of the condition
- function).
- </param>
- </struct>
- </list>
-
- <list name="Dependencies">
- n/a
- </list>
-
- <param name="Example">
- No examples available.
- </param>
-
-</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Stg_Component.c
--- a/Base/Automation/src/Stg_Component.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Stg_Component.c Tue Jan 12 14:38:16 2010 +1100
@@ -53,26 +53,13 @@ const Type Stg_Component_Type = "Stg_Com
const Type Stg_Component_Type = "Stg_Component";
-Stg_Component* _Stg_Component_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- AllocationType nameAllocationType )
+Stg_Component* _Stg_Component_New( STG_COMPONENT_DEFARGS )
{
Stg_Component* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(Stg_Component) );
- self = (Stg_Component*)_Stg_Object_New( _sizeOfSelf, type, _delete, _print, _copy, name, nameAllocationType );
+ self = (Stg_Component*)_Stg_Object_New( STG_OBJECT_PASSARGS );
/* General info */
@@ -111,12 +98,15 @@ void _Stg_Component_Delete( void* compon
void _Stg_Component_Delete( void* component ) {
Stg_Component* self = (Stg_Component*)component;
+ /* just make sure the component is destroyed */
+ Stg_Component_Destroy( self, NULL, False );
+
Memory_Free( self->destroyType );
Memory_Free( self->executeType );
Memory_Free( self->initialiseType );
Memory_Free( self->buildType );
Memory_Free( self->constructType );
-
+
/* Stg_Class_Delete parent class */
_Stg_Object_Delete( self );
}
@@ -134,7 +124,7 @@ void _Stg_Component_Print( void* compone
/* Virtual info */
Journal_Printf( (void*) stream, "\t_defaultConstructor (func ptr): %p\n", self->_defaultConstructor );
Journal_Printf( (void*) stream, "\t_construct (func ptr): %p\n", self->_construct );
- Journal_Printf( (void*) stream, "\t_build (func ptr): %p\n", self->_build );
+
Journal_Printf( (void*) stream, "\t_initialise (func ptr): %p\n", self->_initialise );
Journal_Printf( (void*) stream, "\t_execute (func ptr): %p\n", self->_execute );
Journal_Printf( (void*) stream, "\t_destroy (func ptr): %p\n", self->_destroy );
@@ -187,7 +177,7 @@ void* _Stg_Component_Copy( void* compone
return newComponent;
}
-void Stg_Component_Construct( void* component, Stg_ComponentFactory* cf, void* data, Bool force ) {
+void Stg_Component_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data, Bool force ) {
Stg_Component* self = (Stg_Component*)component;
assert( self );
@@ -351,10 +341,11 @@ void Stg_Component_Execute( void* compon
void Stg_Component_Destroy( void* component, void* data, Bool force ) {
Stg_Component* self = (Stg_Component*)component;
- if( force || !self->isDestroyed ) {
- /*Stg_TimeMonitor* tm;
- Stg_MemMonitor* mm;
- char* buf;
+
+ if( /* TODO: once the refCounters are implemented there is no longeer a need to check self|| */ self && !self->isDestroyed ) {
+ /*Stg_TimeMonitor* tm;
+ Stg_MemMonitor* mm;
+ char* buf;
buf = Stg_Object_AppendSuffix( self, "Destroy" );
@@ -368,9 +359,11 @@ void Stg_Component_Destroy( void* compon
Stg_CallGraph_Push( stgCallGraph, self->_destroy, self->destroyType );
#endif
- self->_destroy( self, data );
self->isDestroyed = True;
-
+
+ if( self->_destroy )
+ self->_destroy( self, data );
+
#ifdef USE_PROFILE
Stg_CallGraph_Pop( stgCallGraph );
#endif
@@ -383,7 +376,6 @@ void Stg_Component_Destroy( void* compon
Memory_Free( buf );*/
}
}
-
/* TODO: UPT TO HERE */
@@ -489,3 +481,5 @@ void Stg_Component_SetupStreamFromDictio
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Stg_Component.h
--- a/Base/Automation/src/Stg_Component.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Stg_Component.h Tue Jan 12 14:38:16 2010 +1100
@@ -37,8 +37,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_Stg_Component_h__
-#define __Base_Automation_Stg_Component_h__
+#ifndef __StGermain_Base_Automation_Stg_Component_h__
+#define __StGermain_Base_Automation_Stg_Component_h__
/* Templates of virtual functions */
typedef void* (Stg_Component_DefaultConstructorFunction) ( Name name );
@@ -64,58 +64,54 @@
\
/* Virtual info */ \
Stg_Component_DefaultConstructorFunction* _defaultConstructor; \
- Stg_Component_ConstructFunction* _construct; \
- Stg_Component_BuildFunction* _build; \
- Stg_Component_InitialiseFunction* _initialise; \
- Stg_Component_ExecuteFunction* _execute; \
- Stg_Component_DestroyFunction* _destroy; \
+ Stg_Component_ConstructFunction* _construct; \
+ Stg_Component_BuildFunction* _build; \
+ Stg_Component_InitialiseFunction* _initialise; \
+ Stg_Component_ExecuteFunction* _execute; \
+ Stg_Component_DestroyFunction* _destroy; \
\
/* Stg_Component info */ \
- Bool isConstructed; \
- Bool isBuilt; \
- Bool isInitialised; \
- Bool hasExecuted; \
- Bool isDestroyed; \
- Type constructType; \
- Type buildType; \
- Type initialiseType; \
- Type executeType; \
- Type destroyType;
+ Bool isConstructed; \
+ Bool isBuilt; \
+ Bool isInitialised; \
+ Bool hasExecuted; \
+ Bool isDestroyed; \
+ Type constructType; \
+ Type buildType; \
+ Type initialiseType; \
+ Type executeType; \
+ Type destroyType;
struct Stg_Component { __Stg_Component };
- #define STG_COMPONENT_DEFARGS \
- STG_CLASS_DEFARGS, \
- Stg_Component_DefaultConstructorFunction* _defaultConstructor, \
- Stg_Component_ConstructFunction* _construct, \
- Stg_Component_BuildFunction* _build, \
- Stg_Component_InitialiseFunction* _initialise, \
- Stg_Component_ExecuteFunction* _execute, \
- Stg_Component_DestroyFunction* _destroy, \
- Name name, \
- AllocationType nameAllocationType
- #define STG_COMPONENT_PASSARGS \
- STG_CLASS_PASSARGS, _defaultConstructor, _construct, \
- _build, _initialise, _execute, _destroy, \
- name, nameAllocationType
/* No Stg_Component_New or Stg_Component_Init as this is an abstract class */
/* Creation implementation */
- Stg_Component* _Stg_Component_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- AllocationType nameAllocationType );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STG_COMPONENT_DEFARGS \
+ STG_OBJECT_DEFARGS, \
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor, \
+ Stg_Component_ConstructFunction* _construct, \
+ Stg_Component_BuildFunction* _build, \
+ Stg_Component_InitialiseFunction* _initialise, \
+ Stg_Component_ExecuteFunction* _execute, \
+ Stg_Component_DestroyFunction* _destroy
+
+ #define STG_COMPONENT_PASSARGS \
+ STG_OBJECT_PASSARGS, \
+ _defaultConstructor, \
+ _construct, \
+ _build, \
+ _initialise, \
+ _execute, \
+ _destroy
+
+ Stg_Component* _Stg_Component_New( STG_COMPONENT_DEFARGS );
/* Class Administration members ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -143,7 +139,7 @@
(Stg_Component*)Stg_Class_Copy( self, NULL, True, NULL, NULL )
/** Contruct the component. Configure/setup the component. */
- void Stg_Component_Construct( void* component, Stg_ComponentFactory* cf, void* data, Bool force );
+ void Stg_Component_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data, Bool force );
/** Build the component: Take the configuration and instantiate the component (do all main mallocs, etc). */
void Stg_Component_Build( void* component, void* data, Bool force );
@@ -181,4 +177,5 @@
void Stg_Component_SetupStreamFromDictionary( void* component, Dictionary* dictionary );
-#endif /* __Base_Automation_Stg_Component_h__ */
+#endif /* __StGermain_Base_Automation_Stg_Component_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Stg_ComponentFactory.c
--- a/Base/Automation/src/Stg_ComponentFactory.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Stg_ComponentFactory.c Tue Jan 12 14:38:16 2010 +1100
@@ -59,34 +59,12 @@ const Type Stg_ComponentFactory_Type = "
** Constructor
*/
/* Creation implementation */
-Stg_ComponentFactory* _Stg_ComponentFactory_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_ComponentFactory_GetDoubleFunc* getDouble,
- Stg_ComponentFactory_GetIntFunc* getInt,
- Stg_ComponentFactory_GetUnsignedIntFunc* getUnsignedInt,
- Stg_ComponentFactory_GetBoolFunc* getBool,
- Stg_ComponentFactory_GetStringFunc* getString,
- Stg_ComponentFactory_GetRootDictDoubleFunc* getRootDictDouble,
- Stg_ComponentFactory_GetRootDictIntFunc* getRootDictInt,
- Stg_ComponentFactory_GetRootDictUnsignedIntFunc* getRootDictUnsignedInt,
- Stg_ComponentFactory_GetRootDictBoolFunc* getRootDictBool,
- Stg_ComponentFactory_GetRootDictStringFunc* getRootDictString,
- Stg_ComponentFactory_ConstructByNameFunc* constructByName,
- Stg_ComponentFactory_ConstructByKeyFunc* constructByKey,
- Stg_ComponentFactory_ConstructByNameWithKeyFallbackFunc* constructByNameWithKeyFallback,
- Stg_ComponentFactory_ConstructByListFunc* constructByList,
- Dictionary* rootDict,
- Dictionary* componentDict,
- Stg_ObjectList* registerRegister )
+Stg_ComponentFactory* _Stg_ComponentFactory_New( STG_COMPONENTFACTORY_DEFARGS )
{
Stg_ComponentFactory *self = NULL;
assert( _sizeOfSelf >= sizeof( Stg_ComponentFactory ) );
- self = (Stg_ComponentFactory*) _Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (Stg_ComponentFactory*) _Stg_Class_New( STG_CLASS_PASSARGS );
self->getDouble = getDouble;
self->getInt = getInt;
@@ -107,7 +85,6 @@ Stg_ComponentFactory* _Stg_ComponentFact
self->rootDict = rootDict;
self->componentDict = componentDict;
- self->registerRegister = registerRegister;
self->infoStream = Journal_Register( InfoStream_Type, self->type );
Stream_SetPrintingRank( self->infoStream, 0 );
Stream_SetAutoFlush( self->infoStream, True );
@@ -117,37 +94,34 @@ Stg_ComponentFactory* _Stg_ComponentFact
return self;
}
-Stg_ComponentFactory* Stg_ComponentFactory_New(
- Dictionary* rootDict,
- Dictionary* componentDict,
- Stg_ObjectList* registerRegister )
-{
+Stg_ComponentFactory* Stg_ComponentFactory_New( Dictionary* rootDict, Dictionary* componentDict ) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( Stg_ComponentFactory );
+ Type type = Stg_ComponentFactory_Type;
+ Stg_Class_DeleteFunction* _delete = _Stg_ComponentFactory_Delete;
+ Stg_Class_PrintFunction* _print = _Stg_ComponentFactory_Print;
+ Stg_ComponentFactory_GetDoubleFunc* getDouble = _Stg_ComponentFactory_GetDouble;
+ Stg_ComponentFactory_GetIntFunc* getInt = _Stg_ComponentFactory_GetInt;
+ Stg_ComponentFactory_GetUnsignedIntFunc* getUnsignedInt = _Stg_ComponentFactory_GetUnsignedInt;
+ Stg_ComponentFactory_GetBoolFunc* getBool = _Stg_ComponentFactory_GetBool;
+ Stg_ComponentFactory_GetStringFunc* getString = _Stg_ComponentFactory_GetString;
+ Stg_ComponentFactory_GetRootDictDoubleFunc* getRootDictDouble = _Stg_ComponentFactory_GetRootDictDouble;
+ Stg_ComponentFactory_GetRootDictIntFunc* getRootDictInt = _Stg_ComponentFactory_GetRootDictInt;
+ Stg_ComponentFactory_GetRootDictUnsignedIntFunc* getRootDictUnsignedInt = _Stg_ComponentFactory_GetRootDictUnsignedInt;
+ Stg_ComponentFactory_GetRootDictBoolFunc* getRootDictBool = _Stg_ComponentFactory_GetRootDictBool;
+ Stg_ComponentFactory_GetRootDictStringFunc* getRootDictString = _Stg_ComponentFactory_GetRootDictString;
+ Stg_ComponentFactory_ConstructByNameFunc* constructByName = _Stg_ComponentFactory_ConstructByName;
+ Stg_ComponentFactory_ConstructByKeyFunc* constructByKey = _Stg_ComponentFactory_ConstructByKey;
+ Stg_ComponentFactory_ConstructByNameWithKeyFallbackFunc* constructByNameWithKeyFallback = _Stg_ComponentFactory_ConstructByNameWithKeyFallback;
+ Stg_ComponentFactory_ConstructByListFunc* constructByList = _Stg_ComponentFactory_ConstructByList;
+
Stg_ComponentFactory *self = NULL;
assert( rootDict );
- assert( registerRegister );
- self = _Stg_ComponentFactory_New( sizeof( Stg_ComponentFactory ),
- Stg_ComponentFactory_Type,
- _Stg_ComponentFactory_Delete,
- _Stg_ComponentFactory_Print,
- NULL,
- _Stg_ComponentFactory_GetDouble,
- _Stg_ComponentFactory_GetInt,
- _Stg_ComponentFactory_GetUnsignedInt,
- _Stg_ComponentFactory_GetBool,
- _Stg_ComponentFactory_GetString,
- _Stg_ComponentFactory_GetRootDictDouble,
- _Stg_ComponentFactory_GetRootDictInt,
- _Stg_ComponentFactory_GetRootDictUnsignedInt,
- _Stg_ComponentFactory_GetRootDictBool,
- _Stg_ComponentFactory_GetRootDictString,
- _Stg_ComponentFactory_ConstructByName,
- _Stg_ComponentFactory_ConstructByKey,
- _Stg_ComponentFactory_ConstructByNameWithKeyFallback,
- _Stg_ComponentFactory_ConstructByList,
- rootDict,
- componentDict,
- registerRegister );
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ self = _Stg_ComponentFactory_New( STG_COMPONENTFACTORY_PASSARGS );
return self;
}
@@ -175,7 +149,7 @@ void _Stg_ComponentFactory_Delete( void*
assert( self );
- Stg_Class_Delete( self->LCRegister );
+ Stg_Class_Delete( self->LCRegister ); /* this deletes all the components on the LCRegister */
_Stg_Class_Delete( self );
}
@@ -222,13 +196,20 @@ void Stg_ComponentFactory_CreateComponen
if( self->componentDict ){
Journal_Printf( stream, "\nCreating Stg_Components from the component-list\n\n" );
Stream_Indent( stream );
-
+
+ /* add the contexts to the live component register first (so these get constructed/built/initialised first) */
for( component_I = 0; component_I < Dictionary_GetCount( self->componentDict ) ; component_I++ ){
componentDictEntry = self->componentDict->entryPtr[ component_I ];
currComponentDict = Dictionary_Entry_Value_AsDictionary( componentDictEntry->value );
componentType = Dictionary_GetString( currComponentDict, "Type" );
componentName = componentDictEntry->key;
+
+ if( strcmp( componentType, "DomainContext" ) &&
+ strcmp( componentType, "FiniteElementContext" ) &&
+ strcmp( componentType, "PICelleratorContext" ) &&
+ strcmp( componentType, "UnderworldContext" ) )
+ continue;
Journal_Firewall(
LiveComponentRegister_Get( self->LCRegister, componentName ) == NULL,
@@ -245,9 +226,41 @@ void Stg_ComponentFactory_CreateComponen
Stg_ComponentRegister_Get_ComponentRegister(), componentType, "0" );
/* Add to register */
- LiveComponentRegister_Add( self->LCRegister,
- componentConstructorFunction( componentName ) );
+ LiveComponentRegister_Add( self->LCRegister, componentConstructorFunction( componentName ) );
}
+
+ /* now add the rest of the components */
+ for( component_I = 0; component_I < Dictionary_GetCount( self->componentDict ) ; component_I++ ){
+ componentDictEntry = self->componentDict->entryPtr[ component_I ];
+
+ currComponentDict = Dictionary_Entry_Value_AsDictionary( componentDictEntry->value );
+ componentType = Dictionary_GetString( currComponentDict, "Type" );
+ componentName = componentDictEntry->key;
+
+ if( !strcmp( componentType, "DomainContext" ) ||
+ !strcmp( componentType, "FiniteElementContext" ) ||
+ !strcmp( componentType, "PICelleratorContext" ) ||
+ !strcmp( componentType, "UnderworldContext" ) )
+ continue;
+
+ Journal_Firewall(
+ LiveComponentRegister_Get( self->LCRegister, componentName ) == NULL,
+ Journal_Register( Error_Type, self->type ),
+ "Error in func %s: Trying to instantiate two components with the name of '%s'\n"
+ "Each component's name must be unique.\n",
+ __func__, componentName );
+
+ /* Print Message */
+ Journal_Printf( stream, "Instantiating %s as %s\n", componentType, componentName );
+
+ /* Get Default Constructor for this type */
+ componentConstructorFunction = Stg_ComponentRegister_AssertGet(
+ Stg_ComponentRegister_Get_ComponentRegister(), componentType, "0" );
+
+ /* Add to register */
+ LiveComponentRegister_Add( self->LCRegister, componentConstructorFunction( componentName ) );
+ }
+
Stream_UnIndent( stream );
}
else{
@@ -256,10 +269,6 @@ void Stg_ComponentFactory_CreateComponen
}
void Stg_ComponentFactory_ConstructComponents( Stg_ComponentFactory* self, void* data ) {
- Dictionary_Entry* componentDictEntry = NULL;
- Dictionary* currComponentDict = NULL;
- Type componentType = NULL;
- Name componentName = NULL;
Stg_Component* component = NULL;
Index component_I;
Stream* stream;
@@ -272,17 +281,119 @@ void Stg_ComponentFactory_ConstructCompo
Journal_Printf( stream, "\nConstructing Stg_Components from the live-component register\n\n" );
Stream_Indent( stream );
- for( component_I = 0; component_I < Dictionary_GetCount( self->componentDict ) ; component_I++ ){
- componentDictEntry = self->componentDict->entryPtr[ component_I ];
+ 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" );
+ }
+}
- currComponentDict = Dictionary_Entry_Value_AsDictionary( componentDictEntry->value );
- componentType = Dictionary_GetString( currComponentDict, "Type" );
- componentName = componentDictEntry->key;
+void Stg_ComponentFactory_BuildComponents( 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, "\nBuilding 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_Get( self->LCRegister, componentName );
- if( component && !component->isConstructed ){
- Stg_Component_Construct( component, self, data, True );
+ component = LiveComponentRegister_At( self->LCRegister, component_I );
+ if( component && !component->isBuilt ){
+ Stg_Component_Build( component, data, True );
+ }
+ }
+ Stream_UnIndent( stream );
+ }
+ else{
+ Journal_Printf( stream, "No Stg_ComponentList found..!\n" );
+ }
+}
+
+void Stg_ComponentFactory_InitialiseComponents( 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, "\nInitialising 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->isInitialised ){
+ Stg_Component_Initialise( component, data, True );
+ }
+ }
+ Stream_UnIndent( stream );
+ }
+ else{
+ Journal_Printf( stream, "No Stg_ComponentList found..!\n" );
+ }
+}
+
+void Stg_ComponentFactory_ExecuteComponents( 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, "\nExecuting 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->hasExecuted ){
+ Stg_Component_Execute( component, data, True );
+ }
+ }
+ Stream_UnIndent( stream );
+ }
+ else{
+ Journal_Printf( stream, "No Stg_ComponentList found..!\n" );
+ }
+}
+
+void Stg_ComponentFactory_DestroyComponents( 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, "\nDestroying 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->isDestroyed ){
+ Stg_Component_Destroy( component, data, True );
}
}
Stream_UnIndent( stream );
@@ -525,7 +636,7 @@ Stg_Component* _Stg_ComponentFactory_Con
if ( !component->isConstructed ) {
Journal_Printf( stream, "%s has not been constructed yet. Constructing now.\n", componentName );
Stream_Indent( stream );
- Stg_Component_Construct( component, self, data, True );
+ Stg_Component_AssignFromXML( component, self, data, True );
Stream_UnIndent( stream );
}
@@ -614,6 +725,198 @@ Stg_Component* _Stg_ComponentFactory_Con
return self->constructByName( self, componentName, type, isEssential, data );
}
+Stg_Component* _Stg_ComponentFactory_PluginConstructByKey(
+ void* cf,
+ void* codelet,
+ Dictionary_Entry_Key componentKey,
+ Type type,
+ Bool isEssential,
+ void* data )
+{
+ Stg_ComponentFactory* self = (Stg_ComponentFactory*)cf;
+ Stg_Component* plugin = (Stg_Component*)codelet;
+ Dictionary* thisPluginDict = NULL;
+ Dictionary* pluginDict = (Dictionary*)Dictionary_Get( self->rootDict, "plugins" );
+ Name componentName, redirect, pluginType;
+ Dictionary_Entry_Value* componentEntryVal;
+ Index pluginIndex;
+ Stream* errorStream = Journal_Register( Error_Type, self->type );
+
+ Journal_Firewall( self != NULL, errorStream, "In func %s: Stg_Component is NULL.\n", __func__ );
+
+ /* Get this plugins Dictionary */
+ for( pluginIndex = 0; pluginIndex < Dictionary_Entry_Value_GetCount( (Dictionary_Entry_Value*)pluginDict ); pluginIndex++ ) {
+ thisPluginDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Entry_Value_GetElement( (Dictionary_Entry_Value*)pluginDict, pluginIndex ) );
+ pluginType = StG_Strdup( Dictionary_GetString( thisPluginDict, "Type" ) );
+
+ if( !strcmp( plugin->type, pluginType ) ){
+ Memory_Free( pluginType );
+ break;
+ }
+ Memory_Free( pluginType );
+ }
+
+ /* Get Dependency's Name */
+ componentEntryVal = Dictionary_Get( thisPluginDict, componentKey );
+ if ( componentEntryVal == NULL ) {
+ Journal_Firewall( !isEssential, errorStream,
+ "plugin '%s' cannot find essential component with key '%s'.\n", plugin->type, componentKey );
+ Journal_PrintfL( self->infoStream, 2, "plugin '%s' cannot find non-essential component with key '%s'.\n", plugin->type, componentKey );
+ return NULL;
+ }
+
+ componentName = Dictionary_Entry_Value_AsString( componentEntryVal );
+
+ /* 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 );
+}
+
+Dictionary_Entry_Value* _Stg_ComponentFactory_PluginGetDictionaryValue( void* cf, void *codelet, Dictionary_Entry_Key key, Dictionary_Entry_Value* defaultVal ) {
+ Stg_ComponentFactory* self = (Stg_ComponentFactory*) cf;
+ Stg_Component* plugin = (Stg_Component*)codelet;
+ Dictionary* thisPluginDict = NULL;
+ Dictionary* pluginDict = (Dictionary*)Dictionary_Get( self->rootDict, "plugins" );
+ Name pluginType;
+ Index pluginIndex;
+ Dictionary_Entry_Value* returnVal;
+ Bool usedDefault = False;
+ Stream* errorStream = Journal_Register( Error_Type, Stg_Component_Type );
+ Stream* stream = self->infoStream;
+
+ Journal_Firewall( self != NULL, errorStream, "In func %s: Stg_ComponentFactory is NULL.\n", __func__ );
+
+ Journal_PrintfL( stream, 2, "Getting parameter '%s': ", key );
+
+ Journal_Firewall( pluginDict != NULL, errorStream,
+ "In func %s: Stg_Component Factory's dictionary is NULL.\n", __func__ );
+
+ /* Get this plugins Dictionary */
+ for( pluginIndex = 0; pluginIndex < Dictionary_Entry_Value_GetCount( (Dictionary_Entry_Value*)pluginDict ); pluginIndex++ ) {
+ thisPluginDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Entry_Value_GetElement( (Dictionary_Entry_Value*)pluginDict, pluginIndex ) );
+ pluginType = StG_Strdup( Dictionary_GetString( thisPluginDict, "Type" ) );
+ if( !strcmp( plugin->type, pluginType ) ){
+ Memory_Free( pluginType );
+ break;
+ }
+ Memory_Free( pluginType );
+ }
+
+ /* Get this Stg_Component's Dictionary */
+ Journal_Firewall( thisPluginDict != NULL, errorStream,
+ "In func %s: Can't find sub-dictionary for component '%s'.\n", __func__, plugin->name );
+
+ /* Get Value from dictionary */
+ returnVal = Dictionary_Get( thisPluginDict, key );
+ if ( !returnVal && defaultVal ) {
+ returnVal = Dictionary_GetDefault( thisPluginDict, key, defaultVal );
+ usedDefault = True;
+ }
+
+ /* Print Stuff */
+ if ( usedDefault ) {
+ Journal_PrintfL( stream, 2, "Using default value = " );
+ if ( Stream_IsPrintableLevel( stream, 2 ) )
+ Dictionary_Entry_Value_Print( returnVal, stream );
+ Journal_PrintfL( stream, 2, "\n" );
+
+ return returnVal;
+ }
+ else if ( returnVal ) {
+ Journal_PrintfL( stream, 2, "Found - Value = " );
+ if ( Stream_IsPrintableLevel( stream, 2 ) )
+ Dictionary_Entry_Value_Print( returnVal, stream );
+ Journal_PrintfL( stream, 2, "\n" );
+ }
+ else
+ Journal_PrintfL( stream, 2, "Not found.\n" );
+
+ return returnVal;
+}
+
+Dictionary_Entry_Value* _Stg_ComponentFactory_PluginGetNumericalValue( void* cf, void *codelet, Dictionary_Entry_Key key, Dictionary_Entry_Value* defaultVal ) {
+ Stg_ComponentFactory* self = (Stg_ComponentFactory*)cf;
+ Dictionary_Entry_Value* returnVal;
+ Bool usedDefault = False;
+ Stream* stream = self->infoStream;
+ Stream* errorStream = Journal_Register( Error_Type, self->type );
+
+ Journal_Firewall( self != NULL, errorStream, "In func %s: Stg_Component is NULL.\n", __func__ );
+
+ returnVal = _Stg_ComponentFactory_PluginGetDictionaryValue( self, codelet, key, defaultVal );
+
+ /* Check to see whether the type is a string -
+ * if it is then assume that this is a dictionary key linking to the root dictionary */
+ if ( returnVal ) {
+ Dictionary_Entry_Key rootDictKey = Dictionary_Entry_Value_AsString( returnVal );
+ Dictionary* rootDict = self->rootDict;
+
+ /* Check if the number really is a string or not */
+ if ( Stg_StringIsNumeric( rootDictKey ) )
+ return returnVal;
+
+ Journal_PrintfL( stream, 2, "Key '%s' points to key '%s' in the root dictionary: ", key, rootDictKey );
+
+ Journal_Firewall( rootDict != NULL, errorStream, "Root Dictionary NULL in component factory.\n" );
+
+ /* Get Value from dictionary */
+ returnVal = Dictionary_Get( rootDict, rootDictKey );
+ if ( !returnVal && defaultVal ) {
+ returnVal = Dictionary_GetDefault( rootDict, rootDictKey, defaultVal );
+ usedDefault = True;
+ }
+
+ /* Print Stuff */
+ if ( usedDefault ) {
+ Journal_PrintfL( stream, 2, "Using default value = " );
+ if ( Stream_IsPrintableLevel( stream, 2 ) )
+ Dictionary_Entry_Value_Print( returnVal, stream );
+ Journal_PrintfL( stream, 2, "\n" );
+ return returnVal;
+ }
+ else if ( returnVal ) {
+ Journal_PrintfL( stream, 2, "Found - Value = " );
+ if ( Stream_IsPrintableLevel( stream, 2 ) )
+ Dictionary_Entry_Value_Print( returnVal, stream );
+ Journal_PrintfL( stream, 2, "\n" );
+ }
+ else
+ Journal_PrintfL( stream, 2, "Not found.\n" );
+ }
+
+ return returnVal;
+}
+
+
+double Stg_ComponentFactory_PluginGetDouble( void* cf, void *codelet, Dictionary_Entry_Key key, double defaultVal ) {
+ return Dictionary_Entry_Value_AsDouble(
+ _Stg_ComponentFactory_PluginGetNumericalValue( cf, codelet, key,
+ Dictionary_Entry_Value_FromDouble( defaultVal )));
+}
+
+int Stg_ComponentFactory_PluginGetInt( void* cf, void *codelet, Dictionary_Entry_Key key, int defaultVal ) {
+ return Dictionary_Entry_Value_AsInt(
+ _Stg_ComponentFactory_PluginGetNumericalValue( cf, codelet, key,
+ Dictionary_Entry_Value_FromInt( defaultVal )));
+}
+
+Bool Stg_ComponentFactory_PluginGetBool( void* cf, void *codelet, Dictionary_Entry_Key key, Bool defaultVal ) {
+ return Dictionary_Entry_Value_AsBool(
+ _Stg_ComponentFactory_PluginGetDictionaryValue( cf, codelet, key,
+ Dictionary_Entry_Value_FromBool( defaultVal ) ) );
+}
+
+char* Stg_ComponentFactory_PluginGetString( void* cf, void* codelet, Dictionary_Entry_Key key, const char* const defaultVal ) {
+ return Dictionary_Entry_Value_AsString(
+ _Stg_ComponentFactory_PluginGetDictionaryValue( cf, codelet, key,
+ Dictionary_Entry_Value_FromString( defaultVal ) ) );
+}
+
Stg_Component* _Stg_ComponentFactory_ConstructByNameWithKeyFallback(
void* cf,
Name parentComponentName,
@@ -636,7 +939,7 @@ Stg_Component* _Stg_ComponentFactory_Con
if ( !component->isConstructed ) {
Journal_Printf( stream, "%s has not been constructed yet. Constructing now.\n", componentTrialName );
Stream_Indent( stream );
- Stg_Component_Construct( component, self, data, True );
+ Stg_Component_AssignFromXML( component, self, data, True );
Stream_UnIndent( stream );
}
}
@@ -707,3 +1010,5 @@ Stg_Component** _Stg_ComponentFactory_Co
return componentList;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Stg_ComponentFactory.h
--- a/Base/Automation/src/Stg_ComponentFactory.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Stg_ComponentFactory.h Tue Jan 12 14:38:16 2010 +1100
@@ -33,8 +33,8 @@
** $Id: Stg_ComponentFactory.h 3851 2006-10-12 08:57:22Z SteveQuenette $
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_Stg_ComponentFactory_h__
-#define __Base_Automation_Stg_ComponentFactory_h__
+#ifndef __StGermain_Base_Automation_Stg_ComponentFactory_h__
+#define __StGermain_Base_Automation_Stg_ComponentFactory_h__
extern const Type Stg_ComponentFactory_Type;
@@ -139,7 +139,6 @@
Stg_ComponentFactory_ConstructByListFunc* constructByList; \
\
/* Class info */ \
- Stg_ObjectList* registerRegister; \
Dictionary* rootDict; \
Dictionary* componentDict; \
LiveComponentRegister* LCRegister; \
@@ -151,34 +150,54 @@
** Constructor
*/
/* Creation implementation */
- Stg_ComponentFactory* _Stg_ComponentFactory_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_ComponentFactory_GetDoubleFunc* getDouble,
- Stg_ComponentFactory_GetIntFunc* getInt,
- Stg_ComponentFactory_GetUnsignedIntFunc* getUnsignedInt,
- Stg_ComponentFactory_GetBoolFunc* getBool,
- Stg_ComponentFactory_GetStringFunc* getString,
- Stg_ComponentFactory_GetRootDictDoubleFunc* getRootDictDouble,
- Stg_ComponentFactory_GetRootDictIntFunc* getRootDictInt,
- Stg_ComponentFactory_GetRootDictUnsignedIntFunc* getRootDictUnsignedInt,
- Stg_ComponentFactory_GetRootDictBoolFunc* getRootDictBool,
- Stg_ComponentFactory_GetRootDictStringFunc* getRootDictString,
- Stg_ComponentFactory_ConstructByNameFunc* constructByName,
- Stg_ComponentFactory_ConstructByKeyFunc* constructByKey,
- Stg_ComponentFactory_ConstructByNameWithKeyFallbackFunc* constructByNameWithKeyFallback,
- Stg_ComponentFactory_ConstructByListFunc* constructByList,
- Dictionary* rootDict,
- Dictionary* componentDict,
- Stg_ObjectList* registerRegister );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STG_COMPONENTFACTORY_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ Stg_ComponentFactory_GetDoubleFunc* getDouble, \
+ Stg_ComponentFactory_GetIntFunc* getInt, \
+ Stg_ComponentFactory_GetUnsignedIntFunc* getUnsignedInt, \
+ Stg_ComponentFactory_GetBoolFunc* getBool, \
+ Stg_ComponentFactory_GetStringFunc* getString, \
+ Stg_ComponentFactory_GetRootDictDoubleFunc* getRootDictDouble, \
+ Stg_ComponentFactory_GetRootDictIntFunc* getRootDictInt, \
+ Stg_ComponentFactory_GetRootDictUnsignedIntFunc* getRootDictUnsignedInt, \
+ Stg_ComponentFactory_GetRootDictBoolFunc* getRootDictBool, \
+ Stg_ComponentFactory_GetRootDictStringFunc* getRootDictString, \
+ Stg_ComponentFactory_ConstructByNameFunc* constructByName, \
+ Stg_ComponentFactory_ConstructByKeyFunc* constructByKey, \
+ Stg_ComponentFactory_ConstructByNameWithKeyFallbackFunc* constructByNameWithKeyFallback, \
+ Stg_ComponentFactory_ConstructByListFunc* constructByList, \
+ Dictionary* rootDict, \
+ Dictionary* componentDict
+
+ #define STG_COMPONENTFACTORY_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ getDouble, \
+ getInt, \
+ getUnsignedInt, \
+ getBool, \
+ getString, \
+ getRootDictDouble, \
+ getRootDictInt, \
+ getRootDictUnsignedInt, \
+ getRootDictBool, \
+ getRootDictString, \
+ constructByName, \
+ constructByKey, \
+ constructByNameWithKeyFallback, \
+ constructByList, \
+ rootDict, \
+ componentDict
+
+ Stg_ComponentFactory* _Stg_ComponentFactory_New( STG_COMPONENTFACTORY_DEFARGS );
Stg_ComponentFactory* Stg_ComponentFactory_New(
Dictionary* rootDict,
- Dictionary* componentDict,
- Stg_ObjectList* registerRegister );
+ Dictionary* componentDict );
void _Stg_ComponentFactory_Init( Stg_ComponentFactory *self );
@@ -202,6 +221,14 @@
void Stg_ComponentFactory_CreateComponents( Stg_ComponentFactory *self );
void Stg_ComponentFactory_ConstructComponents( Stg_ComponentFactory* self, void* data );
+
+ void Stg_ComponentFactory_BuildComponents( Stg_ComponentFactory* self, void* data );
+
+ void Stg_ComponentFactory_InitialiseComponents( Stg_ComponentFactory* self, void* data );
+
+ void Stg_ComponentFactory_ExecuteComponents( Stg_ComponentFactory* self, void* data );
+
+ void Stg_ComponentFactory_DestroyComponents( Stg_ComponentFactory* self, void* data );
Dictionary_Entry_Value* _Stg_ComponentFactory_GetDictionaryValue(
void* cf, Name componentName, Dictionary_Entry_Key key, Dictionary_Entry_Value* defaultVal ) ;
@@ -248,6 +275,25 @@
Bool isEssential,
void* data ) ;
+ #define Stg_ComponentFactory_PluginConstructByKey( cf, codelet, componentKey, type, isEssential, data ) \
+ (type*) _Stg_ComponentFactory_PluginConstructByKey( \
+ cf, codelet, componentKey, type ## _Type, isEssential, data )
+ Stg_Component* _Stg_ComponentFactory_PluginConstructByKey(
+ void* cf,
+ void* codelet,
+ Dictionary_Entry_Key componentKey,
+ Type type,
+ Bool isEssential,
+ void* data ) ;
+
+ double Stg_ComponentFactory_PluginGetDouble( void* cf, void *codelet, Dictionary_Entry_Key key, double defaultVal );
+
+ int Stg_ComponentFactory_PluginGetInt( void* cf, void *codelet, Dictionary_Entry_Key key, int defaultVal );
+
+ Bool Stg_ComponentFactory_PluginGetBool( void* cf, void *codelet, Dictionary_Entry_Key key, Bool defaultVal );
+
+ char* Stg_ComponentFactory_PluginGetString( void* cf, void* codelet, Dictionary_Entry_Key key, const char* const defaultVal );
+
#define Stg_ComponentFactory_ConstructByNameWithKeyFallback( \
cf, parentComponentName, componentTrialName, componentFallbackKey, type, isEssential, data ) \
(type*) ( (Stg_ComponentFactory*) cf )->constructByNameWithKeyFallback( \
@@ -278,4 +324,5 @@
#define Stg_ComponentFactory_Unlimited ((unsigned int) -1)
-#endif /* __Base_Automation_Stg_ComponentFactory_h__ */
+#endif /* __StGermain_Base_Automation_Stg_ComponentFactory_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Stg_ComponentRegister.c
--- a/Base/Automation/src/Stg_ComponentRegister.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Stg_ComponentRegister.c Tue Jan 12 14:38:16 2010 +1100
@@ -46,37 +46,38 @@
/* Textual name of this class */
const Type Stg_ComponentRegister_Type = "Stg_ComponentRegister";
+const Type Stg_ComponentRegisterElement_Type = "Stg_ComponentRegisterElement";
const Name Version = "0";
Stg_ComponentRegister *stgComponentRegister = NULL;
-Stg_ComponentRegister *_Stg_ComponentRegister_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
+Stg_ComponentRegister *_Stg_ComponentRegister_New( STG_COMPONENTREGISTER_DEFARGS )
{
Stg_ComponentRegister *self = NULL;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(Stg_ComponentRegister) );
- self = (Stg_ComponentRegister*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (Stg_ComponentRegister*)_Stg_Class_New( STG_CLASS_PASSARGS );
return self;
}
Stg_ComponentRegister *Stg_ComponentRegister_New( )
{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( Stg_ComponentRegister );
+ Type type = Stg_ComponentRegister_Type;
+ Stg_Class_DeleteFunction* _delete = _Stg_ComponentRegister_Delete;
+ Stg_Class_PrintFunction* _print = _Stg_ComponentRegister_Print;
+
Stg_ComponentRegister *self = NULL;
if( stgComponentRegister == NULL ){
- self = _Stg_ComponentRegister_New( sizeof( Stg_ComponentRegister ),
- Stg_ComponentRegister_Type,
- _Stg_ComponentRegister_Delete,
- _Stg_ComponentRegister_Print,
- NULL );
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ self = _Stg_ComponentRegister_New( STG_COMPONENTREGISTER_PASSARGS );
Stg_ComponentRegister_Init( self );
}
else{
@@ -91,12 +92,8 @@ void _Stg_ComponentRegister_Init( Stg_Co
{
assert( self );
- self->constructors = BTree_New(
- constructorElementCompareFunction,
- NULL,
- constructorElementDeleteFunction,
- constructorElementPrintFunction,
- BTREE_NO_DUPLICATES );
+ self->constructors = Stg_ObjectList_New();
+ self->debugStream = Journal_Register( Debug_Type, "ComponentRegisterDebug" );
}
void Stg_ComponentRegister_Init( Stg_ComponentRegister* self )
@@ -113,6 +110,7 @@ void _Stg_ComponentRegister_Delete( void
self = (Stg_ComponentRegister*) componentRegister;
assert( self );
+ Stg_ObjectList_DeleteAllObjects( self->constructors );
Stg_Class_Delete( self->constructors );
_Stg_Class_Delete( self );
}
@@ -143,20 +141,41 @@ int Stg_ComponentRegister_AddFunc(
Stg_ComponentRegisterElement *element = NULL;
assert( self );
- element = Memory_Alloc( Stg_ComponentRegisterElement, "Stg_ComponentRegisterElement" );
- element->componentType = StG_Strdup( componentType );
- element->defaultConstructor = func;
- element->metadata = metadata;
- element->version = StG_Strdup( version );
+ element = Stg_ComponentRegisterElement_New(Stg_ComponentRegisterElement_Type,
+ _Stg_ComponentRegisterElement_Delete,
+ _Stg_ComponentRegisterElement_Print,
+ componentType,
+ func,
+ metadata,
+ version
+ );
- Journal_Firewall( BTree_InsertNode( self->constructors, (void*)element, sizeof( Stg_ComponentRegisterElement ) ),
+ Journal_Printf( self->debugStream, "Adding [%s] to ComponentRegister\n", componentType);
+
+ /* Copy component type into name field - used as key in objectList */
+ element->name = StG_Strdup(componentType);
+
+ /* search object list to avoid duplicates... */
+ Journal_Firewall( Stg_ObjectList_Get(self->constructors, element->name ) == NULL,
Journal_Register( Error_Type, Stg_ComponentRegister_Type ),
"Error in func %s: Attempting to enter duplicate constructors for type '%s' (version '%s').\n"
"This should only be done once per type.\n",
__func__, componentType, version );
+ /* Append element to list */
+ Stg_ObjectList_Append(self->constructors, element );
return 1;
+}
+
+Bool Stg_ComponentRegister_RemoveEntry(
+ Stg_ComponentRegister* self,
+ Name componentType,
+ Name version )
+{
+ assert( self );
+ Stg_ObjectList_Remove( self->constructors, componentType, DELETE);
+ return True;
}
Stg_Component_DefaultConstructorFunction* Stg_ComponentRegister_Get(
@@ -164,26 +183,14 @@ Stg_Component_DefaultConstructorFunction
Name componentType,
Name version )
{
- BTreeNode *node = NULL;
- Stg_ComponentRegisterElement *element = NULL;
- SearchCriteria sc;
-
assert( self );
-
- sc.type = componentType;
- sc.version = version;
-
- BTree_SetCompareFunction( self->constructors, constructorElementCompareFunction1 );
- node = BTree_FindNode( self->constructors, (void*)(&sc) );
- BTree_SetCompareFunction( self->constructors, constructorElementCompareFunction );
- if( node ){
- element = (Stg_ComponentRegisterElement*) node->data;
- if( element ){
- return (void*) element->defaultConstructor;
- }
- }
-
- return NULL;
+ /* Get the element object */
+ Stg_ComponentRegisterElement *element = Stg_ObjectList_Get(self->constructors, componentType);
+ if ( element )
+ /* Return the constructor function pointer */
+ return element->defaultConstructor;
+ else
+ return NULL;
}
Stg_Component_DefaultConstructorFunction* Stg_ComponentRegister_AssertGet(
@@ -215,24 +222,11 @@ Dictionary* Stg_ComponentRegister_GetMet
Name componentType,
Name version )
{
- BTreeNode *node = NULL;
Stg_ComponentRegisterElement *element = NULL;
- SearchCriteria sc;
-
assert( self );
-
- sc.type = componentType;
- sc.version = version;
-
- BTree_SetCompareFunction( self->constructors, constructorElementCompareFunction1 );
- node = BTree_FindNode( self->constructors, (void*)(&sc) );
- BTree_SetCompareFunction( self->constructors, constructorElementCompareFunction );
-
- if( node ){
- element = (Stg_ComponentRegisterElement*) node->data;
- if( element ){
- return (void*) element->metadata();
- }
+ element = Stg_ObjectList_Get(self->constructors, componentType);
+ if( element ){
+ return (void*) element->metadata();
}
return NULL;
@@ -242,17 +236,48 @@ Stg_ComponentRegister *Stg_ComponentRegi
return stgComponentRegister;
}
-BTreeIterator* Stg_ComponentRegister_GetIterator( void* componentRegister ) {
+int Stg_ComponentRegister_GetCount( void* componentRegister ) {
Stg_ComponentRegister* self = (Stg_ComponentRegister*)componentRegister;
- return BTreeIterator_New( self->constructors );
+ return self->constructors->count;
}
-Stg_ComponentRegisterElement* Stg_ComponentRegisterIterator_First( BTreeIterator* iterator ) {
- return (Stg_ComponentRegisterElement*)BTreeIterator_First( iterator );
+/** Stg_ComponentRegisterElement methods:
+ * Constructor interface... */
+Stg_ComponentRegisterElement* Stg_ComponentRegisterElement_New(
+ Type type,
+ Stg_Class_DeleteFunction* _delete,
+ Stg_Class_PrintFunction* _print,
+ Type componentType,
+ Stg_Component_DefaultConstructorFunction* defaultConstructor,
+ Stg_Component_MetaAsDictionaryFunction* metadata,
+ Name version
+ )
+{
+ Stg_ComponentRegisterElement* self = ( Stg_ComponentRegisterElement*)_Stg_Class_New(
+ sizeof(Stg_ComponentRegisterElement),
+ type, _delete, _print, _Stg_Class_Copy);
+
+ self->componentType = StG_Strdup(componentType);
+ self->defaultConstructor = defaultConstructor;
+ self->metadata = metadata;
+ self->version = StG_Strdup(version);
+ return self; /* How in the hell this worked previously without returning anything I have no idea */
}
-Stg_ComponentRegisterElement* Stg_ComponentRegisterIterator_Next( BTreeIterator* iterator ) {
- return (Stg_ComponentRegisterElement*)BTreeIterator_Next( iterator );
+void _Stg_ComponentRegisterElement_Delete( void* self )
+{
+ Stg_ComponentRegisterElement* element = (Stg_ComponentRegisterElement*)self;
+ if( element ){
+ if (element->componentType) Memory_Free( element->componentType );
+ if (element->version) Memory_Free( element->version );
+ if (element->name) Memory_Free( element->name);
+ _Stg_Class_Delete( element ); /* element's parent is a class so delete it */
+ }
+}
+Stg_ComponentRegisterElement* Stg_ComponentRegister_GetByIndex( void* componentRegister, int index ) {
+ Stg_ComponentRegister* self = (Stg_ComponentRegister*)componentRegister;
+ assert(index < self->constructors->count);
+ return (Stg_ComponentRegisterElement*)self->constructors->data[index];
}
Type Stg_ComponentRegisterElement_GetType( Stg_ComponentRegisterElement* element ) {
@@ -271,172 +296,32 @@ Dictionary* Stg_ComponentRegisterElement
return element->metadata();
}
-/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-int constructorElementCompareFunction( void *data1, void *data2 )
+void _Stg_ComponentRegisterElement_Print( void* self, Stream* printStream )
{
- Stg_ComponentRegisterElement *d1 = NULL, *d2 = NULL;
- char key[1024];
- char key1[1024];
-
- d1 = (Stg_ComponentRegisterElement*)data1;
- d2 = (Stg_ComponentRegisterElement*)data2;
-
- if (d1 == NULL || d2 == NULL){
- return 0;
- }
-
- memset( key, 0, sizeof( key ) );
- memset( key1, 0, sizeof( key1 ) );
- sprintf( key, "%s%s", d1->componentType, d1->version );
- sprintf( key1, "%s%s", d2->componentType, d2->version );
-
- if (strcmp(key, key1) > 0){
- return 1;
- }
- else if (!strcmp(key, key1)){
- return 0;
- }
- else{
- return -1;
- }
-}
-
-int constructorElementCompareFunction1( void *data1, void *data2 )
-{
- Stg_ComponentRegisterElement *d1 = NULL;
- SearchCriteria *d2 = NULL;
- char key[1024];
- char key1[1024];
-
- d1 = (Stg_ComponentRegisterElement*)data1;
- d2 = (SearchCriteria*)data2;
-
- if (d1 == NULL || d2 == NULL){
- return 0;
- }
-
- memset( key, 0, sizeof( key ) );
- memset( key1, 0, sizeof( key1 ) );
- sprintf( key, "%s%s", d1->componentType, d1->version );
- sprintf( key1, "%s%s", d2->type, d2->version );
-
- if (strcmp(key, key1) > 0){
- return 1;
- }
- else if (!strcmp(key, key1)){
- return 0;
- }
- else{
- return -1;
- }
-}
-
-void constructorElementPrintFunction( void *nodeData, Stream *printStream )
-{
- Stg_ComponentRegisterElement *element;
-
- assert( nodeData );
-
- element = ( Stg_ComponentRegisterElement* ) nodeData;
+ Stg_ComponentRegisterElement* element = (Stg_ComponentRegisterElement*)self;
Journal_Printf( printStream, "Constructor Information\n");
Journal_Printf( printStream, "\tStg_ComponentType : %s\n", element->componentType );
Journal_Printf( printStream, "\tStg_Component Default Constructor: %p\n", element->defaultConstructor );
Journal_Printf( printStream, "\tVersion : %s\n", element->version );
}
-void constructorElementDeleteFunction( void *nodeData )
-{
- Stg_ComponentRegisterElement *element = NULL;
- element = (Stg_ComponentRegisterElement*) nodeData;
-
- if( element ){
- Memory_Free( element->componentType );
- Memory_Free( element->version );
- Memory_Free( element );
- }
-}
-
-typedef struct {
- Type type;
- float percentageSimilar;
-} Stg_ComponentRegister_SimilarityObject;
-
-typedef struct {
- Name nameToCompare;
- Index currentIndex;
- Stg_ComponentRegister_SimilarityObject* array;
-} Stg_ComponentRegister_SimilarityList;
-
-int _Stg_ComponentRegister_SimilarityCompare( const void *ptr1, const void *ptr2 ) {
- Stg_ComponentRegister_SimilarityObject* similarityPtr1 = (Stg_ComponentRegister_SimilarityObject*) ptr1;
- Stg_ComponentRegister_SimilarityObject* similarityPtr2 = (Stg_ComponentRegister_SimilarityObject*) ptr2;
-
- if ( similarityPtr1->percentageSimilar > similarityPtr2->percentageSimilar )
- return -1;
- else
- return 1;
-}
-
-void Stg_ComponentRegister_Similarity_Helper( void* nodeData, void* _list ) {
- Stg_ComponentRegisterElement* element = (Stg_ComponentRegisterElement*) nodeData;
- Stg_ComponentRegister_SimilarityList* list = (Stg_ComponentRegister_SimilarityList*) _list;
- Type componentType = element->componentType;
- float stringLength = (float) strlen( list->nameToCompare );
- float typeLength = (float) strlen( componentType );
- Index array_I = list->currentIndex;
- unsigned int substringLength;
-
- substringLength = Stg_LongestMatchingSubsequenceLength( componentType, list->nameToCompare, False );
- list->array[ array_I ].type = componentType;
- list->array[ array_I ].percentageSimilar = (float) substringLength * 100.0 / MAX( typeLength, stringLength );
-
- list->currentIndex++;
-}
void Stg_ComponentRegister_PrintSimilar( void* componentRegister, Name name, void* _stream, unsigned int number ) {
Stg_ComponentRegister* self = (Stg_ComponentRegister*) componentRegister;
- Stream* stream = (Stream*) _stream;
- Stg_ComponentRegister_SimilarityList similarityList;
- Stg_ComponentRegister_SimilarityObject* similarityObject;
- Index type_I;
- Index count = self->constructors->nodeCount;
-
- similarityList.nameToCompare = name;
- similarityList.currentIndex = 0;
- similarityList.array = Memory_Alloc_Array( Stg_ComponentRegister_SimilarityObject, count, "similarityArray");
-
- /* First parse the tree, calculating how similar the 'name' is to the types registered */
- BTree_ParseTree( self->constructors, Stg_ComponentRegister_Similarity_Helper, &similarityList );
-
- /* Sort list from most similar to least similar */
- qsort( similarityList.array, (size_t)count, sizeof( Stg_ComponentRegister_SimilarityObject ), _Stg_ComponentRegister_SimilarityCompare );
-
- /* Print out the first 'number' in list */
- if ( number > count )
- number = count;
- for ( type_I = 0 ; type_I < number ; type_I++ ) {
- similarityObject = &similarityList.array[ type_I ];
- Journal_Printf( stream, "%s (%.2f%% similar)\n", similarityObject->type, similarityObject->percentageSimilar );
- }
-
- Memory_Free( similarityList.array );
-}
-
-
-void constructorElementPrintTypeFunction( void* nodeData, void* printStream ) {
- Stg_ComponentRegisterElement* element = ( Stg_ComponentRegisterElement* ) nodeData;
- Stream* stream = (Stream*) printStream;
-
- assert( nodeData );
- assert( stream );
-
- Journal_Printf( stream, "%s\n", element->componentType );
+ Stg_ObjectList_PrintSimilar( self->constructors, name, _stream, number );
}
void Stg_ComponentRegister_PrintAllTypes( void* componentRegister, void* stream ) {
Stg_ComponentRegister* self = (Stg_ComponentRegister*) componentRegister;
- /* Parse the tree, printing all the names */
- BTree_ParseTree( self->constructors, constructorElementPrintTypeFunction, stream );
+ /* Parse the list, printing all the names */
+ int i;
+ Stg_ComponentRegisterElement* element;
+ for(i = 0; i < Stg_ComponentRegister_GetCount(self); i++) {
+ element = Stg_ComponentRegister_GetByIndex(self, i);
+ Journal_Printf( stream, "%s\n", element->componentType );
+ }
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Stg_ComponentRegister.h
--- a/Base/Automation/src/Stg_ComponentRegister.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/Stg_ComponentRegister.h Tue Jan 12 14:38:16 2010 +1100
@@ -37,8 +37,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_Stg_ComponentRegister_h__
-#define __Base_Automation_Stg_ComponentRegister_h__
+#ifndef __StGermain_Base_Automation_Stg_ComponentRegister_h__
+#define __StGermain_Base_Automation_Stg_ComponentRegister_h__
/* Textual name of this class */
extern const Type Stg_ComponentRegister_Type;
@@ -46,13 +46,33 @@
/*struct Stg_Component_DefaultConstructorFunction;*/
#define __Stg_ComponentRegisterElement \
+ __Stg_Object \
Type componentType; \
Stg_Component_DefaultConstructorFunction* defaultConstructor; \
Stg_Component_MetaAsDictionaryFunction* metadata; \
Name version;
struct Stg_ComponentRegisterElement{ __Stg_ComponentRegisterElement };
+
+ extern const Type Stg_ComponentRegisterElement_Type;
+
+ /** ComponentRegisterElement Constructor interface. */
+ Stg_ComponentRegisterElement* Stg_ComponentRegisterElement_New(
+ Type type,
+ Stg_Class_DeleteFunction* _delete,
+ Stg_Class_PrintFunction* _print,
+ Type componentType,
+ Stg_Component_DefaultConstructorFunction* defaultConstructor,
+ Stg_Component_MetaAsDictionaryFunction* metadata,
+ Name version
+ );
+ /** Stg_Class_Delete interface. */
+ void _Stg_ComponentRegisterElement_Delete( void* element );
+
+ /** Print interaface. */
+ void _Stg_ComponentRegisterElement_Print( void* element, Stream* paramStream );
+
/* Stg_ComponentRegister information */
#define __Stg_ComponentRegister \
/* General info */ \
@@ -61,19 +81,26 @@
/* Virtual info */ \
\
/* Stg_ComponentRegister info */ \
- BTree *constructors; \
+ Stg_ObjectList* constructors; \
+ Stream* debugStream; \
struct Stg_ComponentRegister { __Stg_ComponentRegister };
/* Class Administration members ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/** Constructor Implementation */
- Stg_ComponentRegister *_Stg_ComponentRegister_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STG_COMPONENTREGISTER_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define STG_COMPONENTREGISTER_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ Stg_ComponentRegister *_Stg_ComponentRegister_New( STG_COMPONENTREGISTER_DEFARGS );
Stg_ComponentRegister *Stg_ComponentRegister_New( );
@@ -114,6 +141,12 @@
Dictionary* componentType ##_Type_MetaAsDictionary(); \
Stg_ComponentRegister_AddFunc( self, componentType, version, func, componentType ##_MetaAsDictionary ); \
}
+
+ /* Remove and free a component in the register */
+ Bool Stg_ComponentRegister_RemoveEntry(
+ Stg_ComponentRegister* self,
+ Name componentType,
+ Name version );
Stg_Component_DefaultConstructorFunction* Stg_ComponentRegister_Get(
Stg_ComponentRegister* self,
@@ -143,16 +176,9 @@
Name version );
void Stg_ComponentRegister_PrintAllTypes( void* componentRegister, void* stream );
- /* Functions for iterating through the component element list ------------------------------------------------------------*/
-
- /** Obtain an iterator to the component element list */
- BTreeIterator* Stg_ComponentRegister_GetIterator();
-
- /** Initialise the iterator to the first component element in the list */
- Stg_ComponentRegisterElement* Stg_ComponentRegisterIterator_First( BTreeIterator* iterator );
-
- /** Step to the next component element in the list */
- Stg_ComponentRegisterElement* Stg_ComponentRegisterIterator_Next( BTreeIterator* iterator );
+ /* Functions for iterating through the component element list ---------------------------------------------------*/
+ int Stg_ComponentRegister_GetCount( void* componentRegister );
+ Stg_ComponentRegisterElement* Stg_ComponentRegister_GetByIndex( void* componentRegister, int index );
/** Obtain the component type from the component list element */
Type Stg_ComponentRegisterElement_GetType( Stg_ComponentRegisterElement* element );
@@ -166,4 +192,5 @@
/** Obtain the component metadata from the component list element */
Dictionary* Stg_ComponentRegisterElement_GetMetadata( Stg_ComponentRegisterElement* element );
-#endif /* __Base_Automation_Stg_ComponentRegister_h__ */
+#endif /* __StGermain_Base_Automation_Stg_ComponentRegister_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Variable.c
--- a/Base/Automation/src/Variable.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1224 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: Variable.c 4149 2007-06-29 06:59:13Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "shortcuts.h"
-#include "Stg_Component.h"
-#include "Stg_ComponentFactory.h"
-#include "LiveComponentRegister.h"
-#include "Variable.h"
-#include "Variable_Register.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <stdarg.h>
-#include <math.h>
-
-/* Textual name of this class */
-const Type Variable_Type = "Variable";
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-Variable* Variable_New(
- Name name,
- Index dataCount,
- SizeT* dataOffsets,
- Variable_DataType* dataTypes,
- Index* dataTypeCounts,
- Name* dataNames,
- SizeT* structSizePtr,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr )
-{
- Variable* self;
-
- self = _Variable_New(
- sizeof(Variable),
- Variable_Type,
- _Variable_Delete,
- _Variable_Print,
- _Variable_Copy,
- (Stg_Component_DefaultConstructorFunction*)Variable_DefaultNew,
- _Variable_Construct,
- _Variable_Build,
- _Variable_Initialise,
- _Variable_Execute,
- _Variable_Destroy,
- name,
- True,
- dataCount,
- dataOffsets,
- dataTypes,
- dataTypeCounts,
- dataNames,
- structSizePtr,
- arraySizePtr,
- arraySizeFunc,
- arrayPtrPtr,
- vr );
-
- return self;
-}
-
-Variable* Variable_DefaultNew( Name name )
-{
- Variable* self;
-
- self = _Variable_New(
- sizeof(Variable),
- Variable_Type,
- _Variable_Delete,
- _Variable_Print,
- _Variable_Copy,
- (Stg_Component_DefaultConstructorFunction*)Variable_DefaultNew,
- _Variable_Construct,
- _Variable_Build,
- _Variable_Initialise,
- _Variable_Execute,
- _Variable_Destroy,
- name,
- False,
- 0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL );
-
- return self;
-}
-
-Variable* Variable_NewScalar(
- Name name,
- Variable_DataType dataType,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr )
-{
- Variable* self;
- SizeT dataOffsets[] = { 0 };
- Variable_DataType dataTypes[] = { 0 }; /* Init value later */
- Index dataTypeCounts[] = { 1 };
-
- dataTypes[0] = dataType;
-
- self = _Variable_New(
- sizeof(Variable),
- Variable_Type,
- _Variable_Delete,
- _Variable_Print,
- _Variable_Copy,
- (Stg_Component_DefaultConstructorFunction*)Variable_DefaultNew,
- _Variable_Construct,
- _Variable_Build,
- _Variable_Initialise,
- _Variable_Execute,
- _Variable_Destroy,
- name,
- True,
- 1,
- dataOffsets,
- dataTypes,
- dataTypeCounts,
- 0, /* no component names */
- 0, /* means work out from dataType at build phase */
- arraySizePtr,
- arraySizeFunc,
- arrayPtrPtr,
- vr );
-
- return self;
-}
-
-Variable* Variable_NewVector(
- Name name,
- Variable_DataType dataType,
- Index dataTypeCount,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr,
- ... /* vector component names */ )
-{
- Variable* self;
- SizeT dataOffsets[] = { 0 };
- Variable_DataType dataTypes[] = { 0 }; /* Init later... */
- Index dataTypeCounts[] = { 0 }; /* Init later... */
- Name* dataNames;
- Index vector_I;
- va_list ap;
-
- dataTypes[0] = dataType;
- dataTypeCounts[0] = dataTypeCount;
-
- dataNames = Memory_Alloc_Array( Name, dataTypeCount, "dataNames" );
-
- va_start( ap, vr );
- for( vector_I = 0; vector_I < dataTypeCount; vector_I++ ) {
- dataNames[vector_I] = va_arg( ap, Name );
- }
- va_end( ap );
-
- self = _Variable_New(
- sizeof(Variable),
- Variable_Type,
- _Variable_Delete,
- _Variable_Print,
- _Variable_Copy,
- (Stg_Component_DefaultConstructorFunction*)Variable_DefaultNew,
- _Variable_Construct,
- _Variable_Build,
- _Variable_Initialise,
- _Variable_Execute,
- _Variable_Destroy,
- name,
- True,
- 1,
- dataOffsets,
- dataTypes,
- dataTypeCounts,
- dataNames,
- 0, /* means work out from dataType at build phase */
- arraySizePtr,
- arraySizeFunc,
- arrayPtrPtr,
- vr );
-
- Memory_Free( dataNames );
-
- return self;
-}
-
-Variable* Variable_NewVector2(
- Name name,
- Variable_DataType dataType,
- Index dataTypeCount,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr,
- char** dataNames )
-{
- Variable* self;
- SizeT dataOffsets[] = { 0 };
- Variable_DataType dataTypes[] = { 0 };
- Index dataTypeCounts[] = { 0 };
-
- dataTypes[0] = dataType;
- dataTypeCounts[0] = dataTypeCount;
-
- self = _Variable_New(
- sizeof(Variable),
- Variable_Type,
- _Variable_Delete,
- _Variable_Print,
- _Variable_Copy,
- (void*)Variable_DefaultNew,
- _Variable_Construct,
- _Variable_Build,
- _Variable_Initialise,
- _Variable_Execute,
- _Variable_Destroy,
- name,
- True,
- 1,
- dataOffsets,
- dataTypes,
- dataTypeCounts,
- dataNames,
- 0, /* means work out from dataType at build phase */
- arraySizePtr,
- arraySizeFunc,
- arrayPtrPtr,
- vr );
-
- return self;
-}
-
-
-void Variable_Init(
- Name name,
- Variable* self,
- Index dataCount,
- SizeT* dataOffsets,
- Variable_DataType* dataTypes,
- Index* dataTypeCounts,
- Name* dataNames,
- SizeT* structSizePtr,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Bool allocateSelf,
- Variable_Register* vr )
-{
- /* General info */
- self->type = Variable_Type;
- self->_sizeOfSelf = sizeof(Variable);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _Variable_Delete;
- self->_print = _Variable_Print;
- self->_copy = _Variable_Copy;
- self->_build = _Variable_Build;
- self->_initialise = _Variable_Initialise;
- self->_execute = _Variable_Execute;
-
- _Stg_Class_Init( (Stg_Class*)self );
- _Stg_Object_Init( (Stg_Object*)self, name, NON_GLOBAL );
- _Stg_Component_Init( (Stg_Component*)self );
- /* Variable info */
- _Variable_Init(
- self,
- dataCount,
- dataOffsets,
- dataTypes,
- dataTypeCounts,
- dataNames,
- structSizePtr,
- arraySizePtr,
- arraySizeFunc,
- arrayPtrPtr,
- allocateSelf,
- vr );
-}
-
-
-Variable* _Variable_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- Index dataCount,
- SizeT* dataOffsets,
- Variable_DataType* dataTypes,
- Index* dataTypeCounts,
- Name* dataNames,
- SizeT* structSizePtr,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr )
-{
- Variable* self;
-
- /* Allocate memory */
- assert( _sizeOfSelf >= sizeof(Variable) );
- self = (Variable*)_Stg_Component_New( _sizeOfSelf, type, _delete, _print, _copy, _defaultConstructor,
- _construct, _build, _initialise, _execute, _destroy, name, NON_GLOBAL );
-
- /* General info */
-
- /* Virtual info */
- self->_build = _build;
- self->_initialise = _initialise;
-
- /* Variable info */
- if( initFlag ){
- _Variable_Init(
- self,
- dataCount,
- dataOffsets,
- dataTypes,
- dataTypeCounts,
- dataNames,
- structSizePtr,
- arraySizePtr,
- arraySizeFunc,
- arrayPtrPtr,
- False,
- vr );
- }
-
- return self;
-}
-
-void _Variable_Init(
- Variable* self,
- Index dataCount,
- SizeT* dataOffsets,
- Variable_DataType* dataTypes,
- Index* dataTypeCounts,
- Name* dataNames,
- SizeT* structSizePtr,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Bool allocateSelf,
- Variable_Register* vr )
-{
- Stream* errorStream = Journal_Register( Error_Type, self->type );
-
- /* General and Virtual info should already be set */
-
- /* Variable info */
- self->isConstructed = True;
- self->allocateSelf = allocateSelf;
- self->offsetCount = dataCount;
- self->structSizePtr = structSizePtr;
- self->arraySizePtr = arraySizePtr;
- self->arraySizeFunc = arraySizeFunc;
- self->arrayPtrPtr = arrayPtrPtr;
- self->parent = NULL;
-
- /* Checks */
- Journal_Firewall( (self->arraySizePtr || self->arraySizeFunc) ,
- errorStream, "Error: in %s(), for Variable %s - either arraySizePtr or arraySizeFunc "
- "passed in must be non-NULL.\n", __func__, self->name );
-
- /* Use of this class has increased... can't assume the info arrays are on persistant memory... copy by default. They will
- be deleted. */
- Journal_Firewall( dataOffsets ? True : False, Journal_Register( Error_Type, Variable_Type ), "dataOffsets is null\n" );
- self->offsets = Memory_Alloc_Array( SizeT, self->offsetCount, "Variable->offsets" );
- memcpy( self->offsets, dataOffsets, sizeof(SizeT) * self->offsetCount );
-
- Journal_Firewall( dataTypes ? True : False, Journal_Register( Error_Type, Variable_Type ), "dataTypes is null\n" );
- self->dataTypes = Memory_Alloc_Array( Variable_DataType, self->offsetCount, "Variable->dataTypes" );
- memcpy( self->dataTypes, dataTypes, sizeof(Variable_DataType) * self->offsetCount );
-
- Journal_Firewall(
- dataTypeCounts ? True : False ,
- Journal_Register( Error_Type, Variable_Type ),
- "dataTypeCounts is null\n" );
- self->dataTypeCounts = Memory_Alloc_Array( Index, self->offsetCount, "Variable->dataTypeCounts" );
- memcpy( self->dataTypeCounts, dataTypeCounts, sizeof(Index) * self->offsetCount );
-
- /* These get set at the build phase (when we assume the variable's data memory has been allocated) */
- self->structSize = 0;
- self->arrayPtr = 0;
- self->dataSizes = 0;
-
- if ( dataNames && self->offsetCount == 1 && self->dataTypeCounts[0] > 1 ) {
- /* Vector case */
- self->subVariablesCount = self->dataTypeCounts[0];
- }
- else {
- /* Scalar or Complex case */
- self->subVariablesCount = self->offsetCount;
- }
- self->components = Memory_Alloc_Array( Variable*, self->subVariablesCount, "Variable->components" );
- memset( self->components, 0, sizeof(Variable*) * self->subVariablesCount );
-
- /* If the variable register is provided, add this and component variable(s) to the register */
- if( vr ) {
- self->vr = vr;
- Variable_Register_Add( vr, self );
-
- /* If we have component names, create the associated variables. Don't do if there is only one component. */
- if( dataNames && self->offsetCount > 1 ) {
- Index component_I;
-
- for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
- if( dataNames[component_I] ) {
- SizeT componentOffsets[] = { 0 };
- Variable_DataType componentTypes[] = { 0 };
- Index componentTypeCounts[] = { 0 };
-
- componentOffsets[0] = self->offsets[component_I];
- componentTypes[0] = self->dataTypes[component_I];
- componentTypeCounts[0] = self->dataTypeCounts[component_I];
-
- /* Assumption: components are scalar or vector, but cannot be complex */
- self->components[component_I] = Variable_New(
- dataNames[component_I],
- 1,
- componentOffsets,
- componentTypes,
- componentTypeCounts,
- 0,
- self->structSizePtr,
- self->arraySizePtr,
- self->arraySizeFunc,
- self->arrayPtrPtr,
- vr );
- self->components[component_I]->parent = self;
- }
- }
- }
- /* Else if we have vector-component names, create the associated variables. Do only if non-complex and a vector. */
- else if( dataNames && self->offsetCount == 1 && self->dataTypeCounts[0] > 1 ) {
- Index vector_I;
-
- for( vector_I = 0; vector_I < self->dataTypeCounts[0]; vector_I++ ) {
- if( dataNames[vector_I] ) {
- /* Unfortunately we cannot call any of our fancy macros here as the array is not resolved
- * yet. As a consequence we have to manually work out the vector's indecis offsets. Ouch
- * only from a code-maintenance point of view. */
- SizeT componentOffsets[] = { 0 }; /* Init later... */
- Variable_DataType componentTypes[] = { 0 }; /* Init later... */
- Index componentTypeCounts[] = { 1 };
-
- componentOffsets[0] =
- (ArithPointer)self->offsets[0] +
- ( self->dataTypes[0] == Variable_DataType_Char ? ( sizeof(char) * vector_I ) :
- self->dataTypes[0] == Variable_DataType_Short ? ( sizeof(short) * vector_I ) :
- self->dataTypes[0] == Variable_DataType_Int ? ( sizeof(int) * vector_I ) :
- self->dataTypes[0] == Variable_DataType_Float ? ( sizeof(float) * vector_I ) :
- self->dataTypes[0] == Variable_DataType_Double ? ( sizeof(double) * vector_I ) :
- self->dataTypes[0] == Variable_DataType_Pointer ? ( sizeof(void*) * vector_I ) :
- Journal_Firewall(
- 0,
- Journal_Register( Error_Type, Variable_Type ),
- "Vector is of a non-builtin type\n" ) );
- componentTypes[0] = self->dataTypes[0];
-
-
- /* Assumption: vector-components are scalar, but cannot be complex */
- self->components[vector_I] = Variable_New(
- dataNames[vector_I],
- 1,
- componentOffsets,
- componentTypes,
- componentTypeCounts,
- 0,
- self->structSizePtr,
- self->arraySizePtr,
- self->arraySizeFunc,
- self->arrayPtrPtr,
- vr );
- self->components[vector_I]->parent = self;
- }
- }
- }
- }
- else {
- self->vr = NULL;
- }
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _Variable_Delete( void* variable ) {
- Variable* self = (Variable*)variable;
-
- if ( self->dataSizes ) {
- Memory_Free( self->dataSizes );
- }
- if (self->allocateSelf) {
- Memory_Free( self->arrayPtr );
- }
-
- Memory_Free( self->dataTypeCounts );
- Memory_Free( self->dataTypes );
- Memory_Free( self->offsets );
- Memory_Free( self->components );
-
- /* Stg_Class_Delete parent */
- _Stg_Component_Delete( self );
-}
-
-
-void _Variable_Print( void* variable, Stream* stream ) {
- Variable* self = (Variable*)variable;
- Index component_I;
-
- /* Print parent */
- _Stg_Component_Print( self, stream );
-
- /* General info */
- Journal_Printf( stream, "Variable (ptr): (%p)\n", self );
-
- /* Virtual info */
-
- /* Variable info */
- Journal_Printf( stream, "\toffsetCount: %u\n", self->offsetCount );
-
- Journal_Printf( stream, "\toffsets (ptr): %p\n", self->offsets );
- for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
- Journal_Printf( stream, "\t\toffsets[%u]: %lu\n", component_I, self->offsets[component_I] );
- }
-
- Journal_Printf( stream, "\tdataTypes (ptr): %p\n", self->dataTypes );
- for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
- Journal_Printf( stream, "\t\tdataTypes[%u]: %lu\n", component_I, self->dataTypes[component_I] );
- }
-
- Journal_Printf( stream, "\tdataTypeCounts (ptr): %p\n", self->dataTypeCounts );
- for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
- Journal_Printf( stream, "\t\tdataTypeCounts[%u]: %lu\n", component_I, self->dataTypeCounts[component_I] );
- }
-
- Journal_Printf( stream, "\tdataSizes (ptr): %p\n", self->dataSizes );
- for( component_I = 0; component_I < self->offsetCount && self->dataSizes; component_I++ ) {
- Journal_Printf( stream, "\t\tdataSizes[%u]: %lu\n", component_I, self->dataSizes[component_I] );
- }
-
- Journal_Printf( stream, "\tcomponents (ptr): %p\n", self->components );
- for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
- Journal_Printf( stream, "\t\tcomponents[%u] (ptr): %p\n", component_I, self->components[component_I] );
- if( self->components[component_I] ) {
- Journal_Printf( stream, "\t\tcomponents[%u]: %s\n", component_I, self->components[component_I]->name );
- }
- }
-
- Journal_Printf( stream, "\tstructSize: %lu\n", self->structSize );
- Journal_Printf( stream, "\tstructSizePtr (ptr): %p\n", self->structSizePtr );
-
- Journal_Printf( stream, "\tarrayPtr (ptr): %p\n", self->arrayPtr );
- Journal_Printf( stream, "\tarrayPtrPtr (ptr): %p\n", self->arrayPtrPtr );
-
- Journal_Printf( stream, "\tarraySize: %lu\n", _Variable_GetNewArraySize( self ) );
- Journal_Printf( stream, "\tarraySizePtr (ptr): %p\n", self->arraySizePtr );
- Journal_Printf( stream, "\tarraySizeFunc (ptr): %p\n", self->arraySizeFunc );
-
- Journal_Printf( stream, "\tallocateSelf = %s\n", self->allocateSelf ? "True" : "False" );
-}
-
-
-void* _Variable_Copy( void* variable, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
- Variable* self = (Variable*)variable;
- Variable* newVariable;
- PtrMap* map = ptrMap;
-
- newVariable = (Variable*)_Stg_Component_Copy( self, dest, deep, nameExt, map );
- PtrMap_Append( map, self, newVariable );
-
- /* virtual methods */
- newVariable->offsetCount = self->offsetCount;
- newVariable->structSize = self->structSize;
- newVariable->arraySizePtr = self->arraySizePtr;
- newVariable->arraySizeFunc = self->arraySizeFunc;
-
- newVariable->allocateSelf = self->allocateSelf; /* This may change depending on whether arrayPtr is found in map */
-
- /* single valued members */
-
- if( deep ) {
- if( (newVariable->offsets = PtrMap_Find( map, self->offsets )) == NULL && self->offsets != NULL ) {
- newVariable->offsets = Memory_Alloc_Array( SizeT, newVariable->offsetCount, "Variable->offsets" );
- memcpy( newVariable->offsets, self->offsets, sizeof(SizeT) * newVariable->offsetCount );
- PtrMap_Append( map, self->offsets, newVariable->offsets );
- }
-
- if( (newVariable->dataTypes = PtrMap_Find( map, self->dataTypes )) == NULL && self->offsets != NULL ) {
- newVariable->dataTypes = Memory_Alloc_Array( Variable_DataType, newVariable->offsetCount, "Variable->dataTypes" );
- memcpy( newVariable->dataTypes, self->dataTypes, sizeof(Variable_DataType) * newVariable->offsetCount );
- PtrMap_Append( map, self->dataTypes, newVariable->dataTypes );
- }
-
- if( (newVariable->dataTypeCounts = PtrMap_Find( map, self->dataTypeCounts )) == NULL && self->dataTypeCounts != NULL ) {
- newVariable->dataTypeCounts = Memory_Alloc_Array( Index, newVariable->offsetCount, "Variable->dataTypeCounts" );
- memcpy( newVariable->dataTypeCounts, self->dataTypeCounts, sizeof(Index) * newVariable->offsetCount );
- PtrMap_Append( map, self->dataTypeCounts, newVariable->dataTypeCounts );
- }
-
- if ( self->structSizePtr != NULL ) {
- if( (newVariable->structSizePtr = PtrMap_Find( map, self->structSizePtr )) == NULL ) {
- newVariable->structSizePtr = Memory_Alloc_Array(
- SizeT,
- 1,
- "Variable->structSizePtr" );
- memcpy( newVariable->structSizePtr, self->structSizePtr, sizeof(SizeT) );
- PtrMap_Append( map, self->structSizePtr, newVariable->structSizePtr );
- }
- }
- else {
- newVariable->structSizePtr = NULL;
- }
-
- if ( self->arraySizePtr != NULL ) {
- if( (newVariable->arraySizePtr = PtrMap_Find( map, self->arraySizePtr )) == NULL ) {
- newVariable->arraySizePtr = Memory_Alloc_Array(
- Index,
- 1,
- "Variable->arraySizePtr" );
- memcpy( newVariable->arraySizePtr, self->arraySizePtr, sizeof(Index) );
- PtrMap_Append( map, self->arraySizePtr, newVariable->arraySizePtr );
- }
- }
- else {
- newVariable->arraySizeFunc = NULL;
- }
- if ( self->arraySizeFunc != NULL ) {
- if( (newVariable->arraySizeFunc = PtrMap_Find( map, self->arraySizeFunc )) == NULL ) {
- newVariable->arraySizeFunc = Memory_Alloc_Array(
- Variable_ArraySizeFunc,
- 1,
- "Variable->arraySizeFunc" );
- memcpy( newVariable->arraySizeFunc, self->arraySizeFunc, sizeof(Index) );
- PtrMap_Append( map, self->arraySizeFunc, newVariable->arraySizeFunc );
- }
- }
- else {
- newVariable->arraySizeFunc = NULL;
- }
-
- if( (newVariable->dataSizes = PtrMap_Find( map, self->dataSizes )) == NULL && self->dataSizes != NULL ) {
- newVariable->dataSizes = Memory_Alloc_Array( SizeT, newVariable->offsetCount, "Variable->dataSizes" );
- memcpy( newVariable->dataSizes, self->dataSizes, sizeof(SizeT) * newVariable->offsetCount );
- PtrMap_Append( map, self->dataSizes, newVariable->dataSizes );
- }
-
- if( (newVariable->arrayPtrPtr = PtrMap_Find( map, self->arrayPtrPtr )) == NULL && self->arrayPtrPtr != NULL ) {
- if( (newVariable->arrayPtr = PtrMap_Find( map, self->arrayPtr )) == NULL && self->arrayPtr != NULL ) {
- Index memoryToAllocSize = _Variable_GetNewArraySize( self ) * self->structSize;
- newVariable->arrayPtr = Memory_Alloc_Bytes(
- memoryToAllocSize,
- Variable_Type,
- "SelfAllocedArray" );
- memcpy( newVariable->arrayPtr, self->arrayPtr, memoryToAllocSize );
- PtrMap_Append( map, self->arrayPtr, newVariable->arrayPtr );
-
- newVariable->arrayPtrPtr = &(newVariable->arrayPtr);
- newVariable->allocateSelf = True;
- }
- }
- else {
- newVariable->arrayPtr = *newVariable->arrayPtrPtr;
- memcpy( newVariable->arrayPtr, self->arrayPtr, _Variable_GetNewArraySize(self) * self->structSize );
- }
-
- if( (newVariable->components = PtrMap_Find( map, self->components )) == NULL && self->components != NULL ) {
- Index comp_I;
-
- if( newVariable->offsetCount == 1 && newVariable->dataTypeCounts[0] > 1 ) {
- /* Vector case */
- newVariable->components = Memory_Alloc_Array(
- Variable*,
- newVariable->dataTypeCounts[0],
- "Variable->components" );
- memset( newVariable->components, 0, sizeof(Variable*) * newVariable->dataTypeCounts[0] );
-
- for( comp_I = 0; comp_I < newVariable->dataTypeCounts[0]; comp_I++ ) {
- newVariable->components[comp_I] = (Variable*)Stg_Class_Copy(
- self->components[comp_I],
- NULL,
- deep,
- nameExt,
- map );
- }
- }
- else {
- /* Scalar or Complex case */
- newVariable->components = Memory_Alloc_Array(
- Variable*,
- newVariable->offsetCount,
- "Variable->components" );
- memset( newVariable->components, 0, sizeof(Variable*) * newVariable->offsetCount );
-
- for( comp_I = 0; comp_I < newVariable->offsetCount; comp_I++ ) {
- if ( self->components[comp_I] ) {
- newVariable->components[comp_I] = (Variable*)Stg_Class_Copy(
- self->components[comp_I],
- NULL,
- deep,
- nameExt,
- map );
- }
- }
- }
-
- PtrMap_Append( map, self->components, newVariable->components );
- }
-
- if ( self->vr ) {
- newVariable->vr = Stg_Class_Copy( self->vr, NULL, deep, nameExt, map );
- }
- }
- else {
- fprintf( stderr, "Warning: please don't shallow copy variables yet...or ever!\n" );
- }
-
- return (void*)newVariable;
-}
-
-
-void _Variable_Build( void* variable, void* data ) {
- Variable* self = (Variable*)variable;
- Index component_I;
- Index subVariable_I;
-
- if( self->parent ) {
- /* We need to build the parent first, as it may initialise data structures needed
- * by this Variable. BUT, the parent will call Build() on all it's sub-Variables
- * including this one, so we need to avoid an infinite loop. */
- self->isBuilt = True;
- Stg_Component_Build( self->parent, NULL, False );
- self->isBuilt = False;
- }
-
- /* Obtain the actual array size, and array pointer */
- Journal_Firewall(
- ( self->arraySizeFunc || self->arraySizePtr )? True : False,
- Journal_Register( Error_Type, Variable_Type ),
- "arraySizePtr && arraySizeFunc is null\n" );
- self->arraySize = _Variable_GetNewArraySize( self );
-
-
- /* Work out the actual data sizes from the data types */
- if( self->dataSizes ) {
- Memory_Free( self->dataSizes );
- }
- self->dataSizes = Memory_Alloc_Array( SizeT, self->offsetCount, "Variable->dataSizes" );
- for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
- switch ( self->dataTypes[component_I] ) {
- case Variable_DataType_Variable:
- Journal_Firewall(
- self->dataTypes[component_I] != Variable_DataType_Variable,
- Journal_Register( Error_Type, Variable_Type ),
- "\"dataType[?] == Variable_DataType_Variables\" not yet implemented\n" );
- break;
- case Variable_DataType_Char:
- self->dataSizes[component_I] = sizeof( char ) * self->dataTypeCounts[component_I];
- break;
- case Variable_DataType_Short:
- self->dataSizes[component_I] = sizeof( short ) * self->dataTypeCounts[component_I];
- break;
- case Variable_DataType_Int:
- self->dataSizes[component_I] = sizeof( int ) * self->dataTypeCounts[component_I];
- break;
- case Variable_DataType_Float:
- self->dataSizes[component_I] = sizeof( float ) * self->dataTypeCounts[component_I];
- break;
- case Variable_DataType_Double:
- self->dataSizes[component_I] = sizeof( double ) * self->dataTypeCounts[component_I];
- break;
- case Variable_DataType_Pointer:
- self->dataSizes[component_I] = sizeof( void* ) * self->dataTypeCounts[component_I];
- break;
- default:
- Journal_Firewall(
- self->dataTypes[component_I] >= Variable_DataType_Size,
- Journal_Register( Error_Type, Variable_Type ),
- "\"dataType[?]\" is unrecognised\n" );
- break;
- }
- }
-
- /* Non-complex variables: Scalar & Vector can workout struct size for themselves.
- * Now that we know all the data sizes, work out the actual struct size (which may need the data sizes) */
- if( self->offsetCount == 1 && !self->structSizePtr ) {
- /* Vector and Scalars which are not apart of a Vector can work out their own size */
- if ( self->structSize == 0 ) {
- self->structSize = self->dataSizes[0];
- }
-
- /* If this is a vector, set its sub variables to the same struct size */
- if ( self->dataTypeCounts[0] > 1 ) {
- for ( subVariable_I = 0; subVariable_I < self->dataTypeCounts[0]; ++subVariable_I ) {
- if ( self->components[subVariable_I] ) {
- self->components[subVariable_I]->structSize = self->structSize;
- }
- else
- /* break here because if one subVariable isn't allocated - then the rest shouldn't be */
- break;
- }
- }
- }
- else {
- Journal_Firewall(
- self->structSizePtr ? True: False,
- Journal_Register( Error_Type, Variable_Type ),
- "structSizePtr is null\n" );
- self->structSize = *self->structSizePtr;
- }
-
- if (self->allocateSelf) {
- Index memoryToAllocSize = _Variable_GetNewArraySize( self ) * self->structSize;
- Index subVariable_I;
-
- Journal_Firewall( self->offsetCount == 1,
- Journal_Register( Error_Type, Variable_Type ),
- "Variable '%s' has 'offsetCount = %u', which should be 1 for self allocation.\n",
- self->name, self->offsetCount );
-
- self->arrayPtr = Memory_Alloc_Bytes( memoryToAllocSize, Variable_Type, "SelfAllocedArray" );
- memset( self->arrayPtr, 0, memoryToAllocSize );
-
- /* If this is a vector then set arrayPtr to be the same for each element of the vector */
- if ( self->dataTypeCounts[0] > 1 ) {
- for ( subVariable_I = 0 ; subVariable_I < self->dataTypeCounts[0] ; subVariable_I++ ) {
- if ( self->components[subVariable_I] ) {
- self->components[ subVariable_I ]->arrayPtr = self->arrayPtr;
- self->components[ subVariable_I ]->arrayPtrPtr = &self->arrayPtr;
- }
- else {
- /* break here because if one subVariable isn't allocated - then the rest shouldn't be */
- break;
- }
- }
- }
- }
- else {
- Journal_Firewall(
- self->arrayPtrPtr ? True : False,
- Journal_Register( Error_Type, Variable_Type ),
- "Variable '%s' has NULL arrayPtrPtr\n", self->name );
- self->arrayPtr = *self->arrayPtrPtr;
- }
-
- /* Lastly, build all components. It is reasonable if the user calls Build on "velocity", then
- * "velocity-x" etc are automatically build also. */
- for ( subVariable_I = 0; subVariable_I < self->subVariablesCount; subVariable_I++ ) {
- if ( self->components[subVariable_I] ) {
- /*Components now call Build on the parent, so if the parent is calling first,
- * need to avoid infinite recursion. */
- self->isBuilt = True;
- Stg_Component_Build( self->components[subVariable_I], data, False );
- self->isBuilt = False;
- }
- }
-}
-
-
-void _Variable_Initialise( void* variable, void* data ) {
- Variable* self = (Variable*)variable;
- Index subVariable_I;
-
- for ( subVariable_I = 0; subVariable_I < self->subVariablesCount; subVariable_I++ ) {
- if ( self->components[subVariable_I] ) {
- Stg_Component_Initialise( self->components[subVariable_I], data, False );
- }
- }
-}
-
-
-void _Variable_Execute( void* variable, void* data ) {
-}
-
-void _Variable_Construct( void* variable, Stg_ComponentFactory* cf, void* data ) {
- Variable* self = (Variable*) variable;
- SizeT dataOffsets[] = { 0 };
- Variable_DataType dataTypes[] = { 0 }; /* Init value later */
- Index dataTypeCounts[] = { 1 };
- Dictionary * componentDict = NULL;
- Dictionary * thisComponentDict = NULL;
- Name dataTypeName = NULL;
- Name rankName = NULL;
- Name countName = NULL;
- unsigned int* count = NULL;
- void * variableRegister = NULL;
- void * pointerRegister = NULL;
- Name* names = NULL;
- Stream* error = Journal_Register( Error_Type, self->type );
-
- assert( self );
-
- componentDict = cf->componentDict;
- assert( componentDict );
- thisComponentDict = Dictionary_GetDictionary( componentDict, self->name );
- assert( thisComponentDict );
-
- /* Grab Registers */
- variableRegister = Stg_ObjectList_Get( cf->registerRegister, "Variable_Register" );
- assert( variableRegister );
- pointerRegister = Stg_ObjectList_Get( cf->registerRegister, "Pointer_Register" );
- assert( pointerRegister );
-
- Stg_ComponentFactory_ConstructByKey( cf, self->name, "Dependency", Stg_Component, False, data );
-
- /* Get Pointer to number of elements in array */
- countName = Dictionary_GetString( thisComponentDict, "Count" );
- count = Stg_ObjectList_Get( pointerRegister, countName );
- assert( count );
-
- /* Get Type of Variable */
- dataTypeName = Dictionary_GetString( thisComponentDict, "DataType" );
- if ( !strcasecmp( dataTypeName, "Double" ) )
- dataTypes[0] = Variable_DataType_Double;
- else if ( !strcasecmp( dataTypeName, "Float" ) )
- dataTypes[0] = Variable_DataType_Float;
- else if ( !strcasecmp( dataTypeName, "Int" ) )
- dataTypes[0] = Variable_DataType_Int;
- else if ( !strcasecmp( dataTypeName, "Char" ) )
- dataTypes[0] = Variable_DataType_Char;
- else if ( !strcasecmp( dataTypeName, "Short" ) )
- dataTypes[0] = Variable_DataType_Short;
- else
- Journal_Firewall( False, error, "Variable '%s' cannot understand data type '%s'\n", self->name, dataTypeName );
-
- /* Get Rank of Variable - i.e. Scalar or Vector */
- rankName = Dictionary_GetString( thisComponentDict, "Rank" );
- if( !strcasecmp( rankName, "Scalar" ) ){
- dataTypeCounts[0] = 1;
- }
- else if ( !strcasecmp( rankName, "Vector" ) ){
- Dictionary_Entry_Value* list;
- Index nameCount = 0;
-
- /* Get Names from list */
- if (( list = Dictionary_Get( thisComponentDict, "names" ) )) {
- Index entry_I;
-
- nameCount = Dictionary_Entry_Value_GetCount( list );
- names = Memory_Alloc_Array( Name, nameCount, "Variable Names" );
-
- for ( entry_I = 0 ; entry_I < nameCount ; entry_I++ )
- names[ entry_I ] = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement(list, entry_I ) );
- }
- dataTypeCounts[0] = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, "VectorComponentCount", nameCount );
-
- Journal_Firewall( nameCount >= dataTypeCounts[0], error,
- "Variable '%s' has too few names in list for %d vector components.\n", self->name, dataTypeCounts[0] );
- }
- else
- Journal_Firewall( False, error, "Variable '%s' cannot understand rank '%s'\n", self->name, rankName );
-
- _Variable_Init(
- self,
- 1,
- dataOffsets,
- dataTypes,
- dataTypeCounts,
- names,
- 0,
- count,
- NULL, /* Note: don't support arraySize being calculated from a Func Ptr through
- Construct() Yet - PatrickSunter, 29 Jun 2007 */
- (void**)&self->arrayPtr,
- True,
- variableRegister );
-
- /* Clean Up */
- if (names)
- Memory_Free(names);
-}
-
-void _Variable_Destroy( void* variable, void* data )
-{
-
-}
-
-Index _Variable_GetNewArraySize( Variable* self ) {
- Index arraySize = 0;
-
- /* By default, we will try the simple ptr approach. */
- if ( NULL != self->arraySizePtr ) {
- arraySize = (*self->arraySizePtr);
- }
- else {
- /* If that was NULL, we expect the arraySizeFunc to be set */
-
- /* Because of the way sub-variables are constructed, they will use their parent's
- * arraySizePtr function (eg in the case of "vx", we want it to use the parent
- * Velocity MeshVariable's function to calculate the
- * size of the mesh.
- */
- if ( NULL != self->parent ) {
- arraySize = (*self->arraySizeFunc)( self->parent );
- }
- else {
- arraySize = (*self->arraySizeFunc)( self );
- }
- }
-
- return arraySize;
-}
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void Variable_SetValue( void* variable, Index array_I, void* value ) {
- Variable* self = (Variable*)variable;
- ArithPointer* vPtr;
- Index component_I;
-
- vPtr = value;
- for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
- memcpy( _Variable_GetPtr( self, array_I, component_I, 0 ), (void*)vPtr, self->dataSizes[component_I] );
-
- vPtr += self->dataSizes[component_I];
- }
-}
-
-
-void Variable_GetValue( void* variable, Index array_I, void* value ) {
- Variable* self = (Variable*)variable;
- ArithPointer* vPtr;
- Index component_I;
-
- vPtr = value;
- for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
- memcpy( (void*)vPtr, _Variable_GetPtr( self, array_I, component_I, 0 ), self->dataSizes[component_I] );
-
- vPtr += self->dataSizes[component_I];
- }
-}
-
-void Variable_Update( void* variable ) {
- Variable* self = (Variable*)variable;
-
- /* array may have resized, assign local properties again */
- self->arrayPtr = *self->arrayPtrPtr;
- self->arraySize = _Variable_GetNewArraySize( self );
-
- if( !( self->offsetCount == 1 && !self->structSizePtr ) ) {
- /* For non-scalar or non-vector variables, the targets may have been extended. */
- self->structSize = *self->structSizePtr;
- }
-}
-
-void Variable_SetValueDoubleAll( void* variable, double value ) {
- Variable* self = (Variable*) variable;
- Index arraySize = self->arraySize;
- Index array_I;
-
- for ( array_I = 0 ; array_I < arraySize ; array_I++ )
- Variable_SetValueDouble( self, array_I, value );
-}
-
-
-void Variable_SaveToFileAsDoubles( void* variable, char* filename ) {
- Variable* self = (Variable*) variable;
- Index arraySize = self->arraySize;
- Index array_I;
- double value;
- FILE* outputFile;
- Index comp_I;
-
- outputFile = fopen( filename, "w" );
-
- for ( array_I = 0 ; array_I < arraySize ; array_I++ ) {
- if ( *self->dataTypeCounts > 1 ) {
- for ( comp_I = 0; comp_I < *self->dataTypeCounts; comp_I++ ) {
- value = Variable_GetValueAtDouble( self, array_I, comp_I );
- fwrite( &value, sizeof(double), 1, outputFile );
- }
- }
- else {
- value = Variable_GetValueDouble( self, array_I );
- fwrite( &value, sizeof(double), 1, outputFile );
- }
-
- }
-
- fclose( outputFile );
-}
-
-
-void Variable_ReadFromFileAsDoubles( void* variable, char* filename ) {
- Variable* self = (Variable*) variable;
- Index arraySize = self->arraySize;
- Index array_I;
- double value;
- FILE* inputFile;
- Index comp_I;
-
- inputFile = fopen( filename, "r" );
-
- for ( array_I = 0 ; array_I < arraySize ; array_I++ ) {
- if ( *self->dataTypeCounts > 1 ) {
- for ( comp_I = 0; comp_I < *self->dataTypeCounts; comp_I++ ) {
- fread( &value, sizeof(double), 1, inputFile );
- Variable_SetValueAtDouble( self, array_I, comp_I, value );
- }
- }
- else {
- fread( &value, sizeof(double), 1, inputFile );
- Variable_SetValueDouble( self, array_I, value );
- }
- }
-
- fclose( inputFile );
-}
-
-
-/** Returns || variable - comparison || / || variable ||,
- * where ||x|| indicates the Euclidean Norm which is the square root of the sum of the squares for each component in x
- * i.e. ||x|| = \sqrt{\sum_i x_i^2}*/
-double Variable_ValueCompare( void* variable, void* _comparison ) {
- Variable* self = (Variable*) variable;
- Variable* comparison = (Variable*) _comparison;
- Index arraySize = self->arraySize;
- Index dataTypeCounts = *self->dataTypeCounts;
- Index array_I;
- Index component_I;
- double differenceValue;
- double selfValue;
- double normDifference = 0.0;
- double normVariable = 0.0;
- Stream* error = Journal_Register( Error_Type, self->type );
-
- /* Simple Error Checking */
- Journal_Firewall( arraySize == comparison->arraySize, error,
- "In func %s: Array sizes different for variables '%s' and '%s'\n", __func__, self->name, comparison->name );
- Journal_Firewall( dataTypeCounts == *comparison->dataTypeCounts, error,
- "In func %s: Data Type Counts different for variables '%s' and '%s'\n", __func__, self->name,comparison->name);
-
- for ( component_I = 0 ; component_I < self->offsetCount ; component_I++ ) {
- Journal_Firewall( self->dataTypes[component_I] == Variable_DataType_Double, error,
- "In func %s: Stg_Component %d of variable '%s' has different type to Variable_DataType_Double.\n",
- __func__, component_I, self->name );
- Journal_Firewall( comparison->dataTypes[component_I] == Variable_DataType_Double, error,
- "In func %s: Stg_Component %d of variable '%s' has different type to Variable_DataType_Double.\n",
- __func__, component_I, comparison->name );
- }
-
- /* Calculate Euclidean Norms */
- for ( array_I = 0 ; array_I < arraySize ; array_I++ ) {
- for ( component_I = 0 ; component_I < dataTypeCounts ; component_I++ ) {
- selfValue = Variable_GetValueAtDouble( self, array_I, component_I );
- differenceValue = selfValue - Variable_GetValueAtDouble( comparison, array_I, component_I );
-
- normDifference += differenceValue * differenceValue;
- normVariable += selfValue * selfValue;
- }
- }
-
- normDifference = sqrt( normDifference );
- normVariable = sqrt( normVariable );
-
- return normDifference/normVariable;
-}
-
-/** Checks whether || variable - comparison || / || variable || < tolerance */
-Bool Variable_ValueCompareWithinTolerance( void* variable, void* comparison, double tolerance ) {
- return ( Variable_ValueCompare( variable, comparison ) < tolerance );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Variable.h
--- a/Base/Automation/src/Variable.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1232 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-/** \file
-** <b>Role:</b>
-** A Variable associates a textual name to a field(s) in an array of structures.
-**
-** <b>Assumptions:</b>
-** None
-**
-** <b>Comments:</b>
-** None
-**
-** <b>Description</b>
-** Variable is used to group a field of a structure inside an array so that functions and algorithms can be solely
-** applied to this member. This allows more dynamic library routines possible.
-**
-** For example in an array of coordinates {x, y, z} a Variable can be created to represent "x".
-**
-** Note that Variables can be applied to any piece of contiguous memory.
-**
-** $Id: Variable.h 4149 2007-06-29 06:59:13Z PatrickSunter $
-**
-**/
-
-#ifndef __Base_Automation_Variable_h__
-#define __Base_Automation_Variable_h__
-
- /** Textual name for Variable class. */
- extern const Type Variable_Type;
-
- typedef enum {
- Variable_DataType_Variable,
- Variable_DataType_Char,
- Variable_DataType_Short,
- Variable_DataType_Int,
- Variable_DataType_Float,
- Variable_DataType_Double,
- Variable_DataType_Pointer,
- Variable_DataType_Size /* Marker for derivatives to enum */
- } Variable_DataType;
-
- typedef Index (Variable_ArraySizeFunc) ( void* self );
-
- /* See Variable */
- #define __Variable \
- /* General info */ \
- __Stg_Component \
- \
- /* Virtual info */ \
- \
- /* Variable info */ \
- Index offsetCount; /**< Number of fields in this variable. */ \
- SizeT* offsets; /**< The offset in bytes these fields are in the struct.*/ \
- Variable_DataType* dataTypes; /**< A list of original data types. */ \
- Index* dataTypeCounts; /**< A list of the number of data. */ \
- SizeT* structSizePtr; /**< A pointer to the size of the structure. */ \
- void** arrayPtrPtr; /**< A pointer to a pointer to the 1D array data. */ \
- Index* arraySizePtr; /**< A ptr to the size/count of the 1D array data. Note that if this is NULL, the arraySizeFunc will be used */ \
- Variable_ArraySizeFunc* arraySizeFunc; /**< A func ptr to the size/count of the 1D array data. */ \
- \
- SizeT* dataSizes; /**< The size in bytes of each field in this variable. */ \
- SizeT structSize; /**< The size of the structure. */ \
- void* arrayPtr; /**< A pointer to the 1D array of structures. */ \
- Index arraySize; /**< The size/count of the 1D array of structures. */ \
- Index subVariablesCount; /**< The number of subvariables. Necessary since determined by whether user passes in names or not at init time. */ \
- Variable** components; /**< For each component of this variable that we made a variable for, the pointer to the variable. */ \
- Bool allocateSelf; \
- Variable_Register* vr; \
- \
- Variable* parent;
-
- struct _Variable { __Variable };
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructors
- */
-
- #define VARIABLE_DEFARGS \
- STG_CLASS_DEFARGS, \
- Stg_Component_DefaultConstructorFunction* _defaultConstructor, \
- Stg_Component_ConstructFunction* _construct, \
- Stg_Component_BuildFunction* _build, \
- Stg_Component_InitialiseFunction* _initialise, \
- Stg_Component_ExecuteFunction* _execute, \
- Stg_Component_DestroyFunction* _destroy, \
- Name name, \
- Bool initFlag, \
- Index dataCount, \
- SizeT* dataOffsets, \
- Variable_DataType* dataTypes, \
- Index* dataTypeCounts, \
- Name* dataNames, \
- SizeT* structSizePtr, \
- Index* arraySizePtr, \
- Variable_ArraySizeFunc* arraySizeFunc, \
- void** arrayPtrPtr, \
- Variable_Register* vr
-
- #define VARIABLE_PASSARGS \
- STG_CLASS_PASSARGS, _defaultConstructor, _construct, \
- _build, _initialise, _execute, _destroy, name, initFlag, \
- dataCount, dataOffsets, dataTypes, dataTypeCounts, \
- dataNames, structSizePtr, arraySizePtr, arraySizeFunc, \
- arrayPtrPtr, vr
-
- /** Creates a new Variable. A Variable holds the run-time information of a complex data type created by the programmer.
- * Essentially it associates a textual name to a variable in the program that the user can use to access or modify.
- *
- * For example, if the program has an array of doubles that stores temperature, a Variable can be created with the name
- * "temperature", which will know how to access any item of this array. This name can then be added to a list of variables
- * to dump, where the code doing so has at compile-time has no idea about the existance of this variable.
- *
- * This constructor is the most complex, allowing the captured data to be a composition of items in a struct, of which
- * itself may be in an array. Each item can be named, causing the construction of a new variable for each, but only if the
- * register is made available and the name is not 0. If the register is made available, then this variable is also added
- * to the register. In the case where there is only one item, but it is a vector, the name list must reperesent the name
- * each each vector item (as opposed to items of the complex type).
- * If structSizePtr is 0 and dataCount is 1, it will attempt to work out the size from the dataType
- * (otherwise it will assert). The casting allows the Variable to be seen in a different type to its actual representation
- * (e.g. as an arry of floats instead of doubles). If dataCastTypes == 0, then no casting is done for any component. The
- * size of the struct, the size of the array and the pointer to the array are provided as pointers to this information, of
- * which will get resolved/dereferenced at the build phase. */
- Variable* Variable_New(
- Name name,
- Index dataCount,
- SizeT* dataOffsets,
- Variable_DataType* dataTypes,
- Index* dataTypeCounts,
- Name* dataNames,
- SizeT* structSizePtr,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr );
-
-
- Variable* Variable_DefaultNew( Name name );
-
- /** Creates a new Variable. A Variable holds the run-time information of a complex data type created by the programmer.
- * Essentially it associates a textual name to a variable in the program that the user can use to access or modify.
- *
- * See Variable_New for more info.
- *
- * This constructor is a shortcut to create a Variable of a scalar in an array. The stride/struct size is the size
- * of the dataType. There is no casting. */
- Variable* Variable_NewScalar(
- Name name,
- Variable_DataType dataType,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr );
-
- /** Creates a new Variable. A Variable holds the run-time information of a complex data type created by the programmer.
- * Essentially it associates a textual name to a variable in the program that the user can use to access or modify.
- *
- * See Variable_New for more info.
- *
- * This constructor is a shortcut to create a Variable of a vector in an array. The names of the vector components are
- * optional and are specified via the variable arguement list at the end. A 0 value signifies no name for the associated
- * vector component. The stride/struct size is the size of the dataType. There is no casting.*/
- Variable* Variable_NewVector(
- Name name,
- Variable_DataType dataType,
- Index dataTypeCount,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr,
- ... /* vector component names */ );
-
- Variable* Variable_NewVector2(
- Name name,
- Variable_DataType dataType,
- Index dataTypeCount,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr,
- char** dataNames );
-
- /** Constructor interface. */
- Variable* _Variable_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- Index dataCount,
- SizeT* dataOffsets,
- Variable_DataType* dataTypes,
- Index* dataTypeCounts,
- Name* dataNames,
- SizeT* structSizePtr,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Variable_Register* vr );
-
-
- /** Initialise a Variable */
- void Variable_Init(
- Name name,
- Variable* self,
- Index dataCount,
- SizeT* dataOffsets,
- Variable_DataType* dataTypes,
- Index* dataTypeCounts,
- Name* dataNames,
- SizeT* structSizePtr,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Bool allocateSelf,
- Variable_Register* vr );
-
- /** Init interface. */
- void _Variable_Init(
- Variable* self,
- Index dataCount,
- SizeT* dataOffsets,
- Variable_DataType* dataTypes,
- Index* dataTypeCounts,
- Name* dataNames,
- SizeT* structSizePtr,
- Index* arraySizePtr,
- Variable_ArraySizeFunc* arraySizeFunc,
- void** arrayPtrPtr,
- Bool allocateSelf,
- Variable_Register* vr );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- /** Stg_Class_Delete Variable implementation */
- void _Variable_Delete( void* variable );
-
- /** Print Variable implementation */
- void _Variable_Print( void* variable, Stream* stream );
-
- /** Copy implementation */
- #define Variable_Copy( self ) \
- (Variable*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
- #define Variable_DeepCopy( self ) \
- (Variable*)Stg_Class_Copy( self, NULL, True, NULL, NULL )
-
- void* _Variable_Copy( void* variable, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
-
- /** Build implementation */
- void _Variable_Build( void* variable, void* data );
-
- /** Initialisation implementation */
- void _Variable_Initialise( void* variable, void* data );
-
- /** Execution implementation */
- void _Variable_Execute( void* variable, void* data );
-
- void _Variable_Construct( void* variable, Stg_ComponentFactory* cf, void* data );
-
- void _Variable_Destroy( void* variable, void* data );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Private Member functions: Fundamental address calculators
- */
-
- /** Implementation of "get" the structure in an array, that the requested data member is in. Private (Do not directly
- * use!)
- * NB:- the array_I needs to be cast to an ArithPointer below - see __Variable_GetPtr() for reason. */
- #define __Variable_GetStructPtr( self, array_I ) \
- ( ( (self)->offsetCount < 2 ) ? \
- ( (void*)( (ArithPointer)(self)->arrayPtr + (ArithPointer)(array_I) * (ArithPointer)( (self)->structSize) + (ArithPointer)( (self)->offsets[0] ) )) : \
- ( (void*)((ArithPointer)(self)->arrayPtr + (ArithPointer)(array_I) * (ArithPointer)((self)->structSize)) ) )
- #ifdef CAUTIOUS
- /** Implementation of "get" the structure in an array that the requested data member is in if CAUTIOUS is defined.
- * It ensures that array_I is within its bounds. Private (Do not directly use!) */
- #define _Variable_GetStructPtr( self, array_I ) \
- ( ((array_I) < (self)->arraySize) ? \
- __Variable_GetStructPtr( (self), (array_I) ) : \
- /*TODO : call J_Firewall, then return NULL. */ \
- (void*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable %s, in macro _Variable_GetStructPtr: requested array index %d " \
- "out of range (array size is %d). Exiting.\n", (self)->name, array_I, \
- (self)->arraySize ), NULL) )
- #else
- /** Implementation of "get" the structure in an array, that the requested data member is in if CAUTIOUS is NOT
- * defined. It DOES NOT ensure that array_I is within its bounds. Private (Do not directly use!) */
- #define _Variable_GetStructPtr __Variable_GetStructPtr
- #endif
-
-
-/* BUG!: ( (void*)((ArithPointer)_Variable_GetStructPtr( (self), (array_I) ) + (self)->offsets[component_I]) ) */
-
- /** Implementation of "get" the requested data member in a structure in an array. Private (Do not directly use!)
- NB - we cast the array_I to an ArithPointer since its usually passed in as an Index (unsigned int), which on
- some architectures such as the SGI Altix is of a different size to the ArithPointer (unsigned long) */
- #define __Variable_GetPtr( self, array_I, component_I, vector_I ) \
- ( (void*)((ArithPointer)(self)->arrayPtr + (ArithPointer)(array_I) * (self)->structSize + (self)->offsets[component_I]) )
- #ifdef CAUTIOUS
- /** Implementation of "get" the requested data member in a structure in an array if CAUTIOUS is defined.
- * It ensures that component_I and array_I are within its bounds. Private (Do not directly use!) */
- #define _Variable_GetPtr( self, array_I, component_I, vector_I ) \
- ( ((component_I) < (self)->offsetCount) ? \
- __Variable_GetPtr( (self), (array_I), (component_I), (vector_I) ) :\
- (void*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Offset array_I out of range\n" ), NULL) )
- #else
- /** Implementation of "get" the requested data member in a structure in an array if CAUTIOUS is NOT
- * defined. It DOES NOT ensure that component_I and array_I are within its bounds. Private (Do not directly
- * use!) */
- #define _Variable_GetPtr __Variable_GetPtr
- #endif
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public Member functions: Assuming this is a Variable of a "char" inbuilt type
- */
-
- /** Assuming this is a Variable of a "char" inbuilt type, return a pointer to that char (type casted to char*). Private
- * (Do not directly use!). */
- #define _Variable_GetPtrChar( self, array_I ) \
- ( (char*)_Variable_GetStructPtr( (self), (array_I) ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a "char" inbuilt type, return a pointer to that char (type casted to char*).
- * It ensures the Variable is of a "char" and is not complex. */
- #define Variable_GetPtrChar( self, array_I ) \
- ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Char) ? \
- _Variable_GetPtrChar( (self), (array_I) ) : \
- (char*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of a char or is complex, but this macro assumes so.\n" ), NULL) )
- #else
- /** Assuming this is a Variable of a "char" inbuilt type, return a pointer to that char (type casted to char*).
- * It DOES NOT ensure the Variable is of a "char" and is not complex. */
- #define Variable_GetPtrChar _Variable_GetPtrChar
- #endif
-
-
- /** Assuming this is a Variable of a vector "char" inbuilt type, return that char. Private (Do not directly use!). */
- #define _Variable_GetValueAtChar( self, array_I, vector_I ) \
- ( Variable_GetPtrChar( (self), (array_I) )[(vector_I)] )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a vector "char" inbuilt type, return that char. It ensures that vector_I is
- * within range. */
- #define Variable_GetValueAtChar( self, array_I, vector_I ) \
- ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
- _Variable_GetValueAtChar( (self), (array_I), (vector_I) ) : \
- (char)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Index into vector of inbuild type is out of range.\n" ) )
- #else
- /** Assuming this is a Variable of a vector "char" inbuilt type, return that char. It DOES NOT ensure that
- * vector_I is within range. */
- #define Variable_GetValueAtChar _Variable_GetValueAtChar
- #endif
-
- /** Assuming this is a Variable of a vector "char" inbuilt type, return a pointer to that char. */
- #define Variable_GetPtrAtChar( self, array_I, vector_I ) \
- ( &_Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
-
-
- /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as a short */
- #define Variable_GetValueAtCharAsShort( self, array_I, vector_I ) \
- ( (short)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as an int */
- #define Variable_GetValueAtCharAsInt( self, array_I, vector_I ) \
- ( (int)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as a float */
- #define Variable_GetValueAtCharAsFloat( self, array_I, vector_I ) \
- ( (float)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as a double */
- #define Variable_GetValueAtCharAsDouble( self, array_I, vector_I ) \
- ( (double)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as a pointer (void*) */
- #define Variable_GetValueAtCharAsPointer( self, array_I, vector_I ) \
- ( (void*)( (int)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) ) )
-
- /** Assuming this is a Variable of a vector "char" inbuilt type, set that char to a new value (internally type casted to char) */
- #define Variable_SetValueAtChar( self, array_I, vector_I, value ) \
- ( *Variable_GetPtrAtChar( (self), (array_I), (vector_I) ) = (char)(value) )
-
-
- /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char */
- #define Variable_GetValueChar( self, array_I ) \
- ( Variable_GetValueAtChar( (self), (array_I), 0 ) )
-
- /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as a short */
- #define Variable_GetValueCharAsShort( self, array_I ) \
- ( (short)Variable_GetValueChar( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as an int */
- #define Variable_GetValueCharAsInt( self, array_I ) \
- ( (int)Variable_GetValueChar( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as a float */
- #define Variable_GetValueCharAsFloat( self, array_I ) \
- ( (float)Variable_GetValueChar( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as a double */
- #define Variable_GetValueCharAsDouble( self, array_I ) \
- ( (double)Variable_GetValueChar( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as a pointer (void*) */
- #define Variable_GetValueCharAsPointer( self, array_I ) \
- ( (void*)( (int)Variable_GetValueChar( (self), (array_I) ) ) )
-
- /** Assuming this is a Variable of a scalar "char" inbuilt type, set that char to a new value (internally type casted to
- * char) */
- #define Variable_SetValueChar( self, array_I, value ) \
- ( *Variable_GetPtrChar( (self), (array_I) ) = (char)(value) )
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public Member functions: Assuming this is a Variable of a "short" inbuilt type
- */
-
- /** Assuming this is a Variable of a "short" inbuilt type, return a pointer to that short (type casted to short*). Private
- * (Do not directly use!). */
- #define _Variable_GetPtrShort( self, array_I ) \
- ( (short*)_Variable_GetStructPtr( (self), (array_I) ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a "short" inbuilt type, return a pointer to that short (type casted to short*).
- * It ensures the Variable is of a "short" and is not complex. */
- #define Variable_GetPtrShort( self, array_I ) \
- ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Short) ? \
- _Variable_GetPtrShort( (self), (array_I) ) : \
- (short*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of a short or is complex, but this macro assumes so.\n" ), NULL) )
- #else
- /** Assuming this is a Variable of a "short" inbuilt type, return a pointer to that short (type casted to short*).
- * It DOES NOT ensure the Variable is of a "short" and is not complex. */
- #define Variable_GetPtrShort _Variable_GetPtrShort
- #endif
-
-
- /** Assuming this is a Variable of a vector "short" inbuilt type, return that short. Private (Do not directly use!). */
- #define _Variable_GetValueAtShort( self, array_I, vector_I ) \
- ( Variable_GetPtrShort( (self), (array_I) )[(vector_I)] )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a vector "short" inbuilt type, return that short. It ensures that vector_I is
- * within range. */
- #define Variable_GetValueAtShort( self, array_I, vector_I ) \
- ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
- _Variable_GetValueAtShort( (self), (array_I), (vector_I) ) : \
- (short)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Index into vector of inbuild type is out of range.\n" ) )
- #else
- /** Assuming this is a Variable of a vector "short" inbuilt type, return that short. It DOES NOT ensure that
- * vector_I is within range. */
- #define Variable_GetValueAtShort _Variable_GetValueAtShort
- #endif
-
- /** Assuming this is a Variable of a vector "short" inbuilt type, return a pointer to that short. */
- #define Variable_GetPtrAtShort( self, array_I, vector_I ) \
- ( &_Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
-
-
- /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as a char */
- #define Variable_GetValueAtShortAsChar( self, array_I, vector_I ) \
- ( (char)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as an int */
- #define Variable_GetValueAtShortAsInt( self, array_I, vector_I ) \
- ( (int)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as a float */
- #define Variable_GetValueAtShortAsFloat( self, array_I, vector_I ) \
- ( (float)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as a double */
- #define Variable_GetValueAtShortAsDouble( self, array_I, vector_I ) \
- ( (double)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as a pointer (void*) */
- #define Variable_GetValueAtShortAsPointer( self, array_I, vector_I ) \
- ( (void*)( (int)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) ) )
-
- /** Assuming this is a Variable of a vector "short" inbuilt type, set that short to a new value (internally type casted to
- * short)*/
- #define Variable_SetValueAtShort( self, array_I, vector_I, value ) \
- ( *Variable_GetPtrAtShort( self, array_I, vector_I ) = (short)(value) )
-
-
- /** Assuming this is a Variable of a "short" inbuilt type, return that short */
- #define Variable_GetValueShort( self, array_I ) \
- ( Variable_GetValueAtShort( (self), (array_I), 0 ) )
-
- /** Assuming this is a Variable of a "short" inbuilt type, return that short as a char */
- #define Variable_GetValueShortAsChar( self, array_I ) \
- ( (char)Variable_GetValueShort( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a "short" inbuilt type, return that short as an int */
- #define Variable_GetValueShortAsInt( self, array_I ) \
- ( (int)Variable_GetValueShort( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a "short" inbuilt type, return that short as a float */
- #define Variable_GetValueShortAsFloat( self, array_I ) \
- ( (float)Variable_GetValueShort( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a "short" inbuilt type, return that short as a double */
- #define Variable_GetValueShortAsDouble( self, array_I ) \
- ( (double)Variable_GetValueShort( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a "short" inbuilt type, return that short as a pointer (void*) */
- #define Variable_GetValueShortAsPointer( self, array_I ) \
- ( (void*)( (int)Variable_GetValueShort( (self), (array_I) ) ) )
-
- /** Assuming this is a Variable of a "short" inbuilt type, set that short to a new value (internally type casted to
- * short)*/
- #define Variable_SetValueShort( self, array_I, value ) \
- ( *Variable_GetPtrShort( self, array_I ) = (short)(value) )
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public Member functions: Assuming this is a Variable of a "int" inbuilt type
- */
-
- /** Assuming this is a Variable of a "int" inbuilt type, return a pointer to that int (type casted to int*). Private
- * (Do not directly use!). */
- #define _Variable_GetPtrInt( self, array_I ) \
- ( (int*)_Variable_GetStructPtr( (self), (array_I) ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a "int" inbuilt type, return a pointer to that int (type casted to int*).
- * It ensures the Variable is of a "int" and is not complex. */
- #define Variable_GetPtrInt( self, array_I ) \
- ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Int) ? \
- _Variable_GetPtrInt( (self), (array_I) ) : \
- (int*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of a int or is complex, but this macro assumes so.\n" ),NULL) )
- #else
- /** Assuming this is a Variable of a "int" inbuilt type, return a pointer to that int (type casted to int*).
- * It DOES NOT ensure the Variable is of a "int" and is not complex. */
- #define Variable_GetPtrInt _Variable_GetPtrInt
- #endif
-
-
- /** Assuming this is a Variable of a vector "int" inbuilt type, return that int. Private (Do not directly use!). */
- #define _Variable_GetValueAtInt( self, array_I, vector_I ) \
- ( Variable_GetPtrInt( (self), (array_I) )[(vector_I)] )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a vector "int" inbuilt type, return that int. It ensures that vector_I is
- * within range. */
- #define Variable_GetValueAtInt( self, array_I, vector_I ) \
- ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
- _Variable_GetValueAtInt( (self), (array_I), (vector_I) ) : \
- (int)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Index into vector of inbuild type is out of range.\n" ) )
- #else
- /** Assuming this is a Variable of a vector "int" inbuilt type, return that int. It DOES NOT ensure that
- * vector_I is within range. */
- #define Variable_GetValueAtInt _Variable_GetValueAtInt
- #endif
-
- /** Assuming this is a Variable of a vector "int" inbuilt type, return a pointer to that int. */
- #define Variable_GetPtrAtInt( self, array_I, vector_I ) \
- ( &_Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
-
-
- /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a char */
- #define Variable_GetValueAtIntAsChar( self, array_I, vector_I ) \
- ( (char)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a short */
- #define Variable_GetValueAtIntAsShort( self, array_I, vector_I ) \
- ( (short)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a float */
- #define Variable_GetValueAtIntAsFloat( self, array_I, vector_I ) \
- ( (float)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a double */
- #define Variable_GetValueAtIntAsDouble( self, array_I, vector_I ) \
- ( (double)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a pointer (void*) */
- #define Variable_GetValueAtIntAsPointer( self, array_I, vector_I ) \
- ( (void*)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "int" inbuilt type, set that int to a new value (internally type casted to int) */
- #define Variable_SetValueAtInt( self, array_I, vector_I, value ) \
- ( *Variable_GetPtrAtInt( (self), (array_I), (vector_I) ) = (int)(value) )
-
-
- /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int */
- #define Variable_GetValueInt( self, array_I ) \
- ( Variable_GetValueAtInt( (self), (array_I), 0 ) )
-
- /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a char */
- #define Variable_GetValueIntAsChar( self, array_I ) \
- ( (char)Variable_GetValueInt( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a short */
- #define Variable_GetValueIntAsShort( self, array_I ) \
- ( (short)Variable_GetValueInt( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a float */
- #define Variable_GetValueIntAsFloat( self, array_I ) \
- ( (float)Variable_GetValueInt( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a double */
- #define Variable_GetValueIntAsDouble( self, array_I ) \
- ( (double)Variable_GetValueInt( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a pointer (void*) */
- #define Variable_GetValueIntAsPointer( self, array_I ) \
- ( (void*)Variable_GetValueInt( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "int" inbuilt type, set that int to a new value (internally type casted to int) */
- #define Variable_SetValueInt( self, array_I, value ) \
- ( *Variable_GetPtrInt( (self), (array_I) ) = (int)(value) )
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public Member functions: Assuming this is a Variable of a "float" inbuilt type
- */
-
- /** Assuming this is a Variable of a "float" inbuilt type, return a pointer to that float (type casted to float*). Private
- * (Do not directly use!). */
- #define _Variable_GetPtrFloat( self, array_I ) \
- ( (float*)_Variable_GetStructPtr( (self), (array_I) ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a "float" inbuilt type, return a pointer to that float (type casted to float*).
- * It ensures the Variable is of a "float" and is not complex. */
- #define Variable_GetPtrFloat( self, array_I ) \
- ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Float) ? \
- _Variable_GetPtrFloat( (self), (array_I) ) : \
- (float*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of a float or is complex, but this macro assumes so.\n" ), NULL) )
- #else
- /** Assuming this is a Variable of a "float" inbuilt type, return a pointer to that float (type casted to float*).
- * It DOES NOT ensure the Variable is of a "float" and is not complex. */
- #define Variable_GetPtrFloat _Variable_GetPtrFloat
- #endif
-
-
- /** Assuming this is a Variable of a vector "float" inbuilt type, return that float. Private (Do not directly use!). */
- #define _Variable_GetValueAtFloat( self, array_I, vector_I ) \
- ( Variable_GetPtrFloat( (self), (array_I) )[(vector_I)] )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a vector "float" inbuilt type, return that float. It ensures that vector_I is
- * within range. */
- #define Variable_GetValueAtFloat( self, array_I, vector_I ) \
- ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
- _Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) : \
- (float)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Index into vector of inbuild type is out of range.\n" ) )
- #else
- /** Assuming this is a Variable of a vector "float" inbuilt type, return that float. It DOES NOT ensure that
- * vector_I is within range. */
- #define Variable_GetValueAtFloat _Variable_GetValueAtFloat
- #endif
-
- /** Assuming this is a Variable of a vector "float" inbuilt type, return a pointer to that float. */
- #define Variable_GetPtrAtFloat( self, array_I, vector_I ) \
- ( &_Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
-
-
- /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as a char */
- #define Variable_GetValueAtFloatAsChar( self, array_I, vector_I ) \
- ( (char)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as a short */
- #define Variable_GetValueAtFloatAsShort( self, array_I, vector_I ) \
- ( (short)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as an int */
- #define Variable_GetValueAtFloatAsInt( self, array_I, vector_I ) \
- ( (int)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as a double */
- #define Variable_GetValueAtFloatAsDouble( self, array_I, vector_I ) \
- ( (double)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as a pointer (void*) */
- #define Variable_GetValueAtFloatAsPointer( self, array_I, vector_I ) \
- ( (void*)( (int)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) ) )
-
- /** Assuming this is a Variable of a vector "float" inbuilt type, set that float to a new value (internally type casted to
- * float) */
- #define Variable_SetValueAtFloat( self, array_I, vector_I, value ) \
- ( *Variable_GetPtrAtFloat( (self), (array_I), (vector_I) ) = (float)(value) )
-
-
- /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float */
- #define Variable_GetValueFloat( self, array_I ) \
- ( Variable_GetValueAtFloat( (self), (array_I), 0 ) )
-
- /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as a char */
- #define Variable_GetValueFloatAsChar( self, array_I ) \
- ( (char)Variable_GetValueFloat( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as a short */
- #define Variable_GetValueFloatAsShort( self, array_I ) \
- ( (short)Variable_GetValueFloat( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as an int */
- #define Variable_GetValueFloatAsInt( self, array_I ) \
- ( (int)Variable_GetValueFloat( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as a double */
- #define Variable_GetValueFloatAsDouble( self, array_I ) \
- ( (double)Variable_GetValueFloat( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as a pointer (void*) */
- #define Variable_GetValueFloatAsPointer( self, array_I ) \
- ( (void*)( (int)Variable_GetValueFloat( (self), (array_I) ) ) )
-
- /** Assuming this is a Variable of a scalar "float" inbuilt type, set that float to a new value (internally type casted to
- * float) */
- #define Variable_SetValueFloat( self, array_I, value ) \
- ( *Variable_GetPtrFloat( (self), (array_I) ) = (float)(value) )
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public Member functions: Assuming this is a Variable of a "double" inbuilt type
- */
-
- /** Assuming this is a Variable of a "double" inbuilt type, return a pointer to that double (type casted to double*).
- * Private (Do not directly use!). */
- #define _Variable_GetPtrDouble( self, array_I ) \
- ( (double*)_Variable_GetStructPtr( (self), (array_I) ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a "double" inbuilt type, return a pointer to that double (type casted to
- * double*). It ensures the Variable is of a "double" and is not complex. */
- #define Variable_GetPtrDouble( self, array_I ) \
- ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Double) ? \
- _Variable_GetPtrDouble( (self), (array_I) ) : \
- (double*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of a double or is complex, but this macro assumes so.\n" ), NULL) )
- #else
- /** Assuming this is a Variable of a "double" inbuilt type, return a pointer to that double (type casted to
- * double*). It DOES NOT ensure the Variable is of a "double" and is not complex. */
- #define Variable_GetPtrDouble _Variable_GetPtrDouble
- #endif
-
-
- /** Assuming this is a Variable of a vector "double" inbuilt type, return that double. Private (Do not directly use!). */
- #define _Variable_GetValueAtDouble( self, array_I, vector_I ) \
- ( (Variable_GetPtrDouble( (self), (array_I) ))[(vector_I)] )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a vector "double" inbuilt type, return that double. It ensures that vector_I is
- * within range. */
- #define Variable_GetValueAtDouble( self, array_I, vector_I ) \
- ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
- _Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) : \
- (double)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Index into vector of inbuild type is out of range.\n" ) )
- #else
- /** Assuming this is a Variable of a vector "double" inbuilt type, return that double. It DOES NOT ensure that
- * vector_I is within range. */
- #define Variable_GetValueAtDouble _Variable_GetValueAtDouble
- #endif
-
- /** Assuming this is a Variable of a vector "double" inbuilt type, return a pointer to that double. */
- #define Variable_GetPtrAtDouble( self, array_I, vector_I ) \
- ( &_Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
-
-
- /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a char */
- #define Variable_GetValueAtDoubleAsChar( self, array_I, vector_I ) \
- ( (char)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a short */
- #define Variable_GetValueAtDoubleAsShort( self, array_I, vector_I ) \
- ( (short)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a int */
- #define Variable_GetValueAtDoubleAsInt( self, array_I, vector_I ) \
- ( (int)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a float */
- #define Variable_GetValueAtDoubleAsFloat( self, array_I, vector_I ) \
- ( (float)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a double */
- #define Variable_GetValueAtDoubleAsDouble( self, array_I, vector_I ) \
- ( (double)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a pointer (void*) */
- #define Variable_GetValueAtDoubleAsPointer( self, array_I, vector_I ) \
- ( (void*)( (int)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) ) )
-
- /** Assuming this is a Variable of a vector "double" inbuilt type, set that double to a new value (internally type casted to
- * double) */
- #define Variable_SetValueAtDouble( self, array_I, vector_I, value ) \
- ( *Variable_GetPtrAtDouble( (self), (array_I), (vector_I) ) = (double)(value) )
-
-
- /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double */
- #define Variable_GetValueDouble( self, array_I ) \
- ( Variable_GetValueAtDouble( (self), (array_I), 0 ) )
-
- /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a char */
- #define Variable_GetValueDoubleAsChar( self, array_I ) \
- ( (char)Variable_GetValueDouble( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a short */
- #define Variable_GetValueDoubleAsShort( self, array_I ) \
- ( (short)Variable_GetValueDouble( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a int */
- #define Variable_GetValueDoubleAsInt( self, array_I ) \
- ( (int)Variable_GetValueDouble( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a float */
- #define Variable_GetValueDoubleAsFloat( self, array_I ) \
- ( (float)Variable_GetValueDouble( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a double */
- #define Variable_GetValueDoubleAsDouble( self, array_I ) \
- ( (double)Variable_GetValueDouble( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a pointer (void*) */
- #define Variable_GetValueDoubleAsPointer( self, array_I ) \
- ( (void*)( (int)Variable_GetValueDouble( (self), (array_I) ) ) )
-
- /** Assuming this is a Variable of a scalar "double" inbuilt type, set that double to a new value (internally type casted to
- * double) */
- #define Variable_SetValueDouble( self, array_I, value ) \
- ( *Variable_GetPtrDouble( (self), (array_I) ) = (double)(value) )
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public Member functions: Assuming this is a Variable of a "pointer" inbuilt type
- */
-
- /** Assuming this is a Variable of a "pointer" inbuilt type, return a pointer to that pointer (type casted to void**).
- * Private. (Do not directly use!). */
- #define _Variable_GetPtrPointer( self, array_I ) \
- ( (void**)_Variable_GetStructPtr( (self), (array_I) ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a "pointer" inbuilt type, return a pointer to that pointer (type casted to
- * void**). It ensures the Variable is of a "pointer" and is not complex. */
- #define Variable_GetPtrPointer( self, array_I ) \
- ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Pointer) ? \
- _Variable_GetPtrPointer( (self), (array_I) ) : \
- (void**)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of a pointer or is complex, but this macro assumes so.\n" ), NULL) )
- #else
- /** Assuming this is a Variable of a "pointer" inbuilt type, return a pointer to that pointer (type casted to
- * void**). It DOES NOT ensure the Variable is of a "pointer" and is not complex. */
- #define Variable_GetPtrPointer _Variable_GetPtrPointer
- #endif
-
-
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer. Private (Do not directly use!). */
- #define _Variable_GetValueAtPointer( self, array_I, vector_I ) \
- ( Variable_GetPtrPointer( (self), (array_I) )[(vector_I)] )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer. It ensures that vector_I is
- * within range. */
- #define Variable_GetValueAtPointer( self, array_I, vector_I ) \
- ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
- _Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) : \
- (void*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Index into vector of inbuild type is out of range.\n" ), NULL) )
- #else
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer. It DOES NOT ensure that
- * vector_I is within range. */
- #define Variable_GetValueAtPointer _Variable_GetValueAtPointer
- #endif
-
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, return a pointer to that pointer. */
- #define Variable_GetPtrAtPointer( self, array_I, vector_I ) \
- ( &_Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
-
-
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as a char pointer (char*) */
- #define Variable_GetValueAtPointerAsCharPointer( self, array_I, vector_I ) \
- ( (char*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as a short pointer (short*) */
- #define Variable_GetValueAtPointerAsShortPointer( self, array_I, vector_I ) \
- ( (short*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as an int pointer (int*) */
- #define Variable_GetValueAtPointerAsIntPointer( self, array_I, vector_I ) \
- ( (int*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as a float pointer (float*) */
- #define Variable_GetValueAtPointerAsFloatPointer( self, array_I, vector_I ) \
- ( (float*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as a double pointer (double*) */
- #define Variable_GetValueAtPointerAsDoublePointer( self, array_I, vector_I ) \
- ( (double*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
-
- /** Assuming this is a Variable of a vector "pointer" inbuilt type, set that pointer to a new value (internally type casted to
- * void*) */
- #define Variable_SetValueAtPointer( self, array_I, vector_I, value ) \
- ( *Variable_GetPtrAtPointer( (self), (array_I), (vector_I) ) = (void*)(value) )
-
-
- /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer (void*) */
- #define Variable_GetValuePointer( self, array_I ) \
- ( Variable_GetValueAtPointer( (self), (array_I), 0 ) )
-
- /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as a char pointer (char*) */
- #define Variable_GetValuePointerAsCharPointer( self, array_I ) \
- ( (char*)Variable_GetValuePointer( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as a short pointer (short*) */
- #define Variable_GetValuePointerAsShortPointer( self, array_I ) \
- ( (short*)Variable_GetValuePointer( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as an int pointer (int*) */
- #define Variable_GetValuePointerAsIntPointer( self, array_I ) \
- ( (int*)Variable_GetValuePointer( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as a float pointer (float*) */
- #define Variable_GetValuePointerAsFloatPointer( self, array_I ) \
- ( (float*)Variable_GetValuePointer( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as a double pointer (double*) */
- #define Variable_GetValuePointerAsDoublePointer( self, array_I ) \
- ( (double*)Variable_GetValuePointer( (self), (array_I) ) )
-
- /** Assuming this is a Variable of a scalar "pointer" inbuilt type, set that pointer to a new value (internally type casted to
- * void*) */
- #define Variable_SetValuePointer( self, array_I, value ) \
- ( *Variable_GetPtrPointer( (self), (array_I) ) = (void*)(value) )
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public Member functions: Assuming this is a Variable of any inbuilt type
- */
-
- /** Assuming this is a Variable of any inbuilt type, return a char (type casted to char). Private. (Do not directly
- * use!). Resolution order: char, short, int, float, double, pointer. */
- #define _Variable_GetValueAsChar( self, array_I ) \
- ( ((self)->dataTypes[0] == Variable_DataType_Char) ? Variable_GetValueChar( (self), (array_I) ) : \
- ((self)->dataTypes[0] == Variable_DataType_Short) ? Variable_GetValueShortAsChar( (self), (array_I) ) : \
- ((self)->dataTypes[0] == Variable_DataType_Int) ? Variable_GetValueIntAsChar( (self), (array_I) ) : \
- ((self)->dataTypes[0] == Variable_DataType_Float) ? Variable_GetValueFloatAsChar( (self), (array_I) ) : \
- ((self)->dataTypes[0] == Variable_DataType_Double) ? Variable_GetValueDoubleAsChar( (self), (array_I) ) : \
- (char)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of any inbuilt type, return a char (type casted to char). It ensures the Variable
- * is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsChar( self, array_I ) \
- ( ((self)->offsetCount == 1) ? \
- _Variable_GetValueAsChar( (self), (array_I) ) : \
- (char)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is complex, but this macro assumes not so.\n" ) )
- #else
- /** Assuming this is a Variable of any inbuilt type, return a char (type casted to char). It DOES NOT ensure the
- * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsChar _Variable_GetValueAsChar
- #endif
-
- /** Assuming this is a Variable of any inbuilt type, return a short (type casted to short). Private. (Do not directly
- * use!). Resolution order: char, short, int, float, double, pointer. */
- #define _Variable_GetValueAsShort( self, array_I ) \
- ( ((self)->dataTypes[0] == Variable_DataType_Char) ? Variable_GetValueCharAsShort( (self), (array_I) ) : \
- ((self)->dataTypes[0] == Variable_DataType_Short) ? Variable_GetValueShort( (self), (array_I) ) : \
- ((self)->dataTypes[0] == Variable_DataType_Int) ? Variable_GetValueIntAsShort( (self), (array_I) ) : \
- ((self)->dataTypes[0] == Variable_DataType_Float) ? Variable_GetValueFloatAsShort( (self), (array_I) ) : \
- ((self)->dataTypes[0] == Variable_DataType_Double) ? Variable_GetValueDoubleAsShort( (self), (array_I) ) : \
- (short)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of any inbuilt type, return a short (type casted to short). It ensures the Variable
- * is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsShort( self, array_I ) \
- ( ((self)->offsetCount == 1) ? \
- _Variable_GetValueAsShort( (self), (array_I) ) : \
- (short)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is complex, but this macro assumes not so.\n" ) )
- #else
- /** Assuming this is a Variable of any inbuilt type, return a short (type casted to short). It DOES NOT ensure the
- * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsShort _Variable_GetValueAsShort
- #endif
-
- /** Assuming this is a Variable of any inbuilt type, return a int (type casted to int). Private. (Do not directly
- * use!). Resolution order: char, short, int, float, double, pointer. */
- #define _Variable_GetValueAsInt( self, array_I ) \
- ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_GetValueCharAsInt( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Short ? Variable_GetValueShortAsInt( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Int ? Variable_GetValueInt( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Float ? Variable_GetValueFloatAsInt( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Double ? Variable_GetValueDoubleAsInt( (self), (array_I) ) : \
- (int)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of any inbuilt type, return a int (type casted to int). It ensures the Variable
- * is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsInt( self, array_I ) \
- ( (self)->offsetCount == 1 ? \
- _Variable_GetValueAsInt( (self), (array_I) ) : \
- (int)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is complex, but this macro assumes not so.\n" ) )
- #else
- /** Assuming this is a Variable of any inbuilt type, return a int (type casted to int). It DOES NOT ensure the
- * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsInt _Variable_GetValueAsInt
- #endif
-
- /** Assuming this is a Variable of any inbuilt type, return a float (type casted to float). Private. (Do not directly
- * use!). Resolution order: char, short, int, float, double, pointer.*/
- #define _Variable_GetValueAsFloat( self, array_I ) \
- ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_GetValueCharAsFloat( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Short ? Variable_GetValueShortAsFloat( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Int ? Variable_GetValueIntAsFloat( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Float ? Variable_GetValueFloat( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Double ? Variable_GetValueDoubleAsFloat( (self), (array_I) ) : \
- (float)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of any inbuilt type, return a float (type casted to float). It ensures the Variable
- * is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsFloat( self, array_I ) \
- ( (self)->offsetCount == 1 ? \
- _Variable_GetValueAsFloat( (self), (array_I) ) : \
- (float)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is complex, but this macro assumes not so.\n" ) )
- #else
- /** Assuming this is a Variable of any inbuilt type, return a float (type casted to float). It DOES NOT ensure the
- * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsFloat _Variable_GetValueAsFloat
- #endif
-
- /** Assuming this is a Variable of any inbuilt type, return a double (type casted to double). Private. (Do not directly
- * use!). Resolution order: char, short, int, float, double, pointer. */
- #define _Variable_GetValueAsDouble( self, array_I ) \
- ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_GetValueCharAsDouble( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Short ? Variable_GetValueShortAsDouble( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Int ? Variable_GetValueIntAsDouble( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Float ? Variable_GetValueFloatAsDouble( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Double ? Variable_GetValueDouble( (self), (array_I) ) : \
- (double)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of any inbuilt type, return a double (type casted to double). It ensures the
- * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsDouble( self, array_I ) \
- ( (self)->offsetCount == 1 ? \
- _Variable_GetValueAsDouble( (self), (array_I) ) : \
- (double)Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is complex, but this macro assumes not so.\n" ) )
- #else
- /** Assuming this is a Variable of any inbuilt type, return a double (type casted to double). It DOES NOT ensure
- * the Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
- #define Variable_GetValueAsDouble _Variable_GetValueAsDouble
- #endif
-
- /** Assuming this is a Variable of any inbuilt type, return a pointer (type casted to void*). Private. (Do not directly
- * use!). Resolution order: pointer, short, int, float, double, pointer. */
- #define _Variable_GetValueAsPointer( self, array_I ) \
- ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_GetValueCharAsPointer( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Short ? Variable_GetValueShortAsPointer( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Int ? Variable_GetValueIntAsPointer( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Float ? Variable_GetValueFloatAsPointer( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Double ? Variable_GetValueDoubleAsPointer( (self), (array_I) ) : \
- (self)->dataTypes[0] == Variable_DataType_Pointer ? Variable_GetValuePointer( (self), (array_I) ) : \
- (Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of any inbuilt type, but this macro assumes so.\n" ), NULL) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of any inbuilt type, return a pointer (type casted to void*). It ensures the Variable
- * is not complex. Resolution order: pointer, short, int, float, double, pointer. */
- #define Variable_GetValueAsPointer( self, array_I ) \
- ( (self)->offsetCount == 1 ? \
- _Variable_GetValueAsPointer( (self), (array_I) ) : \
- (void*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is complex, but this macro assumes not so.\n" ), NULL) )
- #else
- /** Assuming this is a Variable of any inbuilt type, return a pointer (type casted to void*). It DOES NOT ensure the
- * Variable is not complex. Resolution order: pointer, short, int, float, double, pointer. */
- #define Variable_GetValueAsPointer _Variable_GetValueAsPointer
- #endif
-
-
- /** Assuming this is a Variable of any inbuilt type, set the value. Private. (Do not directly use!). Resolution order:
- * pointer, short, int, float, double, pointer. */
- #define _Variable_SetValueFromInbuilt( self, array_I, value ) \
- ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_SetValueChar( (self), (array_I), (value) ) : \
- (self)->dataTypes[0] == Variable_DataType_Short ? Variable_SetValueShort( (self), (array_I), (value) ) : \
- (self)->dataTypes[0] == Variable_DataType_Int ? Variable_SetValueInt( (self), (array_I), (value) ) : \
- (self)->dataTypes[0] == Variable_DataType_Float ? Variable_SetValueFloat( (self), (array_I), (value) ) : \
- (self)->dataTypes[0] == Variable_DataType_Double ? Variable_SetValueDouble( (self), (array_I), (value) ) : \
- (self)->dataTypes[0] == Variable_DataType_Pointer ? Variable_SetValuePointer( (self), (array_I), (value) ) : \
- (Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is not of any inbuilt type, but this macro assumes so.\n" ), NULL) )
- #ifdef CAUTIOUS
- /** Assuming this is a Variable of any inbuilt type, set the value. It ensures the Variable is not complex.
- * Resolution order: pointer, short, int, float, double, pointer. */
- #define Variable_SetValueFromInbuilt( self, array_I, value ) \
- ( (self)->offsetCount == 1 ? \
- _Variable_SetValueFromInbuilt( (self), (array_I), (value) ) : \
- (void*)(Journal_Firewall( \
- 0, \
- Journal_Register( Error_Type, Variable_Type ), \
- "Variable is complex, but this macro assumes not so.\n" ), NULL) )
- #else
- /** Assuming this is a Variable of any inbuilt type, set the value. It DOES NOT ensure the Variable is not complex.
- * Resolution order: pointer, short, int, float, double, pointer. */
- #define Variable_SetValueFromInbuilt _Variable_SetValuefromInBuilt
- #endif
-
- /** Finds the new size of the array - replaces the limited ptr way of doing this. */
- Index _Variable_GetNewArraySize( Variable* self );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public Member functions: for any Variable
- */
-
- /** "Get" the requested data from the Variable that may be in an array. The returned value is a void*. If the Variable is
- * of a basic type, then the pointer to the scalar or the vector itself with the structure (if relevant) is returned. If
- * the Variable is of a complex type (i.e. it has more than one data component), then the pointer to the structure the
- * variable repesents is returned. */
- #define Variable_GetStructPtr _Variable_GetStructPtr
-
- /** Generic Variable "set". Works for any Variable. For complex Variables, the value must be the array of bytes of all the
- * data members concatenated (i.e. in marshalled form, not the structured form). Inherently slow operation. */
- void Variable_SetValue( void* variable, Index array_I, void* value );
-
- /** Generic Variable "get". Works for any Variable. For complex Variables, the value must be the array of already allocated
- * bytes of all the data members concatenated (i.e. in marshalled form, not the structured form). Inherently slow
- * operation. */
- void Variable_GetValue( void* variable, Index array_I, void* value );
-
- /** Updates the local members in variable from pointers
- * Used then the data is resized or extened.
- * If the data is an array which the array length is changed, this function expects the length */
- void Variable_Update( void* variable );
-
- /** Sets value to all entries in array of variable */
- void Variable_SetValueDoubleAll( void* variable, double value ) ;
-
- void Variable_SaveToFileAsDoubles( void* variable, char* filename );
-
- void Variable_ReadFromFileAsDoubles( void* variable, char* filename );
-
- /** Returns || variable - comparison || / || variable ||,
- * where ||x|| indicates the Euclidean Norm which is the square root of the sum of the squares for each component in x
- * i.e. ||x|| = \sqrt{\sum_i x_i^2}*/
- double Variable_ValueCompare( void* variable, void* _comparison );
- /** Checks whether || variable - comparison || / || variable || < tolerance */
- Bool Variable_ValueCompareWithinTolerance( void* variable, void* comparison, double tolerance );
-
-#endif /* __Base_Automation_Variable__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Variable.meta
--- a/Base/Automation/src/Variable.meta Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
-<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
-
-<param name="Name">Variable</param>
-<param name="Author">Steve Quenette</param>
-<param name="Organisation">VPAC</param>
-<param name="Project">StGermain</param>
-<param name="Location">./StGermain/Base/Automation/src/</param>
-<param name="Project Web">http://www.stgermainproject.org/</param>
-<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
-<param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
-<param name="Parent">Stg_Component</param>
-<param name="Reference"></param>
-<param name="Summary">Associates a textual label with a piece of data in memory, which can then be referred to via the Variable Register.</param>
-<param name="Description"><![CDATA[
-<p>Variable makes an association between a defined, textual name and a chunk of data in memory. This data could take the form of a basic type (such as an int or double), or an element of an array, or an entire array or struct. Variable may also index a regular series of non-contiguous locations in memory. This capability to define arbitrary data within a datastructure makes it very powerful.</p>
-
-<p>For example, a Variable can refer to a series of ints in an array with an offset of 1 and a stride of 3. This terminology will be familiar to those who are accustomed with MPI. Once a Variable is defined, it is stored in the Variable Register. Like other Registers of StGermain, it can be accessed by any other Component.
-</p>
-
-<p>The benefit of using Variable is that it provides access to data without the need for the original source code or linking to the header file. Practically everything you need to use the data is supplied by Variable: the memory location, a name for the data, its type and its size.</p>
-
-<p>When specified throught the XML system, the Variable will actually allocate the memory of the underlying memory variable itself. When used in the C API, the Variable must be passed the underlying memory chunk (but the memory chunk itself need not yet be allocated until just before the Variable undergoes its build phase).</p>
-
-<p>The XML implementation of Variable doesn't allow the specification of complex data types or arrays. For arrays, components such as MeshVariable should be used</p>
-]]>
-</param>
-
-
-<list name="Params">
- <struct>
- <param name="Name">DataType</param>
- <param name="Type">String</param>
- <param name="Default">[Double,Float,Int,Char,Short], None - not specifying causes an error</param>
- <param name="Description">Specifies the fundamental data type of the variable.</param>
- </struct>
- <struct>
- <param name="Name">Rank</param>
- <param name="Type">String</param>
- <param name="Default">[Scalar,Vector], None - not specifying causes an error</param>
- <param name="Description">Specifies whether the variable is of a vector not. If it is of a vector, VectorComponentCount and names is used to specify the number of vector subcomponents and the name of the variables to create for each component.</param>
- </struct>
- <struct>
- <param name="Name">VectorComponentCount</param>
- <param name="Type">UnsignedInt</param>
- <param name="Default">0</param>
- <param name="Description">The count of subcomponents inside this Variable that are also to become variables.</param>
- </struct>
- <struct>
- <param name="Name">names</param>
- <param name="Type">list</param>
- <param name="Default">(empty)</param>
- <param name="Description">The list of textual names for the subcomponents if this variable. A good example is a Variable named velocity which has the subcomponents vx, vy, vz.</param>
- </struct>
-</list>
-
-
-<list name="Dependencies">
-</list>
-
-
-<param name="Example"><![CDATA[
-<p>Examples:
-XML version / MDF (Model Description File):
-Unlike the C usage, MDF automatically handles memory allocation.
-</p>
-<p>
-<struct name="velocity">
- <param name="Type">Variable</param>
- <param name="Rank">Vector</param>
- <param name="DataType">Double</param>
- <param name="VectorComponentCount">3</param>
- <list name="names">
- <param>vx</param>
- <param>vy</param>
- <param>vz</param>
- </list>
-</struct>
-</p>
-<p>
-This example create an entry in the variable register of the name "velocity",
-which is a vector of 3 double components. Also, 3 more entries into the variable
- register will be made, targetting the 3 vector components of "velocity",
- named "vx", "vy", "vz".
-</p>
-
-<p>C version:
-Using Variable in C is different to the XML implementation because you need to
- do own memory handling.
-This example is based on the sourcecode in
-~/code/StGermain/Base/Automation/tests/testVariable.c </p>
-<p>
-/* Construct phase */
-double* velocity;
-Variable_NewVector("velocity",
- Variable_DataType_Double,
- 3,
- &aSize[1],
- (void**)&velocity,
- vr,
- "vx",
- "vy",
- "vz");
-
-/* Build phase*/
-velocity = malloc(...);
-component_Build(v);
-
-A general form of the C version:
-Variable_NewVector(name,
- type,
- length,
- array size,
- data array,
- variable register,
- [optional: list of names of array items]);
-</p>]]>
-</param>
-
-</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableAllVC.c
--- a/Base/Automation/src/VariableAllVC.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,589 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: VariableAllVC.c 2509 2005-01-10 23:39:07Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <mpi.h>
-
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "shortcuts.h"
-#include "Stg_Component.h"
-#include "Stg_ComponentFactory.h"
-#include "Variable.h"
-#include "Variable_Register.h"
-#include "ConditionFunction.h"
-#include "ConditionFunction_Register.h"
-#include "VariableCondition.h"
-#include "VariableAllVC.h"
-
-#include <string.h>
-#include <assert.h>
-
-
-const Type VariableAllVC_Type = "VariableAllVC";
-const Name defaultVariableAllVCName = "defaultVariableAllVCName";
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Constructor
-*/
-
-VariableCondition* VariableAllVC_Factory(
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data )
-{
- return (VariableCondition*)VariableAllVC_New( defaultVariableAllVCName, NULL, variable_Register, conFunc_Register, dictionary, data );
-}
-
-
-VariableAllVC* VariableAllVC_New(
- Name name,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data )
-{
- return _VariableAllVC_New(
- sizeof(VariableAllVC),
- VariableAllVC_Type,
- _VariableAllVC_Delete,
- _VariableAllVC_Print,
- _VariableAllVC_Copy,
- (Stg_Component_DefaultConstructorFunction*)VariableAllVC_DefaultNew,
- _VariableCondition_Construct,
- _VariableAllVC_Build,
- _VariableCondition_Initialise,
- _VariableCondition_Execute,
- _VariableCondition_Destroy,
- name,
- True,
- _VariableAllVC_BuildSelf,
- _VariableAllVC_PrintConcise,
- _VariableAllVC_ReadDictionary,
- _VariableAllVC_GetSet,
- _VariableAllVC_GetVariableCount,
- _VariableAllVC_GetVariableIndex,
- _VariableAllVC_GetValueIndex,
- _VariableAllVC_GetValueCount,
- _VariableAllVC_GetValue,
- _VariableCondition_Apply,
- _dictionaryEntryName,
- variable_Register,
- conFunc_Register,
- dictionary,
- data );
-}
-
-VariableAllVC* VariableAllVC_DefaultNew( Name name )
-{
- return (VariableAllVC*)_VariableAllVC_New(
- sizeof(VariableAllVC),
- VariableAllVC_Type,
- _VariableAllVC_Delete,
- _VariableAllVC_Print,
- _VariableAllVC_Copy,
- (Stg_Component_DefaultConstructorFunction*)VariableAllVC_DefaultNew,
- _VariableCondition_Construct,
- _VariableAllVC_Build,
- _VariableCondition_Initialise,
- _VariableCondition_Execute,
- _VariableCondition_Destroy,
- name,
- False,
- _VariableAllVC_BuildSelf,
- _VariableAllVC_PrintConcise,
- _VariableAllVC_ReadDictionary,
- _VariableAllVC_GetSet,
- _VariableAllVC_GetVariableCount,
- _VariableAllVC_GetVariableIndex,
- _VariableAllVC_GetValueIndex,
- _VariableAllVC_GetValueCount,
- _VariableAllVC_GetValue,
- _VariableCondition_Apply,
- NULL,
- NULL/*variable_Register*/,
- NULL/*conFunc_Register*/,
- NULL,
- NULL );
-}
-
-void VariableAllVC_Init(
- Name name,
- Name _dictionaryEntryName,
- VariableAllVC* self,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data )
-{
- /* General info */
- self->type = VariableAllVC_Type;
- self->_sizeOfSelf = sizeof(VariableAllVC);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _VariableAllVC_Delete;
- self->_print = _VariableAllVC_Print;
- self->_copy = _VariableAllVC_Copy;
- self->_build = _VariableAllVC_Build;
- self->_initialise = _VariableCondition_Initialise;
- self->_execute = _VariableCondition_Execute;
- self->_buildSelf = _VariableAllVC_BuildSelf;
- self->_printConcise = _VariableAllVC_PrintConcise;
- self->_readDictionary = _VariableAllVC_ReadDictionary;
- self->_getSet = _VariableAllVC_GetSet;
- self->_getVariableCount = _VariableAllVC_GetVariableCount;
- self->_getVariableIndex = _VariableAllVC_GetVariableIndex;
- self->_getValueIndex = _VariableAllVC_GetValueIndex;
- self->_getValueCount = _VariableAllVC_GetValueCount;
- self->_getValue = _VariableAllVC_GetValue;
- self->_apply = _VariableCondition_Apply;
-
- _Stg_Class_Init( (Stg_Class*)self );
- _Stg_Object_Init( (Stg_Object*)self, name, NON_GLOBAL );
- _Stg_Component_Init( (Stg_Component*)self );
- _VariableCondition_Init( (VariableCondition*)self, variable_Register, conFunc_Register, dictionary );
-
- /* Stg_Class info */
- _VariableAllVC_Init( self, _dictionaryEntryName, data );
-}
-
-
-VariableAllVC* _VariableAllVC_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc* _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data)
-{
- VariableAllVC* self;
-
- /* Allocate memory/General info */
- assert(_sizeOfSelf >= sizeof(VariableAllVC));
- self = (VariableAllVC*)_VariableCondition_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _defaultConstructor,
- _construct,
- _build,
- _initialise,
- _execute,
- _destroy,
- name,
- initFlag,
- _buildSelf,
- _printConcise,
- _readDictionary,
- _getSet,
- _getVariableCount,
- _getVariableIndex,
- _getValueIndex,
- _getValueCount,
- _getValue,
- _apply,
- variable_Register,
- conFunc_Register,
- dictionary );
-
- /* Virtual info */
-
- /* Stg_Class info */
- if( initFlag ){
- _VariableAllVC_Init( self, _dictionaryEntryName, data );
- }
-
- return self;
-}
-
-
-void _VariableAllVC_Init(
- void* allElementsVC,
- Name _dictionaryEntryName,
- void* data )
-{
- VariableAllVC* self = (VariableAllVC*)allElementsVC;
-
- self->isConstructed = True;
- self->_dictionaryEntryName = _dictionaryEntryName;
- self->data = data;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** General virtual functions
-*/
-
-void _VariableAllVC_ReadDictionary( void* variableCondition, void* dictionary ) {
- VariableAllVC* self = (VariableAllVC*)variableCondition;
- Dictionary_Entry_Value* vcDictVal;
- Dictionary_Entry_Value _vcDictVal;
- Dictionary_Entry_Value* varsVal;
- VariableAllVC_Entry_Index entry_I;
-
- /* Find dictionary entry */
- if (self->_dictionaryEntryName)
- vcDictVal = Dictionary_Get( dictionary, self->_dictionaryEntryName );
- else
- {
- vcDictVal = &_vcDictVal;
- Dictionary_Entry_Value_InitFromStruct( vcDictVal, dictionary );
- }
-
- if (vcDictVal)
- {
- /* Obtain the variable entries */
- self->_entryCount = Dictionary_Entry_Value_GetCount(Dictionary_Entry_Value_GetMember(vcDictVal, "variables"));
- self->_entryTbl = Memory_Alloc_Array( VariableAllVC_Entry, self->_entryCount, "VariableAllVC->_entryTbl" );
- varsVal = Dictionary_Entry_Value_GetMember(vcDictVal, "variables");
-
- for (entry_I = 0; entry_I < self->_entryCount; entry_I++)
- {
- char* valType;
- Dictionary_Entry_Value* valueEntry;
- Dictionary_Entry_Value* varDictListVal;
-
- varDictListVal = Dictionary_Entry_Value_GetElement(varsVal, entry_I);
- valueEntry = Dictionary_Entry_Value_GetMember(varDictListVal, "value");
-
- self->_entryTbl[entry_I].varName = Dictionary_Entry_Value_AsString(
- Dictionary_Entry_Value_GetMember(varDictListVal, "name"));
-
- valType = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(varDictListVal, "type"));
- if (!strcasecmp(valType, "func"))
- {
- char* funcName = Dictionary_Entry_Value_AsString(valueEntry);
-
- self->_entryTbl[entry_I].value.type = VC_ValueType_CFIndex;
- self->_entryTbl[entry_I].value.as.typeCFIndex = ConditionFunction_Register_GetIndex(
- self->conFunc_Register, funcName);
- }
- else if (!strcasecmp(valType, "array"))
- {
- Dictionary_Entry_Value* valueElement;
- Index i;
-
- self->_entryTbl[entry_I].value.type = VC_ValueType_DoubleArray;
- self->_entryTbl[entry_I].value.as.typeArray.size = Dictionary_Entry_Value_GetCount(valueEntry);
- self->_entryTbl[entry_I].value.as.typeArray.array = Memory_Alloc_Array( double,
- self->_entryTbl[entry_I].value.as.typeArray.size,"VariableAllVC->_entryTbl[].value.as.typeArray.array" );
-
- for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++)
- {
- valueElement = Dictionary_Entry_Value_GetElement(valueEntry, i);
- self->_entryTbl[entry_I].value.as.typeArray.array[i] =
- Dictionary_Entry_Value_AsDouble(valueElement);
- }
- }
- else if( !strcasecmp( valType, "double" ) || !strcasecmp( valType, "d" ) || !strcasecmp( valType, "float" ) || !strcasecmp( valType, "f" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
- self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
- }
- else if( !strcasecmp( valType, "integer" ) || !strcasecmp( valType, "int" ) || !strcasecmp( valType, "i" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Int;
- self->_entryTbl[entry_I].value.as.typeInt = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
- }
- else if( !strcasecmp( valType, "short" ) || !strcasecmp( valType, "s" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Short;
- self->_entryTbl[entry_I].value.as.typeShort = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
- }
- else if( !strcasecmp( valType, "char" ) || !strcasecmp( valType, "c" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Char;
- self->_entryTbl[entry_I].value.as.typeChar = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
- }
- else if( !strcasecmp( valType, "pointer" ) || !strcasecmp( valType, "ptr" ) || !strcasecmp( valType, "p" ) ) {
- self->_entryTbl[entry_I].value.type = VC_ValueType_Ptr;
- self->_entryTbl[entry_I].value.as.typePtr = (void*) ( (ArithPointer) Dictionary_Entry_Value_AsUnsignedInt( valueEntry ));
- }
- else {
- /* Assume double */
- Journal_DPrintf( Journal_Register( InfoStream_Type, "myStream" ), "Type to variable on variable condition not given, assuming double\n" );
- self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
- self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
- }
- }
- }
- else
- {
- self->_entryCount = 0;
- self->_entryTbl = NULL;
- }
-}
-
-
-void _VariableAllVC_Delete( void* allElementsVC ) {
- VariableAllVC* self = (VariableAllVC*)allElementsVC;
-
- if (self->_entryTbl) Memory_Free(self->_entryTbl);
-
- /* Stg_Class_Delete parent */
- _VariableCondition_Delete(self);
-}
-
-
-void _VariableAllVC_Print( void* allElementsVC, Stream* stream ) {
- VariableAllVC* self = (VariableAllVC*)allElementsVC;
- VariableAllVC_Entry_Index entry_I;
- Index i;
-
- /* Set the Journal for printing informations */
- Stream* info = stream;
-
- /* General info */
- Journal_Printf( info, "VariableAllVC (ptr): %p\n", self);
-
- /* Print parent */
- _VariableCondition_Print(self);
-
- /* Virtual info */
-
- /* Stg_Class info */
- Journal_Printf( info, "\tdictionary (ptr): %p\n", self->dictionary);
- Journal_Printf( info, "\t_dictionaryEntryName (ptr): %p\n", self->_dictionaryEntryName);
- if (self->_dictionaryEntryName)
- Journal_Printf( info, "\t\t_dictionaryEntryName: %s\n", self->_dictionaryEntryName);
- Journal_Printf( info, "\t_entryCount: %u\n", self->_entryCount);
- Journal_Printf( info, "\t_entryTbl (ptr): %p\n", self->_entryTbl);
- if( self->_entryTbl ) {
- for (entry_I = 0; entry_I < self->_entryCount; entry_I++)
- {
- Journal_Printf( info, "\t\t_entryTbl[%u]:\n", entry_I);
- Journal_Printf( info, "\t\t\tvarName (ptr): %p\n", self->_entryTbl[entry_I].varName);
- if (self->_entryTbl[entry_I].varName)
- Journal_Printf( info, "\t\t\t\tvarName: %s\n", self->_entryTbl[entry_I].varName);
- Journal_Printf( info, "\t\t\tvalue:\n");
- switch (self->_entryTbl[entry_I].value.type)
- {
- case VC_ValueType_Double:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Double\n" );
- Journal_Printf( info, "\t\t\t\tasDouble: %g\n", self->_entryTbl[entry_I].value.as.typeDouble );
- break;
-
- case VC_ValueType_Int:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Int\n" );
- Journal_Printf( info, "\t\t\t\tasInt: %i\n", self->_entryTbl[entry_I].value.as.typeInt );
- break;
-
- case VC_ValueType_Short:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Short\n" );
- Journal_Printf( info, "\t\t\t\tasShort: %i\n", self->_entryTbl[entry_I].value.as.typeShort );
- break;
-
- case VC_ValueType_Char:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Char\n");
- Journal_Printf( info, "\t\t\t\tasChar: %c\n", self->_entryTbl[entry_I].value.as.typeChar );
- break;
-
- case VC_ValueType_Ptr:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Ptr\n");
- Journal_Printf( info, "\t\t\t\tasPtr: %g\n", self->_entryTbl[entry_I].value.as.typePtr );
- break;
-
- case VC_ValueType_DoubleArray:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_DoubleArray\n");
- Journal_Printf( info, "\t\t\t\tarraySize: %u\n", self->_entryTbl[entry_I].value.as.typeArray.size);
- Journal_Printf( info, "\t\t\t\tasDoubleArray (ptr): %p\n",
- self->_entryTbl[entry_I].value.as.typeArray.array);
- if (self->_entryTbl[entry_I].value.as.typeArray.array)
- for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++)
- Journal_Printf( info, "\t\t\t\tasDoubleArray[%u]: %g\n", i,
- self->_entryTbl[entry_I].value.as.typeArray.array[i]);
- break;
-
- case VC_ValueType_CFIndex:
- Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_CFIndex\n");
- Journal_Printf( info, "\t\t\t\tasCFIndex: %u\n", self->_entryTbl[entry_I].value.as.typeCFIndex);
- break;
- }
- }
- }
-}
-
-
-void* _VariableAllVC_Copy( void* allElementsVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
- VariableAllVC* self = (VariableAllVC*)allElementsVC;
- VariableAllVC* newVariableAllVC;
- PtrMap* map = ptrMap;
- Bool ownMap = False;
-
- if( !map ) {
- map = PtrMap_New( 10 );
- ownMap = True;
- }
-
- newVariableAllVC = (VariableAllVC*)_VariableCondition_Copy( self, dest, deep, nameExt, map );
-
- newVariableAllVC->_dictionaryEntryName = self->_dictionaryEntryName;
- newVariableAllVC->_entryCount = self->_entryCount;
-
- if( deep ) {
- newVariableAllVC->data = Stg_Class_Copy( self->data, NULL, deep, nameExt, map );
-
- if( (newVariableAllVC->_entryTbl = PtrMap_Find( map, self->_entryTbl )) == NULL && self->_entryTbl ) {
- newVariableAllVC->_entryTbl = Memory_Alloc_Array( VariableAllVC_Entry, newVariableAllVC->_entryCount, "VariableAllVC->_entryTbl");
- memcpy( newVariableAllVC->_entryTbl, self->_entryTbl, sizeof(VariableAllVC_Entry) * newVariableAllVC->_entryCount );
- PtrMap_Append( map, newVariableAllVC->_entryTbl, self->_entryTbl );
- }
- }
- else {
- newVariableAllVC->data = self->data;
- newVariableAllVC->_entryTbl = self->_entryTbl;
- }
-
- if( ownMap ) {
- Stg_Class_Delete( map );
- }
-
- return (void*)newVariableAllVC;
-}
-
-
-void _VariableAllVC_Build( void* allElementsVC, void* data ) {
- VariableAllVC* self = (VariableAllVC*)allElementsVC;
-
- _VariableAllVC_BuildSelf( self, data );
-
- _VariableCondition_Build( self, data );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Macros
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _VariableAllVC_BuildSelf( void* allElementsVC, void* data ) {
- VariableAllVC* self = (VariableAllVC*)allElementsVC;
-
- if( self->data ) {
- Stg_Component_Build( self->data, data, False );
- }
-}
-
-
-IndexSet* _VariableAllVC_GetSet( void* variableCondition ) {
- VariableAllVC* self = (VariableAllVC*)variableCondition;
- Variable* var = self->variable_Register->_variable[0];
- IndexSet* set = IndexSet_New( var->arraySize );
-
- IndexSet_AddAll( set );
-
- return set;
-}
-
-
-VariableCondition_VariableIndex _VariableAllVC_GetVariableCount( void* variableCondition, Index globalIndex ) {
- VariableAllVC* self = (VariableAllVC*)variableCondition;
-
- return self->_entryCount;
-}
-
-
-Variable_Index _VariableAllVC_GetVariableIndex(
- void* variableCondition,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex)
-{
- VariableAllVC* self = (VariableAllVC*)variableCondition;
-
- return Variable_Register_GetIndex(self->variable_Register, self->_entryTbl[varIndex].varName);
-}
-
-
-VariableCondition_ValueIndex _VariableAllVC_GetValueIndex(
- void* variableCondition,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex)
-{
- return varIndex;
-}
-
-
-VariableCondition_ValueIndex _VariableAllVC_GetValueCount( void* variableCondition ) {
- VariableAllVC* self = (VariableAllVC*)variableCondition;
-
- return self->_entryCount;
-}
-
-
-VariableCondition_Value _VariableAllVC_GetValue( void* variableCondition, VariableCondition_ValueIndex valIndex ) {
- VariableAllVC* self = (VariableAllVC*)variableCondition;
-
- return self->_entryTbl[valIndex].value;
-}
-
-void _VariableAllVC_PrintConcise( void* variableCondition, Stream* stream ) {
- VariableAllVC* self = (VariableAllVC*)variableCondition;
-
- Journal_Printf( stream, "\ttype: %s, set: all\n", self->type );
-}
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Build functions
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Functions
-*/
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableAllVC.h
--- a/Base/Automation/src/VariableAllVC.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,195 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Comments:
-**
-** $Id: VariableAllVC.h 2509 2005-01-10 23:39:07Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Base_Automation_VariableAllVC_h__
-#define __Base_Automation_VariableAllVC_h__
-
-
- extern const Type VariableAllVC_Type;
-
-
- #define __VariableAllVC_Entry \
- Name varName; \
- VariableCondition_Value value; \
-
- struct _VariableAllVC_Entry { __VariableAllVC_Entry };
-
-
- #define __VariableAllVC \
- /* General info */ \
- __VariableCondition \
- \
- /* Virtual info */ \
- \
- /* Stg_Class info */ \
- Name _dictionaryEntryName; \
- VariableAllVC_Entry_Index _entryCount; \
- VariableAllVC_Entry* _entryTbl; \
- void* data;
-
- struct _VariableAllVC { __VariableAllVC };
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructor
- */
-
- VariableCondition* VariableAllVC_Factory(
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* data );
-
- VariableAllVC* VariableAllVC_New(
- Name name,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* mesh );
-
- void VariableAllVC_Init(
- Name name,
- Name _dictionaryEntryName,
- VariableAllVC* self,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* mesh );
-
- VariableAllVC* VariableAllVC_DefaultNew( Name name );
-
- VariableAllVC* _VariableAllVC_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc* _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Name _dictionaryEntryName,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary,
- void* mesh );
-
- void _VariableAllVC_Init(
- void* allElementsVC,
- Name _dictionaryEntryName,
- void* mesh );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** General virtual functions
- */
-
- void _VariableAllVC_Delete( void* allElementsVC );
-
- void _VariableAllVC_Print( void* allElementsVC, Stream* stream );
-
- /* Copy */
- #define VariableAllVC_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
- #define VariableAllVC_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
-
- void* _VariableAllVC_Copy( void* allElementsVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
-
- void _VariableAllVC_Build( void* allElementsVC, void* data );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Macros
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _VariableAllVC_BuildSelf( void* allElementsVC, void* data );
-
- void _VariableAllVC_ReadDictionary( void* variableCondition, void* dictionary );
-
- IndexSet* _VariableAllVC_GetSet( void* variableCondition );
-
- VariableCondition_VariableIndex _VariableAllVC_GetVariableCount( void* variableCondition, Index globalIndex );
-
- Variable_Index _VariableAllVC_GetVariableIndex(
- void* variableCondition,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex );
-
- VariableCondition_ValueIndex _VariableAllVC_GetValueIndex(
- void* variableCondition,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex );
-
- VariableCondition_ValueIndex _VariableAllVC_GetValueCount( void* variableCondition );
-
- VariableCondition_Value _VariableAllVC_GetValue( void* variableCondition, VariableCondition_ValueIndex valIndex );
-
- void _VariableAllVC_PrintConcise( void* variableCondition, Stream* stream );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Build functions
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Functions
- */
-
-
-#endif /* __Base_Automation_VariableAllVC_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableAllVC.meta
--- a/Base/Automation/src/VariableAllVC.meta Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
-<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
-
-<param name="Name">VariableAllVC</param>
- <param name="Author">...</param>
- <param name="Organisation">VPAC</param>
- <param name="Project">StGermain</param>
- <param name="Location">./StGermain/Base/Automation/src/</param>
- <param name="Project Web">http://www.stgermainproject.org/</param>
- <param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
- <param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
- <param name="Parent">VariableCondition</param>
- <param name="Reference">...</param>
- <param name="Summary">...</param>
-
- <param name="Description">
- Selects all available entries in a Variable object to have a value
- applied.
- </param>
-
- <list name="Params">
- <struct>
- <param name="Name">variables</param>
- <param name="Type">List</param>
- <param name="Default"></param>
- <param name="Description">
- A list of variable structures describing a Variable object to have values set and
- the values to apply. Each structure has three parameters: 'name' (the name of the
- Variable object), 'type' (the type of the value, either double or func) and 'value'
- (for a double this is a number and for a func this is the name of the condition
- function).
- </param>
- </struct>
- </list>
-
- <list name="Dependencies">
- n/a
- </list>
-
- <param name="Example">
- n/a
- </param>
-
-</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableCondition.c
--- a/Base/Automation/src/VariableCondition.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,777 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: VariableCondition.c 4297 2008-08-19 16:54:05Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "shortcuts.h"
-#include "Stg_Component.h"
-#include "Stg_ComponentFactory.h"
-#include "Variable.h"
-#include "Variable_Register.h"
-#include "ConditionFunction.h"
-#include "ConditionFunction_Register.h"
-#include "VariableCondition.h"
-
-#include <string.h>
-#include <assert.h>
-
-/** Textual name of this class */
-const Type VariableCondition_Type = "VariableCondition";
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Constructor
-*/
-
-VariableCondition* _VariableCondition_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary )
-{
- VariableCondition* self;
-
- /* Allocate memory/General info */
- assert(_sizeOfSelf >= sizeof(VariableCondition));
- self = (VariableCondition*)_Stg_Component_New( _sizeOfSelf, type, _delete, _print, _copy, _defaultConstructor,
- _construct, _build, _initialise, _execute, _destroy, name, NON_GLOBAL );
-
- /* Virtual info */
- self->_buildSelf = _buildSelf;
- self->_printConcise = _printConcise;
- self->_readDictionary = _readDictionary;
- self->_getSet = _getSet;
- self->_getVariableCount = _getVariableCount;
- self->_getVariableIndex = _getVariableIndex;
- self->_getValueIndex = _getValueIndex;
- self->_getValueCount = _getValueCount;
- self->_getValue = _getValue;
- self->_apply = _apply;
-
- /* Stg_Class info */
- if( initFlag ){
- _VariableCondition_Init( self, variable_Register, conFunc_Register, dictionary );
- }
-
- return self;
-}
-
-
-void _VariableCondition_Init(
- void* variableCondition,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary )
-{
- VariableCondition* self = (VariableCondition*)variableCondition;
-
- self->isConstructed = True;
- self->variable_Register = variable_Register;
- self->conFunc_Register = conFunc_Register;
- self->dictionary = dictionary;
- self->_set = NULL;
- self->indexCount = 0;
- self->indexTbl = NULL;
- self->vcVarCountTbl = NULL;
- self->vcTbl = NULL;
- self->valueCount = 0;
- self->valueTbl = NULL;
- self->mapping = NULL;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** General virtual functions
-*/
-
-void _VariableCondition_Delete(void* variableCondition)
-{
- VariableCondition* self = (VariableCondition*)variableCondition;
-
- if (self->_set) Stg_Class_Delete(self->_set);
- if (self->indexTbl) Memory_Free(self->indexTbl);
- if (self->vcVarCountTbl) Memory_Free(self->vcVarCountTbl);
- if (self->valueTbl) Memory_Free(self->valueTbl);
-
- /* Stg_Class_Delete parent */
- _Stg_Component_Delete( self );
-}
-
-
-void _VariableCondition_Print(void* variableCondition)
-{
- VariableCondition* self = (VariableCondition*)variableCondition;
- VariableCondition_VariableIndex vcVar_I;
- VariableCondition_ValueIndex val_I;
- Index i;
-
- /* Set the Journal for printing informations */
- Stream* variableConditionStream = Journal_Register( InfoStream_Type, "VariableConditionStream");
-
- /* General info */
- Journal_Printf( variableConditionStream, "VariableCondition (ptr): %p\n", self);
-
- /* Print parent */
- _Stg_Component_Print( self, variableConditionStream );
-
- /* Virtual info */
- Journal_Printf( variableConditionStream, "\t_getSet (func ptr): %p\n", self->_getSet);
- Journal_Printf( variableConditionStream, "\t_getVariableCount (func ptr): %p\n", self->_getVariableCount);
- Journal_Printf( variableConditionStream, "\t_getVariableIndex (func ptr): %p\n", self->_getVariableIndex);
- Journal_Printf( variableConditionStream, "\t_getValueIndex (func ptr): %p\n", self->_getValueIndex);
- Journal_Printf( variableConditionStream, "\t_getValueCount (func ptr): %p\n", self->_getValueCount);
- Journal_Printf( variableConditionStream, "\t_getValue (func ptr): %p\n", self->_getValue);
-
- /* Stg_Class info */
- Journal_Printf( variableConditionStream, "\tvariable_Register (ptr): %p\n", self->variable_Register);
- Journal_Printf( variableConditionStream, "\tconFunc_Register (ptr): %p\n", self->conFunc_Register);
- Journal_Printf( variableConditionStream, "\t_set (ptr): %p\n", self->_set);
- Journal_Printf( variableConditionStream, "\tindexCount: %u\n", self->indexCount);
- Journal_Printf( variableConditionStream, "\tindexTbl (ptr): %p\n", self->indexTbl);
- if (self->indexTbl)
- for (i = 0; i < self->indexCount; i++)
- Journal_Printf( variableConditionStream, "\t\tindexTbl[%u]: %u\n", i, self->indexTbl[i]);
- Journal_Printf( variableConditionStream, "\tvcVarCountTbl (ptr): %p\n", self->vcVarCountTbl);
- if (self->vcVarCountTbl)
- for (i = 0; i < self->indexCount; i++)
- Journal_Printf( variableConditionStream, "\t\tvcVarCountTbl[%u]: %u\n", i, self->vcVarCountTbl[i]);
- Journal_Printf( variableConditionStream, "\tvcTbl (ptr): %p\n", self->vcTbl);
- if (self->vcTbl)
- for (i = 0; i < self->indexCount; i++)
- for (vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++)
- {
- Journal_Printf( variableConditionStream, "\t\tvcTbl[%u][%u]:\n", i, vcVar_I);
- Journal_Printf( variableConditionStream, "\t\t\tvarIndex: %u\n", self->vcTbl[i][vcVar_I].varIndex);
- Journal_Printf( variableConditionStream, "\t\t\tvalIndex: %u\n", self->vcTbl[i][vcVar_I].valIndex);
- }
- Journal_Printf( variableConditionStream, "\tvalueCount: %u\n", self->valueCount);
- Journal_Printf( variableConditionStream, "\tvalueTbl (ptr): %p\n", self->valueTbl);
- if( self->valueTbl ) {
- for (val_I = 0; val_I < self->valueCount; val_I++)
- {
- Journal_Printf( variableConditionStream, "\t\tvalueTbl[%u]:\n", val_I);
- switch (self->valueTbl[val_I].type)
- {
- case VC_ValueType_Double:
- Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Double\n" );
- Journal_Printf( variableConditionStream, "\t\t\tasDouble: %g\n", self->valueTbl[val_I].as.typeDouble );
- break;
-
- case VC_ValueType_Int:
- Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Int\n" );
- Journal_Printf( variableConditionStream, "\t\t\tasInt: %i\n", self->valueTbl[val_I].as.typeInt );
- break;
-
- case VC_ValueType_Short:
- Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Short\n" );
- Journal_Printf( variableConditionStream, "\t\t\tasShort: %i\n", self->valueTbl[val_I].as.typeShort );
- break;
-
- case VC_ValueType_Char:
- Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Char\n");
- Journal_Printf( variableConditionStream, "\t\t\tasChar: %c\n", self->valueTbl[val_I].as.typeChar );
- break;
-
- case VC_ValueType_Ptr:
- Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Ptr\n");
- Journal_Printf( variableConditionStream, "\t\t\tasPtr: %g\n", self->valueTbl[val_I].as.typePtr );
- break;
-
- case VC_ValueType_DoubleArray:
- Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_DoubleArray\n");
- Journal_Printf( variableConditionStream, "\t\t\tarraySize: %u\n", self->valueTbl[val_I].as.typeArray.size);
- Journal_Printf( variableConditionStream, "\t\t\tasDoubleArray (ptr): %p\n", self->valueTbl[val_I].as.typeArray.array);
- if (self->valueTbl[val_I].as.typeArray.array)
- for (i = 0; i < self->valueTbl[val_I].as.typeArray.size; i++)
- Journal_Printf( variableConditionStream, "\t\t\t\tasDoubleArray[%u]: %g\n", i,
- self->valueTbl[val_I].as.typeArray.array[i]);
- break;
-
- case VC_ValueType_CFIndex:
- Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_CFIndex\n");
- Journal_Printf( variableConditionStream, "\t\t\tasCFIndex: %u\n", self->valueTbl[val_I].as.typeCFIndex);
- break;
- }
- }
- }
-}
-
-
-void* _VariableCondition_Copy( void* variableCondition, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
- VariableCondition* newVariableCondition;
- PtrMap* map = ptrMap;
- Bool ownMap = False;
-
- if( !map ) {
- map = PtrMap_New( 10 );
- ownMap = True;
- }
-
- newVariableCondition = (VariableCondition*)_Stg_Component_Copy( self, dest, deep, nameExt, map );
-
- /* Virtual methods */
- newVariableCondition->_buildSelf = self->_buildSelf;
- newVariableCondition->_printConcise = self->_printConcise;
- newVariableCondition->_readDictionary = self->_readDictionary;
- newVariableCondition->_getSet = self->_getSet;
- newVariableCondition->_getVariableCount = self->_getVariableCount;
- newVariableCondition->_getVariableIndex = self->_getVariableIndex;
- newVariableCondition->_getValueIndex = self->_getValueIndex;
- newVariableCondition->_getValueCount = self->_getValueCount;
- newVariableCondition->_getValue = self->_getValue;
-
- newVariableCondition->variable_Register = self->variable_Register;
- newVariableCondition->conFunc_Register = self->conFunc_Register;
- newVariableCondition->dictionary = self->dictionary;
- newVariableCondition->indexCount = self->indexCount;
- newVariableCondition->valueCount = self->valueCount;
-
- if( deep ) {
- newVariableCondition->_set = (IndexSet*)Stg_Class_Copy( self->_set, NULL, deep, nameExt, map );
-
- if( (newVariableCondition->indexTbl = PtrMap_Find( map, self->indexTbl )) == NULL && self->indexTbl ) {
- newVariableCondition->indexTbl = (Index*)Memory_Alloc_Array( Index, newVariableCondition->indexCount, "VariableCondition->indexTbl" );
- memcpy( newVariableCondition->indexTbl, self->indexTbl, sizeof(Index) * newVariableCondition->indexCount );
- PtrMap_Append( map, newVariableCondition->indexTbl, self->indexTbl );
- }
-
- if( (newVariableCondition->vcVarCountTbl = PtrMap_Find( map, self->vcVarCountTbl )) == NULL && self->vcVarCountTbl ) {
- newVariableCondition->vcVarCountTbl = Memory_Alloc_Array( VariableCondition_VariableIndex, newVariableCondition->indexCount, "VC->vcVarCountTbl" );
- memcpy( newVariableCondition->vcVarCountTbl, self->vcVarCountTbl, sizeof(VariableCondition_VariableIndex) * newVariableCondition->indexCount );
- PtrMap_Append( map, newVariableCondition->vcVarCountTbl, self->vcVarCountTbl );
- }
-
- if( (newVariableCondition->vcTbl = PtrMap_Find( map, self->vcTbl )) == NULL && self->vcTbl ) {
- Index idx_I;
-
- newVariableCondition->vcTbl = Memory_Alloc_2DComplex( VariableCondition_Tuple, newVariableCondition->indexCount, newVariableCondition->vcVarCountTbl, "VC->vcTbl" );
- for( idx_I = 0; idx_I < newVariableCondition->indexCount; idx_I++ ) {
- memcpy( newVariableCondition->vcTbl[idx_I], self->vcTbl[idx_I], sizeof(VariableCondition_Tuple) * newVariableCondition->vcVarCountTbl[idx_I] );
- }
- PtrMap_Append( map, newVariableCondition->vcTbl, self->vcTbl );
- }
-
- if( (newVariableCondition->valueTbl = PtrMap_Find( map, self->valueTbl )) == NULL && self->valueTbl ) {
- newVariableCondition->valueTbl = Memory_Alloc_Array( VariableCondition_Value, newVariableCondition->valueCount, "VC->valueTbl" );
- memcpy( newVariableCondition->valueTbl, self->valueTbl, sizeof(VariableCondition_Value) * newVariableCondition->indexCount );
- PtrMap_Append( map, newVariableCondition->valueTbl, self->valueTbl );
- }
- }
- else {
- newVariableCondition->_set = self->_set;
- newVariableCondition->indexTbl = self->indexTbl;
- newVariableCondition->vcVarCountTbl = self->vcVarCountTbl;
- newVariableCondition->vcTbl = self->vcTbl;
- newVariableCondition->valueTbl = self->valueTbl;
- }
-
- if( ownMap ) {
- Stg_Class_Delete( map );
- }
-
- return (void*)newVariableCondition;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Macros
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Build functions
-*/
-
-void _VariableCondition_Construct( void* variableCondition, Stg_ComponentFactory* cf, void* data ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
-}
-
-void _VariableCondition_Build( void* variableCondition, void* data ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
- VariableCondition_ValueIndex val_I;
- Index i;
-
- /* Read the dictionary */
- self->_readDictionary( self, self->dictionary );
-
- /* Obtain the set */
- self->_set = self->_getSet(self);
- if (self->_set)
- IndexSet_GetMembers(self->_set, &self->indexCount, &self->indexTbl);
- else
- {
- self->indexCount = 0;
- self->indexTbl = NULL;
- }
-
- /* Only build the index related tables if there are active BCs */
- if ( self->indexCount ) {
- /* Build the variable to condition table */
- self->vcVarCountTbl = Memory_Alloc_Array( VariableCondition_VariableIndex, self->indexCount, "VC->vcVarCountTbl" );
-
- for (i = 0; i < self->indexCount; i++)
- {
- /* For the index, get the number of "variables" that have been assigned conditions */
- self->vcVarCountTbl[i] = self->_getVariableCount(self, self->indexTbl[i]);
- }
-
- self->vcTbl = Memory_Alloc_2DComplex( VariableCondition_Tuple, self->indexCount, self->vcVarCountTbl, "VC->vcTbl" );
- for ( i = 0; i < self->indexCount; i++ )
- {
- VariableCondition_VariableIndex vcVar_I;
-
- for ( vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++ )
- {
- Variable* var;
-
- /* For the index's variable, get the variable i.d. and value i.d. */
- self->vcTbl[i][vcVar_I].varIndex = self->_getVariableIndex(self, self->indexTbl[i], vcVar_I);
- self->vcTbl[i][vcVar_I].valIndex = self->_getValueIndex(self, self->indexTbl[i], vcVar_I);
-
- /* Force the building of the variable (to be safe) */
- var = self->variable_Register->_variable[self->vcTbl[i][vcVar_I].varIndex];
- Stg_Component_Build( var, data, False );
- }
- }
- }
-
- self->valueCount = self->_getValueCount(self);
- self->valueTbl = Memory_Alloc_Array( VariableCondition_Value, self->valueCount, "VC->valueTbl" );
- for (val_I = 0; val_I < self->valueCount; val_I++)
- self->valueTbl[val_I] = self->_getValue(self, val_I);
-
- /* Build mapping. */
- self->mapping = UIntMap_New();
- for( i = 0; i < self->indexCount; i++ )
- UIntMap_Insert( self->mapping, self->indexTbl[i], i );
-}
-
-void _VariableCondition_Initialise( void* variableCondition, void* data ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
- Index i;
-
- for( i = 0; i < self->indexCount; i++ ) {
- VariableCondition_VariableIndex vcVar_I;
-
- for( vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++ ) {
- Variable* var;
-
- /* Force the building of the variable (to be safe) */
- var = self->variable_Register->_variable[self->vcTbl[i][vcVar_I].varIndex];
- Stg_Component_Initialise( var, data, False );
- }
- }
-}
-
-void _VariableCondition_Execute( void* variableCondition, void* data ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
-
- VariableCondition_Apply( self, data );
-}
-
-void _VariableCondition_Destroy( void* variableCondition, void* data )
-{
-
-}
-
-void _VariableCondition_Apply( void* variableCondition, void* context ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
- Index i;
-
- for (i = 0; i < self->indexCount; i++)
- VariableCondition_ApplyToIndex(variableCondition, self->indexTbl[i], context);
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Functions
-*/
-
-void VariableCondition_Apply( void* variableCondition, void* context ) {
- assert( variableCondition );
- ((VariableCondition*)variableCondition)->_apply( variableCondition, context );
-}
-
-
-void VariableCondition_ApplyToVariable( void* variableCondition, VariableCondition_VariableIndex varIndex, void* context ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
- Index i;
-
- for (i = 0; i < self->indexCount; i++)
- VariableCondition_ApplyToIndexVariable(variableCondition, self->indexTbl[i], varIndex, context);
-}
-
-
-void VariableCondition_ApplyToIndex( void* variableCondition, Index localIndex, void* context ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
- Variable* var;
- Variable_Index varIndex;
- VariableCondition_ValueIndex val_I;
- ConditionFunction* cf;
- Index index, i;
- Stream* errorStr = Journal_Register( Error_Type, self->type );
-
- /* Ensure that the index provided (localIndex) has a condition attached to it */
- insist( UIntMap_Map( self->mapping, localIndex, &index ), == True );
-
- /* For each variable that has a condition at this index */
- for (i = 0; i < self->vcVarCountTbl[index]; i++)
- {
- varIndex = self->vcTbl[index][i].varIndex;
- assert( varIndex != (unsigned)-1 );
-
- var = self->variable_Register->_variable[varIndex];
-
- val_I = self->vcTbl[index][i].valIndex;
- assert( val_I != (unsigned)-1 );
-
- switch (self->valueTbl[val_I].type)
- {
- case VC_ValueType_Double:
- Journal_Firewall( var->dataTypeCounts[0] == 1, errorStr,
- "Error - in %s: while applying values for variable condition "
- "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
- "which has %d components. Specify a scalar Variable instead.\n",
- __func__, self->name, self->indexTbl[index], "double",
- var->name, var->dataTypeCounts[0] );
- Variable_SetValueDouble(
- var,
- self->indexTbl[index],
- self->valueTbl[val_I].as.typeDouble );
- break;
-
- case VC_ValueType_DoubleArray:
- Variable_SetValue(
- var,
- self->indexTbl[index],
- self->valueTbl[val_I].as.typeArray.array );
- break;
-
- case VC_ValueType_CFIndex:
- Journal_Firewall( self->valueTbl[val_I].as.typeCFIndex != (unsigned)-1, errorStr,
- "Error - in %s: trying to apply to index %d of variable \"%s\", which "
- "is supposed to be a condition function, but the cond. func. wasn't "
- "found in the c.f. register.\n", __func__, localIndex, var->name );
- cf = self->conFunc_Register->_cf[self->valueTbl[val_I].as.typeCFIndex];
- ConditionFunction_Apply(
- cf,
- localIndex,
- varIndex,
- context,
- Variable_GetStructPtr( var, self->indexTbl[index] ) );
- break;
-
- case VC_ValueType_Int:
- Journal_Firewall( var->dataTypeCounts[0] == 1, errorStr,
- "Error - in %s: while applying values for variable condition "
- "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
- "which has %d components. Specify a scalar Variable instead.\n",
- __func__, self->name, self->indexTbl[index], "int",
- var->name, var->dataTypeCounts[0] );
- Variable_SetValueInt(
- var,
- self->indexTbl[index],
- self->valueTbl[val_I].as.typeInt );
- break;
-
- case VC_ValueType_Short:
- Journal_Firewall( var->dataTypeCounts[0] == 1, errorStr,
- "Error - in %s: while applying values for variable condition "
- "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
- "which has %d components. Specify a scalar Variable instead.\n",
- __func__, self->name, self->indexTbl[index], "short",
- var->name, var->dataTypeCounts[0] );
- Variable_SetValueShort(
- var,
- self->indexTbl[index],
- self->valueTbl[val_I].as.typeShort );
- break;
-
- case VC_ValueType_Char:
- Journal_Firewall( var->dataTypeCounts[0] == 1, errorStr,
- "Error - in %s: while applying values for variable condition "
- "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
- "which has %d components. Specify a scalar Variable instead.\n",
- __func__, self->name, self->indexTbl[index], "char",
- var->name, var->dataTypeCounts[0] );
- Variable_SetValueChar(
- var,
- self->indexTbl[index],
- self->valueTbl[val_I].as.typeChar );
- break;
-
- case VC_ValueType_Ptr:
- Variable_SetValuePointer(
- var,
- self->indexTbl[index],
- self->valueTbl[val_I].as.typePtr );
- break;
-
- default:
- assert(0);
- break;
- }
- }
-}
-
-
-void VariableCondition_ApplyToIndexVariable(
- void* variableCondition,
- Index localIndex,
- VariableCondition_VariableIndex varIndex,
- void* context )
-{
- VariableCondition* self = (VariableCondition*)variableCondition;
- Variable_Index globalVarIndex;
- Variable* var;
- ConditionFunction* cf;
- Index index;
-
-/*
- * NOTE: This algorithm here is RIDICULOUSLY slow. I've added a mapping
- * to the class, that should help.
-
- for (index = 0; index < self->indexCount; index++)
- if (self->indexTbl[index] == localIndex)
- break;
-*/
-
- if(!UIntMap_Map( self->mapping, localIndex, &index ))
- return;
-
- globalVarIndex = self->vcTbl[index][varIndex].varIndex;
- var = self->variable_Register->_variable[globalVarIndex];
-
- switch (self->valueTbl[self->vcTbl[index][varIndex].valIndex].type)
- {
- case VC_ValueType_Double:
- Variable_SetValueDouble(
- var,
- self->indexTbl[index],
- self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeDouble );
- break;
-
- case VC_ValueType_CFIndex:
- cf = self->conFunc_Register->_cf[self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeCFIndex];
- ConditionFunction_Apply(
- cf,
- localIndex,
- globalVarIndex,
- context,
- Variable_GetStructPtr( var, self->indexTbl[index]) );
- break;
-
- case VC_ValueType_DoubleArray:
- Variable_SetValue(
- var,
- self->indexTbl[index],
- self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeArray.array );
- break;
-
- case VC_ValueType_Int:
- Variable_SetValueInt(
- var,
- self->indexTbl[index],
- self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeInt );
- break;
-
- case VC_ValueType_Short:
- Variable_SetValueShort(
- var,
- self->indexTbl[index],
- self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeShort );
- break;
-
- case VC_ValueType_Char:
- Variable_SetValueChar(
- var,
- self->indexTbl[index],
- self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeChar );
- break;
-
- case VC_ValueType_Ptr:
- Variable_SetValuePointer(
- var,
- self->indexTbl[index],
- self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typePtr );
- break;
-
- default:
- assert(0);
- break;
- }
-}
-
-
-Bool VariableCondition_IsCondition( void* variableCondition, Index localIndex, Variable_Index inputVarIndex ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
- VariableCondition_VariableIndex vcVar_I;
- Index i;
- Variable_Index varIndexToTryMatch = 0;
- Variable_Index subVarIndexToTryMatch = 0;
- Variable* variableToTryMatch = NULL;
- Variable* subVariableToTryMatch = NULL;
- Variable_Index subVariable_I = 0;
-
- /* if the set isn't initialised, this is a NULL BC : False */
- if ( !self->_set ) {
- return False;
- }
-
- /* first check if the index they've given us is actually in the list this VC applies to */
- /* quick check, since we have the set available */
- if ( localIndex >= self->_set->size ) {
- Stream* warning = Journal_Register( ErrorStream_Type, self->type );
- Journal_Printf( warning, "Error- In %s: Tried to check an index %d larger than the size of "
- "the set (%d).\n", __func__, localIndex, self->_set->size );
- assert(0);
- return False;
- }
-
- if(!UIntMap_Map( self->mapping, localIndex, &i ))
- return False;
-/*
- if ( !IndexSet_IsMember( self->_set, localIndex ) ) {
- return False;
- }
- for (i = 0; i < self->indexCount; i++)
- if (self->indexTbl[i] == localIndex)
- break;
-
- if (i == self->indexCount)
- return False;
-*/
-
- /* now check if the Variable they've given us is actually in the list to apply at the given index */
- for (vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++) {
- varIndexToTryMatch = self->vcTbl[i][vcVar_I].varIndex;
- variableToTryMatch = self->variable_Register->_variable[varIndexToTryMatch];
-
- if ( varIndexToTryMatch == inputVarIndex) {
- return True;
- }
- else if ( variableToTryMatch->subVariablesCount >= 1 ) {
- /* 2nd chance draw is that if this Var has sub-components, we should test if the input argument is
- * actually one of those - in which case we should consider it has a condition applied to it. */
-
- for ( subVariable_I = 0; subVariable_I < variableToTryMatch->subVariablesCount; subVariable_I++ ) {
- /* TODO: next few lines bit slow! Maybe need to cache subvar indices on variable */
- subVariableToTryMatch = variableToTryMatch->components[subVariable_I];
- if ( subVariableToTryMatch == NULL ) continue;
-
- subVarIndexToTryMatch = Variable_Register_GetIndex( self->variable_Register,
- subVariableToTryMatch->name );
-
- if ( subVarIndexToTryMatch == inputVarIndex) {
- return True;
- }
- }
- }
- }
-
- return False;
-}
-
-
-VariableCondition_ValueIndex VariableCondition_GetValueIndex (void* variableCondition, Index localIndex, Variable_Index varIndex )
-{
- VariableCondition* self = (VariableCondition*)variableCondition;
- VariableCondition_VariableIndex vcVar_I;
- Index i;
-
- /* if the set isn't initialised, this is a NULL BC : False */
- if ( !self->_set ) {
- return False;
- }
-
- /* first check if the index they've given us is actually in the list this VC applies to */
- /* quick check, since we have the set available */
- if ( localIndex >= self->_set->size ) {
- Stream* warning = Journal_Register( ErrorStream_Type, self->type );
- Journal_Printf( warning, "Error- In %s: Tried to check an index %d larger than the size of "
- "the set (%d).\n", __func__, localIndex, self->_set->size );
- assert(0);
- return False;
- }
- if ( !IndexSet_IsMember( self->_set, localIndex ) ) {
- return (VariableCondition_ValueIndex)-1;
- }
- for (i = 0; i < self->indexCount; i++)
- if (self->indexTbl[i] == localIndex)
- break;
-
- if (i == self->indexCount)
- return (VariableCondition_ValueIndex)-1;
-
- /* now check if the Variable they've given us is actually in the list to apply at the given index */
- for (vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++)
- if (self->vcTbl[i][vcVar_I].varIndex == varIndex)
- return self->vcTbl[i][vcVar_I].valIndex;
-
- return (VariableCondition_ValueIndex)-1;
-}
-
-
-void VariableCondition_PrintConcise( void* variableCondition, Stream* stream ) {
- VariableCondition* self = (VariableCondition*)variableCondition;
-
- self->_printConcise( self, stream );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableCondition.h
--- a/Base/Automation/src/VariableCondition.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,250 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-** Abstract class for specifying (1 or more) conditions that apply to (1 or more) variables in an array.
-**
-** Assumptions:
-**
-** Comments:
-**
-** $Id: VariableCondition.h 4297 2008-08-19 16:54:05Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Base_Automation_VariableCondition_h__
-#define __Base_Automation_VariableCondition_h__
-
- /** Textual name of this class */
- extern const Type VariableCondition_Type;
-
- typedef void (VariableCondition_BuildSelfFunc) ( void* variableCondition, void* data );
- typedef void (VariableCondition_PrintConciseFunc) ( void* variableCondition, Stream* stream );
- typedef void (VariableCondition_ReadDictionaryFunc) ( void* variableCondition, void* dictionary );
- typedef IndexSet* (VariableCondition_GetSetFunc) ( void* variableCondition );
- typedef VariableCondition_VariableIndex (VariableCondition_GetVariableCountFunc) ( void* variableCondition, Index index );
- typedef Variable_Index (VariableCondition_GetVariableIndexFunc) ( void* variableCondition, Index index, VariableCondition_VariableIndex condVar_I );
- typedef VariableCondition_ValueIndex (VariableCondition_GetValueIndexFunc) ( void* variableCondition, Index index, VariableCondition_VariableIndex condVar_I );
- typedef VariableCondition_ValueIndex (VariableCondition_GetValueCountFunc) ( void* variableCondition );
- typedef VariableCondition_Value (VariableCondition_GetValueFunc) ( void* variableCondition, VariableCondition_ValueIndex valIndex );
- typedef void (VariableCondition_ApplyFunc)( void *vc, void* ctx );
-
-
- typedef struct {
- Index size;
- double* array;
- } VariableCondition_Value_Array;
-
- typedef union {
- double typeDouble;
- int typeInt;
- short typeShort;
- char typeChar;
- void* typePtr;
- VariableCondition_Value_Array typeArray;
- ConditionFunction_Index typeCFIndex;
- } VariableCondition_Value_AsType;
-
- #define __VariableCondition_Value \
- VariableCondition_ValueType type; \
- VariableCondition_Value_AsType as;
- struct _VariableCondition_Value { __VariableCondition_Value };
-
-
- #define __VariableCondition_Tuple \
- /** The variable index into VariableCondition::variable_Register identifying a variable */ \
- Variable_Index varIndex; \
- /** The value index into VariableCondition::valueTbl identifying a value to apply to the variable */ \
- VariableCondition_ValueIndex valIndex; \
-
- /** Used to relate which Condition is applied to a Variable */
- struct _VariableCondition_Tuple { __VariableCondition_Tuple };
-
-
- #define __VariableCondition \
- /* General info */ \
- __Stg_Component \
- \
- /* Virtual info */ \
- VariableCondition_BuildSelfFunc* _buildSelf; \
- VariableCondition_PrintConciseFunc* _printConcise; \
- VariableCondition_ReadDictionaryFunc* _readDictionary; \
- VariableCondition_GetSetFunc* _getSet; \
- VariableCondition_GetVariableCountFunc* _getVariableCount; \
- VariableCondition_GetVariableIndexFunc* _getVariableIndex; \
- VariableCondition_GetValueIndexFunc* _getValueIndex; \
- VariableCondition_GetValueCountFunc* _getValueCount; \
- VariableCondition_GetValueFunc* _getValue; \
- VariableCondition_ApplyFunc* _apply; \
- \
- /* Stg_Class info */ \
- /** Register of Variables that may be operated on. */ \
- Variable_Register* variable_Register; \
- /** Register of Condition functions that may be applied. */ \
- ConditionFunction_Register* conFunc_Register; \
- Dictionary* dictionary; \
- \
- /** Set specifying which indexes in the client structure are being controlled by this VC. */ \
- IndexSet* _set; \
- /** the number of indexes this VC applies to. */ \
- Index indexCount; \
- /** Array, of size indexCount, containing the indexes this VC applies to. */ \
- Index* indexTbl; \
- /** Array containing the number of variables at each index that are controlled by this VC */ \
- VariableCondition_VariableIndex* vcVarCountTbl; \
- /** 2d Array, which for each index this VC controls, stores the VariableCondition_Tuple that relates
- what condition is being applied to which Variable */ \
- VariableCondition_Tuple** vcTbl; \
- /** Number of values in the valueTbl which will be applied somewhere using this VC */ \
- VariableCondition_ValueIndex valueCount; \
- /** Array of values which are available to apply (which index/var pairs they apply to is determined
- by VariableCondition::vcTbl). */ \
- VariableCondition_Value* valueTbl; \
- \
- UIntMap* mapping; \
- Stg_ComponentFactory* cf;
-
- /** Abstract class for specifying (1 or more) conditions that apply to (1 or more) variables in an array -
- see VariableCondition.h for details */
- struct _VariableCondition { __VariableCondition };
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructor
- */
-
- VariableCondition* _VariableCondition_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- VariableCondition_BuildSelfFunc* _buildSelf,
- VariableCondition_PrintConciseFunc* _printConcise,
- VariableCondition_ReadDictionaryFunc* _readDictionary,
- VariableCondition_GetSetFunc* _getSet,
- VariableCondition_GetVariableCountFunc _getVariableCount,
- VariableCondition_GetVariableIndexFunc* _getVariableIndex,
- VariableCondition_GetValueIndexFunc* _getValueIndex,
- VariableCondition_GetValueCountFunc* _getValueCount,
- VariableCondition_GetValueFunc* _getValue,
- VariableCondition_ApplyFunc* _apply,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary );
-
- void _VariableCondition_Init(
- void* variableCondition,
- Variable_Register* variable_Register,
- ConditionFunction_Register* conFunc_Register,
- Dictionary* dictionary );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** General virtual functions
- */
-
- void _VariableCondition_Delete( void* variableCondition );
-
- void _VariableCondition_Print( void* variableCondition );
-
- /* Copy */
- #define VariableCondition_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
- #define VariableCondition_Copy( self ) \
- (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
-
- void* _VariableCondition_Copy( void* variableCondition, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Macros
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _VariableCondition_Apply( void* variableCondition, void* context );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Build functions
- */
- void _VariableCondition_Construct( void* variableCondition, Stg_ComponentFactory* cf, void* d );
- void _VariableCondition_Build( void* variableCondition, void* data );
- void _VariableCondition_Initialise( void* variableCondition, void* data );
- void _VariableCondition_Execute( void* variableCondition, void* data );
- void _VariableCondition_Destroy( void* variableCondition, void* data );
-
- #define VariableCondition_BuildSelf( self, data ) \
- if( (self)->_buildSelf ) \
- (self)->_buildSelf( self, data )
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Functions
- */
-
- void VariableCondition_Apply( void* variableCondition, void* context );
-
- void VariableCondition_ApplyToVariable(
- void* variableCondition,
- VariableCondition_VariableIndex varIndex,
- void* context );
-
- void VariableCondition_ApplyToIndex( void* variableCondition, Index globalIndex, void* context );
-
- void VariableCondition_ApplyToIndexVariable(
- void* variableCondition,
- Index globalIndex,
- VariableCondition_VariableIndex varIndex,
- void* context );
-
- /** Checks whether a given (node)/(var at that node) pair is a variable condition */
- Bool VariableCondition_IsCondition(
- void* variableCondition,
- Index globalIndex,
- Variable_Index varIndex );
-
- VariableCondition_ValueIndex VariableCondition_GetValueIndex(
- void* variableCondition,
- Index globalIndex,
- Variable_Index varIndex );
-
- void VariableCondition_PrintConcise( void* variableCondition, Stream* stream );
-
-#endif /* __Base_Automation_VariableCondition_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableCondition.meta
--- a/Base/Automation/src/VariableCondition.meta Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
-<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
-
- <param name="Name">VariableCondition</param>
- <param name="Author">...</param>
- <param name="Organisation">VPAC</param>
- <param name="Project">StGermain</param>
- <param name="Location">./StGermain/Base/Automation/src/</param>
- <param name="Project Web">http://www.stgermainproject.org/</param>
- <param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
- <param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
- <param name="Parent">Stg_Component</param>
- <param name="Reference">...</param>
- <param name="Summary">...</param>
-
- <param name="Description">
- Base class for any concrete variable condition. Defines the interface for
- specifying boundary conditions.
- </param>
-
- <list name="Params">
- n/a
- </list>
-
- <list name="Dependencies">
- n/a
- </list>
-
- <param name="Example">
- n/a
- </param>
-
-</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableCondition_Register.c
--- a/Base/Automation/src/VariableCondition_Register.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,225 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: VariableCondition_Register.c 3462 2006-02-19 06:53:24Z WalterLandry $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "shortcuts.h"
-#include "VariableCondition_Register.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h>
-
-/* Textual name of this class */
-const Type VariableCondition_Register_Type = "VariableCondition_Register";
-
-
-/* Global, default instantiation of the register... will be loaded with in built types (built in Init.c) */
-VariableCondition_Register* variableCondition_Register = 0;
-
-
-VariableCondition_Register* VariableCondition_Register_New(void) {
- return _VariableCondition_Register_New( sizeof(VariableCondition_Register), VariableCondition_Register_Type, _VariableCondition_Register_Delete, _VariableCondition_Register_Print, NULL );
-}
-
-void VariableCondition_Register_Init( void* variableCondition_Register ) {
- VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
-
- /* General info */
- self->type = VariableCondition_Register_Type;
- self->_sizeOfSelf = sizeof(VariableCondition_Register);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _VariableCondition_Register_Delete;
- self->_print = _VariableCondition_Register_Print;
- self->_copy = NULL;
- _Stg_Class_Init( (Stg_Class*)self );
-
- /* VariableCondition_Register info */
- _VariableCondition_Register_Init( self );
-}
-
-VariableCondition_Register* _VariableCondition_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
-{
- VariableCondition_Register* self;
-
- /* Allocate memory */
- assert( _sizeOfSelf >= sizeof(VariableCondition_Register) );
- self = (VariableCondition_Register*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
-
- /* General info */
-
- /* Virtual info */
-
- _VariableCondition_Register_Init( self );
-
- return self;
-}
-
-void _VariableCondition_Register_Init( void* variableCondition_Register ) {
- VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
-
- /* General and Virtual info should already be set */
-
- /* VariableCondition_Register info */
- self->count = 0;
- self->_size = 8;
- self->_delta = 8;
- self->entry = Memory_Alloc_Array( VariableCondition_Register_Entry, self->_size, "VC_Register->entry" );
- memset( self->entry, 0, sizeof(VariableCondition_Register_Entry) * self->_size );
-}
-
-void _VariableCondition_Register_Delete( void* variableCondition_Register ) {
- VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
-
- /* Assumes ownerships of the element types */
- if( self->entry ) {
- Memory_Free( self->entry );
- }
-
- /* Stg_Class_Delete parent */
- _Stg_Class_Delete( self );
-}
-
-void _VariableCondition_Register_Print( void* variableCondition_Register, Stream* stream ) {
- VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
- #ifdef DEBUG
- VariableCondition_Index variableCondition_I;
- #endif
-
- /* Set the Journal for printing informations */
- Stream* variableCondition_RegisterStream = stream;
-
- /* General info */
- Journal_Printf( variableCondition_RegisterStream, "VariableCondition_Register (ptr): %p\n", self );
-
- /* Print parent */
- _Stg_Class_Print( self, variableCondition_RegisterStream );
-
- /* Virtual info */
-
- /* VariableCondition_Register info */
- Journal_Printf( variableCondition_RegisterStream, "\tcount: %u\n", self->count );
- Journal_Printf( variableCondition_RegisterStream, "\t_size: %lu\n", self->_size );
- Journal_Printf( variableCondition_RegisterStream, "\t_delta: %lu\n", self->_delta );
-
- Journal_Printf( variableCondition_RegisterStream, "\tvariableCondition (ptr): %p\n", self->entry );
- Journal_Printf( variableCondition_RegisterStream, "\tvariableCondition[0-%u]:\n", self->count );
- #ifdef DEBUG
- for( variableCondition_I = 0; variableCondition_I < self->count; variableCondition_I++ ) {
- Journal_Printf( variableCondition_RegisterStream, "\tentry[%u]:\n", variableCondition_I );
- Journal_Printf( variableCondition_RegisterStream, "\t\ttype: %s\n", self->entry[variableCondition_I].type );
- Journal_Printf( variableCondition_RegisterStream, "\t\tfactory (func ptr): %p\n", self->entry[variableCondition_I].factory );
- }
- #else
- Journal_Printf( variableCondition_RegisterStream, "...\n" );
- #endif
- Journal_Printf( variableCondition_RegisterStream, "\t]\n" );
-}
-
-VariableCondition_Index VariableCondition_Register_Add(
- void* variableCondition_Register,
- Type type,
- VariableCondition_Register_FactoryFunc* factory )
-{
- VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
- VariableCondition_Index handle;
-
- if( self->count >= self->_size ) {
- SizeT currentSize = self->_size;
-
- self->_size += self->_delta;
- self->entry = Memory_Realloc_Array( self->entry, VariableCondition_Register_Entry, self->_size );
- memset( (Pointer)((ArithPointer)self->entry + (currentSize * sizeof(VariableCondition_Register_Entry)) ),
- 0, sizeof(VariableCondition_Register_Entry) * (self->_size - currentSize) );
- }
-
- handle = self->count;
- self->entry[handle].type = type;
- self->entry[handle].factory = factory;
- self->count++;
-
- return handle;
-}
-
-VariableCondition_Index VariableCondition_Register_GetIndex( void* variableCondition_Register, Type type ) {
- VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
- VariableCondition_Index variableCondition_I;
-
- for( variableCondition_I = 0; variableCondition_I < self->count; variableCondition_I++ ) {
- if( self->entry[variableCondition_I].type == type ) {
- return variableCondition_I;
- }
- }
- /* type is likely to be given from input file in this case... treat comparison checks like for Name... do strcmp too */
- for( variableCondition_I = 0; variableCondition_I < self->count; variableCondition_I++ ) {
- if( strcmp( self->entry[variableCondition_I].type, type ) == 0 ) {
- return variableCondition_I;
- }
- }
- return (unsigned)-1;
-}
-
-VariableCondition_Register_Entry* _VariableCondition_Register_At(
- void* variableCondition_Register,
- VariableCondition_Index handle )
-{
- VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
-
- return VariableCondition_Register_At( self, handle );
-}
-
-VariableCondition* VariableCondition_Register_CreateNew(
- void* variableCondition_Register,
- void* variable_Register,
- void* conFunc_Register,
- Type type,
- void* dictionary,
- void* data )
-{
- VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
-
- return VariableCondition_Register_At( self, VariableCondition_Register_GetIndex( self, type ) )->factory(
- (Variable_Register*)variable_Register,
- (ConditionFunction_Register*)conFunc_Register,
- (Dictionary*)dictionary,
- data );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableCondition_Register.h
--- a/Base/Automation/src/VariableCondition_Register.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Comments:
-** The original sizes need to be manually set by the user.... this whole system needs rethinking... it can be done better
-**
-** $Id: VariableCondition_Register.h 3462 2006-02-19 06:53:24Z WalterLandry $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Base_Automation_VariableCondition_Register_h__
-#define __Base_Automation_VariableCondition_Register_h__
-
-
- /* Child classes must define these factories */
- typedef VariableCondition* (VariableCondition_Register_FactoryFunc) ( Variable_Register* variable_Register, ConditionFunction_Register* conFunc_Register, Dictionary* dictionary, void* data );
-
-
- /** Textual name of this class */
- extern const Type VariableCondition_Register_Type;
-
-
- /** Global, default instantiation of the register... will be loaded with in built types (built in Init.c) */
- extern VariableCondition_Register* variableCondition_Register;
-
-
- /* Register entry info */
- #define __VariableCondition_Register_Entry \
- Type type; \
- VariableCondition_Register_FactoryFunc* factory;
- struct _VariableCondition_Register_Entry { __VariableCondition_Register_Entry };
-
-
- /* VariableCondition_Register info */
- #define __VariableCondition_Register \
- /* General info */ \
- __Stg_Class \
- \
- /* Virtual info */ \
- \
- /* VariableCondition_Register info */ \
- VariableCondition_Index count; \
- SizeT _size; \
- SizeT _delta; \
- VariableCondition_Register_Entry* entry;
- struct _VariableCondition_Register { __VariableCondition_Register };
-
-
- /* Create a new VariableCondition_Register */
- VariableCondition_Register* VariableCondition_Register_New(void);
-
- /* Initialise a VariableCondition_Register */
- void VariableCondition_Register_Init(
- void* variableCondition_Register);
-
- /* Creation implementation / Virtual constructor */
- VariableCondition_Register* _VariableCondition_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy );
-
- /* Initialisation implementation */
- void _VariableCondition_Register_Init( void* variableCondition_Register);
-
-
- /* Stg_Class_Delete implementation */
- void _VariableCondition_Register_Delete( void* variableCondition_Register );
-
- /* Print implementation */
- void _VariableCondition_Register_Print( void* variableCondition_Register, Stream* stream );
-
-
- /* Add a new entry */
- VariableCondition_Index VariableCondition_Register_Add(
- void* variableCondition_Register,
- Type type,
- VariableCondition_Register_FactoryFunc* factory );
-
- /* Get the handle to an entry */
- VariableCondition_Index VariableCondition_Register_GetIndex( void* variableCondition_Register, Type type );
-
- /* Get an entry from the register */
- #define VariableCondition_Register_At( variableCondition_Register, handle ) \
- ( &(variableCondition_Register)->entry[(handle)] )
- VariableCondition_Register_Entry* _VariableCondition_Register_At(
- void* variableCondition_Register,
- VariableCondition_Index handle );
-
- /* Create a new instance of a type */
- VariableCondition* VariableCondition_Register_CreateNew(
- void* variableCondition_Register,
- void* variable_Register,
- void* conFunc_Register,
- Type type,
- void* dictionary,
- void* data );
-
-#endif /* __Base_Automation_VariableCondition_Register_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableDumpStream.c
--- a/Base/Automation/src/VariableDumpStream.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,201 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: VariableDumpStream.c 789 2004-02-10 17:15:11Z SteveQuenette $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "Stg_Component.h"
-#include "Variable.h"
-#include "VariableDumpStream.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h>
-
-
-const Type VariableDumpStream_Type = "VariableDumpStream";
-
-
-Stream* VariableDumpStream_New( Name name )
-{
- return (Stream*)_VariableDumpStream_New(
- sizeof(VariableDumpStream),
- VariableDumpStream_Type,
- _VariableDumpStream_Delete,
- _VariableDumpStream_Print,
- _VariableDumpStream_Copy,
- name,
- _CStream_Printf,
- _CStream_Write,
- _VariableDumpStream_Dump,
- _CStream_SetFile );
-}
-
-void VariableDumpStream_Init( VariableDumpStream* self, Name name )
-{
-
-}
-
-
-VariableDumpStream* _VariableDumpStream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile )
-{
- VariableDumpStream* self;
-
- /* Allocate memory */
- assert( _sizeOfSelf >= sizeof(VariableDumpStream) );
- self = (VariableDumpStream*)_CStream_New( _sizeOfSelf, type, _delete, _print, _copy, name,
- _printf, _write, _dump, _setFile );
-
- _VariableDumpStream_Init( self );
-
- return self;
-}
-
-void _VariableDumpStream_Init( VariableDumpStream* self )
-{
- self->data = NULL;
- self->numItems = 0;
-}
-
-void _VariableDumpStream_Delete( void* cStream )
-{
- VariableDumpStream* self = (VariableDumpStream*)cStream;
-
- /* Stg_Class_Delete parent */
- _Stream_Delete( self );
-}
-
-void _VariableDumpStream_Print( void* cStream, Stream* stream ) {
-
- VariableDumpStream* self = (VariableDumpStream*)cStream;
-
- /* Print parent */
- _Stream_Print( self, stream );
-
- /* General info */
- Journal_Printf( stream, "VariableDumpStream (ptr): %p\n", cStream);
-
- Journal_Printf( stream, "data (ptr): %p\n", self->data );
- Journal_Printf( stream, "numItems: %d\n", self->numItems );
-}
-
-void* _VariableDumpStream_Copy( void* variableDumpStream, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
- VariableDumpStream* self = (VariableDumpStream*)variableDumpStream;
- VariableDumpStream* newVariableDumpStream;
-
- newVariableDumpStream = _Stream_Copy( self, dest, deep, nameExt, ptrMap );
-
- /* HACK */
- /* TODO: this should actually copy the data, i think... */
- newVariableDumpStream->data = NULL;
- newVariableDumpStream->numItems = 0;
- /* END HACK */
- newVariableDumpStream->dumpEvery = self->dumpEvery;
-
- return newVariableDumpStream;
-}
-
-Bool _VariableDumpStream_Dump( Stream* stream, void* _loop )
-{
- VariableDumpStream* self = (VariableDumpStream*)stream;
- int varI, typeI;
- int* loop = (int*)_loop;
- float tmp;
-
-
- if ( self->data == NULL || self->numItems == 0 )
- {
- return True;
- }
- if ( loop != NULL )
- {
- if( !((*loop) == 0 || (((*loop) - 1) % self->dumpEvery == 0)) )
- return True;
- }
-
- /* testing if the others compile....
- char tmp1 = Variable_GetValueAsChar( self->data, varI );
- short tmp2 = Variable_GetValueAsShort( self->data, varI );
- int tmp3 = Variable_GetValueAsInt( self->data, varI );
- double tmp4 = Variable_GetValueAsDouble( self->data, varI );
- void* tmp5 = Variable_GetValueAsPointer( self->data, varI );*/
- for ( varI = 0; varI < self->data->arraySize; ++varI ) {
- if ( *self->data->dataTypeCounts > 1 ) {
- for ( typeI = 0; typeI < *self->data->dataTypeCounts; ++typeI ) {
- tmp = Variable_GetValueAtDoubleAsFloat( self->data, varI, typeI );
- self->_write(
- stream,
- &tmp,
- sizeof(float), 1 );
- }
- }
- else {
- tmp = Variable_GetValueDoubleAsFloat( self->data, varI );
- self->_write(
- stream,
- &tmp,
- sizeof(float), 1 );
- }
- }
-
-
- return True;
-}
-
-void VariableDumpStream_SetVariable( void* stream, Variable* data, int numItems, unsigned int dumpEvery, const Name const fileName )
-{
- VariableDumpStream* self = (VariableDumpStream*)stream;
- JournalFile* file;
-
- self->data = data;
- self->numItems = numItems;
- self->dumpEvery = dumpEvery;
-
- file = Journal_GetFile( fileName );
- if ( file == NULL )
- {
- file = CFile_New2( fileName );
- Journal_RegisterFile( file );
- }
- Stream_SetFile( stream, file );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/VariableDumpStream.h
--- a/Base/Automation/src/VariableDumpStream.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-/** \file
-** <b>Role:</b>
-**
-**
-** <b>Assumptions</b>
-** None
-**
-** <b>Comments</b>
-** None
-**
-** <b>Description</b>
-**
-**
-** Comments:
-**
-** $Id: VariableDumpStream.h 789 2004-02-10 17:15:11Z SteveQuenette $
-**
-**/
-
-#ifndef __Base_IO_VariableDumpStream_h__
-#define __Base_IO_VariableDumpStream_h__
-
- /** Textual name for VariableDumpStream class. */
- extern const Type VariableDumpStream_Type;
-
-
- /** \def __VariableDumpStream See VariableDumpStream. */
- #define __VariableDumpStream \
- /* General info */ \
- __CStream \
- Variable* data; \
- Index numItems; \
- unsigned int dumpEvery;
- struct VariableDumpStream { __VariableDumpStream };
-
-
- /** Create a new VariableDumpStream */
- Stream* VariableDumpStream_New( Name name );
-
- /** Inits a VariableDumpStream. */
- void VariableDumpStream_Init( VariableDumpStream* self, Name name );
-
- /** Constructor interface. */
- VariableDumpStream* _VariableDumpStream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile );
-
- /** Init interface. */
- void _VariableDumpStream_Init( VariableDumpStream *self );
-
- /** Stg_Class_Delete interface. */
- void _VariableDumpStream_Delete( void* vStream );
-
- /** Print interface. */
- void _VariableDumpStream_Print( void* vStream, Stream* stream );
-
- /** Dumps the variable. */
- Bool _VariableDumpStream_Dump( Stream* stream, void* loop );
-
- /** Copy interface. */
- #define VariableDumpStream_Copy( self ) \
- (VariableDumpStream*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
- #define VariableDumpStream_DeepCopy( self ) \
- (VariableDumpStream*)Stg_Class_Copy( self, NULL, True, NULL, NULL )
-
- void* _VariableDumpStream_Copy( void* variableDumpStream, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
-
- /** Sets the information that this stream dumps. */
- void VariableDumpStream_SetVariable( void* stream, Variable* data, int numItems, unsigned int dumpEvery, const Name const fileName );
-
-
-#endif /* __IO_VariableDumpStreamFile_h__ */
-
-
-
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Variable_Register.c
--- a/Base/Automation/src/Variable_Register.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,269 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: Variable_Register.c 4137 2007-06-07 05:46:46Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-
-#include "types.h"
-#include "shortcuts.h"
-#include "Stg_Component.h"
-#include "Variable.h"
-#include "Variable_Register.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-
-const Type Variable_Register_Type = "Variable_Register";
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Constructor
-*/
-
-Variable_Register* Variable_Register_New(void)
-{
- return _Variable_Register_New( sizeof(Variable_Register), Variable_Register_Type, _Variable_Register_Delete,
- _Variable_Register_Print, _Variable_Register_Copy );
-}
-
-
-void Variable_Register_Init(Variable_Register* self)
-{
- /* General info */
- self->type = Variable_Register_Type;
- self->_sizeOfSelf = sizeof(Variable_Register);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _Variable_Register_Delete;
- self->_print = _Variable_Register_Print;
- self->_copy = _Variable_Register_Copy;
-
- _Stg_Class_Init((Stg_Class*)self);
-
- /* Stg_Class info */
- _Variable_Register_Init(self);
-}
-
-
-Variable_Register* _Variable_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
-{
- Variable_Register* self;
-
- /* Allocate memory */
- self = (Variable_Register*)_Stg_Class_New(_sizeOfSelf, type, _delete, _print, _copy);
-
- /* Virtual info */
-
- /* Stg_Class info */
- _Variable_Register_Init(self);
-
- return self;
-}
-
-
-void _Variable_Register_Init(void* variable_Register)
-{
- Variable_Register* self = (Variable_Register*)variable_Register;
-
- self->count = 0;
- self->_size = 8;
- self->_delta = 8;
- self->_variable = Memory_Alloc_Array( Variable*, self->_size, "Variable_Register->_variable" );
- memset(self->_variable, 0, sizeof(Variable*)*self->_size);
- self->errorStream = Journal_Register( Error_Type, self->type );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** General virtual functions
-*/
-
-void _Variable_Register_Delete(void* variable_Register)
-{
- Variable_Register* self = (Variable_Register*)variable_Register;
-
- if (self->_variable) Memory_Free(self->_variable);
-
- /* Stg_Class_Delete parent class */
- _Stg_Class_Delete(self);
-}
-
-void _Variable_Register_Print(void* variable_Register, Stream* stream)
-{
- Variable_Register* self = (Variable_Register*)variable_Register;
-
- /* Set the Journal for printing informations */
- Stream* variable_RegisterStream = Journal_Register( InfoStream_Type, "Variable_RegisterStream");
-
- /* General info */
- Journal_Printf( variable_RegisterStream, "Variable_Register (ptr): %p\n", self);
-
- /* Virtual info */
-
- /* Stg_Class info */
- Journal_Printf( variable_RegisterStream, "\tcount: %u\n", self->count);
- Journal_Printf( variable_RegisterStream, "\t_size: %lu\n", self->_size);
- Journal_Printf( variable_RegisterStream, "\t_delta: %lu\n", self->_delta);
- Journal_Printf( variable_RegisterStream, "\t_variable (ptr): %p\n", self->_variable);
- if (self->_variable)
- {
- Variable_Index var_I;
-
- for (var_I = 0; var_I < self->count; var_I++)
- Stg_Class_Print(self->_variable[var_I], stream);
- }
-
- /* Print parent */
- _Stg_Class_Print(self, variable_RegisterStream);
-}
-
-void* _Variable_Register_Copy( void* vr, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
-
- Variable_Register* self = (Variable_Register*)vr;
- Variable_Register* newVariableRegister;
- int ii;
-
- newVariableRegister = (Variable_Register*)_Stg_Class_Copy( self, dest, deep, nameExt, ptrMap );
- PtrMap_Append( ptrMap, self, newVariableRegister );
-
- newVariableRegister->count = self->count;
- newVariableRegister->_size = self->_size;
- newVariableRegister->_variable = Memory_Alloc_Array( Variable*, self->_size, "Variable_Register->_variable" );
- memset(newVariableRegister->_variable, 0, sizeof(Variable*)*self->_size);
-
- for ( ii = 0; ii < self->count; ++ii ) {
- if ( (newVariableRegister->_variable[ii] = PtrMap_Find( ptrMap, self->_variable[ii] )) == NULL ) {
- newVariableRegister->_variable[ii] = Stg_Class_Copy( self->_variable[ii], NULL, deep, nameExt, ptrMap );
- }
- }
-
- return newVariableRegister;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Macros
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Build functions
-*/
-
-Variable_Index Variable_Register_Add(void* variable_Register, Variable* variable)
-{
- Variable_Register* self = (Variable_Register*)variable_Register;
- Variable_Index handle;
-
- if (self->count >= self->_size)
- {
- SizeT currentSize = self->_size;
-
- self->_size += self->_delta;
- self->_variable = Memory_Realloc_Array( self->_variable, Variable*, self->_size );
- memset( (Pointer)((ArithPointer)self->_variable + (currentSize * sizeof(Variable*)) ), 0,
- sizeof(Variable*) * (self->_size - currentSize) );
- }
-
- handle = self->count++;
- self->_variable[handle] = variable;
-
- return handle;
-}
-
-
-void Variable_Register_BuildAll(void* variable_Register)
-{
- Variable_Register* self = (Variable_Register*)variable_Register;
- Variable_Index var_I;
-
- for (var_I = 0; var_I < self->count; var_I++)
- Stg_Component_Build( self->_variable[var_I], 0, False );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Functions
-*/
-
-Variable_Index Variable_Register_GetIndex(void* variable_Register, Name name)
-{
- Variable_Register* self = (Variable_Register*)variable_Register;
- Variable_Index var_I;
-
- for (var_I = 0; var_I < self->count; var_I++)
- {
- if (self->_variable[var_I]->name && !strcmp(name, self->_variable[var_I]->name))
- return var_I;
- }
-
- return (Variable_Index)-1;
-}
-
-
-Variable* Variable_Register_GetByName(void* variable_Register, Name name)
-{
- Variable_Register* self = (Variable_Register*)variable_Register;
- Variable_Index varIndex;
-
- if( (varIndex = Variable_Register_GetIndex( self, name )) != (Variable_Index)-1 )
- return self->_variable[varIndex];
-
- return NULL;
-}
-
-
-Variable* Variable_Register_GetByIndex(void* variable_Register, Variable_Index varIndex ) {
- Variable_Register* self = (Variable_Register*)variable_Register;
- #if DEBUG
- Stream* error = self->errorStream;
-
- Journal_DFirewall( (varIndex < self->count), error,
- "Error: Given variable index %d not between 0 and variable count %d.\n",
- varIndex, self->count );
- #endif
-
- return self->_variable[varIndex];
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/Variable_Register.h
--- a/Base/Automation/src/Variable_Register.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-** Instantiates the Variable_Register such that there is only one set of DOF descriptions (for example, all the nodes have the same
-** DOF configuration).
-**
-** Assumptions:
-** All "adding" is done before the Variable_Register_Build(...), which will be done in the mesh's initialisation.
-**
-** Comments:
-** You "add" DOF descriptors by using the Variable_Register_Add( variable_Register, name, offset ), where the "name" is the
-** textual name for the DOF that will be used in the I/O of the DOF (e.g. for initial and boundary conditions), and "offset" is
-** the memory offset of the DOF in the construct that it will be used (e.g. node.vel[0]-node ).
-**
-** $Id: Variable_Register.h 4081 2007-04-27 06:20:07Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Base_Automation_Variable_Register_h__
-#define __Base_Automation_Variable_Register_h__
-
-
- extern const Type Variable_Register_Type;
-
-
- #define __Variable_Register \
- /* General info */ \
- __Stg_Class \
- \
- /* Virtual info */ \
- \
- /* Stg_Class info */ \
- /** Total number of variables counted */ \
- Variable_Index count; \
- SizeT _size; \
- SizeT _delta; \
- Variable** _variable; \
- Stream* errorStream;
-
- struct _Variable_Register { __Variable_Register };
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructor
- */
- Variable_Register* Variable_Register_New(void);
-
- void Variable_Register_Init(Variable_Register* self);
-
- Variable_Register* _Variable_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy );
-
- void _Variable_Register_Init(void* variable_Register);
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** General virtual functions
- */
-
- void _Variable_Register_Delete(void* variable_Register);
-
- void _Variable_Register_Print(void* variable_Register, Stream* stream);
-
- void* _Variable_Register_Copy( void* vr, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Macros
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Build functions
- */
-
- /* Add a variable... do before building */
- Variable_Index Variable_Register_Add(void* variable_Register, Variable* variable);
-
- void Variable_Register_BuildAll(void* variable_Register);
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public Functions & Macros
- */
-
- Variable_Index Variable_Register_GetIndex(void* variable_Register, Name name);
-
- Variable* Variable_Register_GetByName(void* variable_Register, Name name);
-
- Variable* Variable_Register_GetByIndex( void* variable_Register, Variable_Index varIndex);
-
-#endif /* __Base_Automation_Variable_Register_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/offsets.h
--- a/Base/Automation/src/offsets.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/offsets.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_offsets_h__
-#define __Base_Automation_offsets_h__
+#ifndef __StGermain_Base_Automation_offsets_h__
+#define __StGermain_Base_Automation_offsets_h__
/** Given a struct object and the name of a member, return the member */
#define GetMember( structVar, member ) \
@@ -69,4 +69,4 @@
( GetOffsetOfIndex( (arrayVar), (structIndex) ) + \
GetOffsetOfMember( GetIndex( (arrayVar), (structIndex) ), (index) ) )
-#endif /* __Base_Automation_offsets_h__ */
+#endif /* __StGermain_Base_Automation_offsets_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/shortcuts.h
--- a/Base/Automation/src/shortcuts.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/shortcuts.h Tue Jan 12 14:38:16 2010 +1100
@@ -27,7 +27,7 @@
*/
/** \file
** Role:
-** Shortcuts to complex types in the eyes of the Base user.
+** Shortcuts to complex types in the eyes of the Context user.
**
** Assumptions:
** None as yet.
@@ -35,21 +35,12 @@
** Comments:
** None as yet.
**
-** $Id: shortcuts.h 4137 2007-06-07 05:46:46Z LukeHodkinson $
+** $Id: shortcuts.h 3851 2006-10-12 08:57:22Z SteveQuenette $
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_shortcuts_h__
-#define __Base_Automation_shortcuts_h__
+#ifndef __StGermain_Base_Automation_shortcuts_h__
+#define __StGermain_Base_Automation_shortcuts_h__
- /* VTK uses Stg_Class_Delete as a standard class member...so if an app
- uses St. G and VTK, then we can't use this macro */
-/*
- #ifndef __vtkObject_h
- #define Build Stg_Component_Build
- #define Initialise Stg_Component_Initialise
- #define Execute Stg_Component_Execute
- #endif
-*/
-
-#endif /* __Base_Automation_shortcuts_h__ */
+
+#endif /* __StGermain_Base_Automation_shortcuts_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/src/types.h
--- a/Base/Automation/src/types.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/src/types.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_types_h__
-#define __Base_Automation_types_h__
+#ifndef __StGermain_Base_Automation_types_h__
+#define __StGermain_Base_Automation_types_h__
typedef struct stgComponent stgComponent;
typedef struct Comm Comm;
@@ -54,60 +54,14 @@ typedef struct Comm Comm;
typedef struct DocumentationComponentFactory DocumentationComponentFactory;
typedef struct HierarchyTable HierarchyTable;
typedef struct Stg_CallGraph Stg_CallGraph;
- typedef struct _Variable Variable;
- typedef struct _Variable_Register Variable_Register;
- typedef struct VariableDumpStream VariableDumpStream;
- typedef struct _VariableCondition VariableCondition;
- typedef struct _SetVC SetVC;
- typedef struct _CompositeVC CompositeVC;
- typedef struct DynamicVC DynamicVC;
- typedef struct _VariableCondition_Register VariableCondition_Register;
- typedef struct _ConditionFunction ConditionFunction;
- typedef struct _ConditionFunction_Register ConditionFunction_Register;
- typedef struct _VariableAllVC_Entry VariableAllVC_Entry;
- typedef struct _VariableAllVC VariableAllVC;
- typedef Index VariableAllVC_Entry_Index;
-
- /* Variable_Register types */
- typedef Index Variable_Set_Index;
- typedef Index Variable_Index;
- typedef Index Dof_Index;
-
- /* VariableCondition_Register types */
- typedef struct _VariableCondition_Register_Entry VariableCondition_Register_Entry;
-
- /* VariableCondition types */
- typedef enum
- {
- VC_ValueType_Double = 1,
- VC_ValueType_Int,
- VC_ValueType_Short,
- VC_ValueType_Char,
- VC_ValueType_Ptr,
- VC_ValueType_DoubleArray,
- VC_ValueType_CFIndex
- } VariableCondition_ValueType;
-
typedef struct SearchCriteria_t{
Name type;
Name version;
}SearchCriteria;
- typedef Index VariableCondition_Index;
- typedef struct _VariableCondition_Value VariableCondition_Value;
- typedef struct _VariableCondition_Tuple VariableCondition_Tuple;
- typedef Index VariableCondition_ValueIndex;
- typedef Index ConditionFunction_Index;
- typedef Index VariableCondition_VariableIndex;
-
- typedef struct _SetVC_Entry SetVC_Entry;
- typedef Index SetVC_Entry_Index;
-
- /* CompositeVC types */
- typedef Index CompositeVC_ItemIndex;
-
typedef void* (Stg_Component_Constructor) ( Name );
typedef void (Stg_Component_LoadFromDict) ( void*, Dictionary*, Dictionary*, Stg_ObjectList* );
-#endif /* __Base_Automation_types_h__ */
+
+#endif /* __StGermain_Base_Automation_types_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/CallGraphSuite.c
--- a/Base/Automation/tests/CallGraphSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/tests/CallGraphSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -161,10 +161,8 @@ void CallGraphSuite_TestTableRealloc( Ca
/* Use "i" as a unique string (unique pointer value)... don't try to print! */
Stg_CallGraph_Push( cg3, TestFunc1, (Name)ii );
}
- pcu_check_true(
- cg3->_tableCount == count &&
- cg3->_tableSize == (size * 2) );
-
+ pcu_check_true( cg3->_tableCount == count && cg3->_tableSize == (size * 2) );
+
Stg_Class_Delete( cg3 );
}
@@ -203,3 +201,5 @@ void CallGraphSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, CallGraphSuite_TestTableRealloc );
pcu_suite_addTest( suite, CallGraphSuite_TestCopy );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/CommSuite.c
--- a/Base/Automation/tests/CommSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/tests/CommSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -299,3 +299,5 @@ void CommSuite( pcu_suite_t* suite ) {
/* Test below not yet completed */
/* pcu_suite_addTest( suite, CommSuite_TestAllgather ); */
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/ComponentCopySuite.c
--- a/Base/Automation/tests/ComponentCopySuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/tests/ComponentCopySuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -76,7 +76,7 @@ void Stg_ComponentA_Delete( void* class
void Stg_ComponentA_Delete( void* class );
void Stg_ComponentA_Print( void* class, Stream* s );
void* Stg_ComponentA_Copy( void* self, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
-void Stg_ComponentA_Construct( void* component, Stg_ComponentFactory* cf, void* data );
+void Stg_ComponentA_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data );
void Stg_ComponentA_Build( void* component, void* data );
void Stg_ComponentA_Initialise( void* component, void* data );
void Stg_ComponentA_Execute( void* component, void* data );
@@ -84,20 +84,21 @@ void Stg_ComponentA_Destroy( void* compo
void* Stg_ComponentA_NewDefault( Name name )
{
- return _Stg_Component_New(
- sizeof(Stg_ComponentA),
- "Stg_ComponentA",
- Stg_ComponentA_Delete,
- Stg_ComponentA_Print,
- Stg_ComponentA_Copy,
- Stg_ComponentA_NewDefault,
- Stg_ComponentA_Construct,
- Stg_ComponentA_Build,
- Stg_ComponentA_Initialise,
- Stg_ComponentA_Execute,
- Stg_ComponentA_Destroy,
- name,
- NON_GLOBAL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Stg_ComponentA);
+ Type type = "Stg_ComponentA";
+ Stg_Class_DeleteFunction* _delete = Stg_ComponentA_Delete;
+ Stg_Class_PrintFunction* _print = Stg_ComponentA_Print;
+ Stg_Class_CopyFunction* _copy = Stg_ComponentA_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = Stg_ComponentA_NewDefault;
+ Stg_Component_ConstructFunction* _construct = Stg_ComponentA_AssignFromXML;
+ Stg_Component_BuildFunction* _build = Stg_ComponentA_Build;
+ Stg_Component_InitialiseFunction* _initialise = Stg_ComponentA_Initialise;
+ Stg_Component_ExecuteFunction* _execute = Stg_ComponentA_Execute;
+ Stg_Component_DestroyFunction* _destroy = Stg_ComponentA_Destroy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+
+ return _Stg_Component_New( STG_COMPONENT_PASSARGS );
}
void Stg_ComponentA_Delete( void* class ) {
Stg_ComponentA* self = (Stg_ComponentA*)class;
@@ -128,7 +129,7 @@ void* Stg_ComponentA_Copy( void* class,
return newCopy;
}
-void Stg_ComponentA_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
+void Stg_ComponentA_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) {
Stg_ComponentA* self = (Stg_ComponentA*)component;
self->b = Stg_ComponentFactory_ConstructByName( cf, "b", Stg_ComponentB, True, data ) ;
@@ -161,7 +162,7 @@ void Stg_ComponentB_Delete( void* class
void Stg_ComponentB_Delete( void* class );
void Stg_ComponentB_Print( void* class, Stream* s );
void* Stg_ComponentB_Copy( void* self, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
-void Stg_ComponentB_Construct( void* component, Stg_ComponentFactory* cf, void* data );
+void Stg_ComponentB_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data );
void Stg_ComponentB_Build( void* component, void* data );
void Stg_ComponentB_Initialise( void* component, void* data );
void Stg_ComponentB_Execute( void* component, void* data );
@@ -169,20 +170,21 @@ void Stg_ComponentB_Destroy( void* compo
void* Stg_ComponentB_NewDefault( Name name )
{
- return _Stg_Component_New(
- sizeof(Stg_ComponentB),
- "Stg_ComponentB",
- Stg_ComponentB_Delete,
- Stg_ComponentB_Print,
- Stg_ComponentB_Copy,
- Stg_ComponentB_NewDefault,
- Stg_ComponentB_Construct,
- Stg_ComponentB_Build,
- Stg_ComponentB_Initialise,
- Stg_ComponentB_Execute,
- Stg_ComponentB_Destroy,
- name,
- NON_GLOBAL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Stg_ComponentB);
+ Type type = "Stg_ComponentB";
+ Stg_Class_DeleteFunction* _delete = Stg_ComponentB_Delete;
+ Stg_Class_PrintFunction* _print = Stg_ComponentB_Print;
+ Stg_Class_CopyFunction* _copy = Stg_ComponentB_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = Stg_ComponentB_NewDefault;
+ Stg_Component_ConstructFunction* _construct = Stg_ComponentB_AssignFromXML;
+ Stg_Component_BuildFunction* _build = Stg_ComponentB_Build;
+ Stg_Component_InitialiseFunction* _initialise = Stg_ComponentB_Initialise;
+ Stg_Component_ExecuteFunction* _execute = Stg_ComponentB_Execute;
+ Stg_Component_DestroyFunction* _destroy = Stg_ComponentB_Destroy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+
+ return _Stg_Component_New( STG_COMPONENT_PASSARGS );
}
void Stg_ComponentB_Delete( void* class ) {
Stg_ComponentB* self = (Stg_ComponentB*)class;
@@ -205,7 +207,7 @@ void* Stg_ComponentB_Copy( void* class,
return newCopy;
}
-void Stg_ComponentB_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
+void Stg_ComponentB_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) {
}
void Stg_ComponentB_Build( void* component, void* data ) {
}
@@ -230,7 +232,7 @@ void Stg_ComponentC_Delete( void* class
void Stg_ComponentC_Delete( void* class );
void Stg_ComponentC_Print( void* class, Stream* s );
void* Stg_ComponentC_Copy( void* self, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
-void Stg_ComponentC_Construct( void* component, Stg_ComponentFactory* cf, void* data );
+void Stg_ComponentC_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data );
void Stg_ComponentC_Build( void* component, void* data );
void Stg_ComponentC_Initialise( void* component, void* data );
void Stg_ComponentC_Execute( void* component, void* data );
@@ -238,20 +240,21 @@ void Stg_ComponentC_Destroy( void* compo
void* Stg_ComponentC_NewDefault( Name name )
{
- return _Stg_Component_New(
- sizeof(Stg_ComponentC),
- "Stg_ComponentC",
- Stg_ComponentC_Delete,
- Stg_ComponentC_Print,
- Stg_ComponentC_Copy,
- Stg_ComponentC_NewDefault,
- Stg_ComponentC_Construct,
- Stg_ComponentC_Build,
- Stg_ComponentC_Initialise,
- Stg_ComponentC_Execute,
- Stg_ComponentC_Destroy,
- name,
- NON_GLOBAL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Stg_ComponentC);
+ Type type = "Stg_ComponentC";
+ Stg_Class_DeleteFunction* _delete = Stg_ComponentC_Delete;
+ Stg_Class_PrintFunction* _print = Stg_ComponentC_Print;
+ Stg_Class_CopyFunction* _copy = Stg_ComponentC_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = Stg_ComponentC_NewDefault;
+ Stg_Component_ConstructFunction* _construct = Stg_ComponentC_AssignFromXML;
+ Stg_Component_BuildFunction* _build = Stg_ComponentC_Build;
+ Stg_Component_InitialiseFunction* _initialise = Stg_ComponentC_Initialise;
+ Stg_Component_ExecuteFunction* _execute = Stg_ComponentC_Execute;
+ Stg_Component_DestroyFunction* _destroy = Stg_ComponentC_Destroy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+
+ return _Stg_Component_New( STG_COMPONENT_PASSARGS );
}
void Stg_ComponentC_Delete( void* class ) {
Stg_ComponentC* self = (Stg_ComponentC*)class;
@@ -279,7 +282,7 @@ void* Stg_ComponentC_Copy( void* class,
return newCopy;
}
-void Stg_ComponentC_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
+void Stg_ComponentC_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) {
Stg_ComponentC* self = (Stg_ComponentC*)component;
self->b = Stg_ComponentFactory_ConstructByName( cf, "b", Stg_ComponentB, True, data ) ;
@@ -359,7 +362,7 @@ void ComponentCopySuite_TestCopy( Compon
Dictionary_AddFromDictionary( data->dict, "components", componentsDictionary );
- cf = Stg_ComponentFactory_New( data->dict, componentsDictionary, Stg_ObjectList_New() );
+ cf = Stg_ComponentFactory_New( data->dict, componentsDictionary );
Stream_Enable( cf->infoStream, False );
Stg_ComponentFactory_CreateComponents( cf );
@@ -401,3 +404,5 @@ void ComponentCopySuite( pcu_suite_t* su
pcu_suite_setFixtures( suite, ComponentCopySuite_Setup, ComponentCopySuite_Teardown );
pcu_suite_addTest( suite, ComponentCopySuite_TestCopy );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/ConditionFunctionSuite.c
--- a/Base/Automation/tests/ConditionFunctionSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-**
-** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "pcu/pcu.h"
-#include "StGermain/Base/Foundation/Foundation.h"
-#include "StGermain/Base/IO/IO.h"
-#include "StGermain/Base/Container/Container.h"
-#include "StGermain/Base/Automation/Automation.h"
-#include "ConditionFunctionSuite.h"
-
-typedef struct {
-} ConditionFunctionSuiteData;
-
-
-#define TEST_CF_RESULT 10
-
-void func(Index index, Variable_Index var_I, void* context, void* result)
-{
- *((double*)result) = TEST_CF_RESULT;
-}
-
-
-void ConditionFunctionSuite_Setup( ConditionFunctionSuiteData* data ) {
-}
-
-void ConditionFunctionSuite_Teardown( ConditionFunctionSuiteData* data ) {
-}
-
-
-void ConditionFunctionSuite_TestApply( ConditionFunctionSuiteData* data ) {
- ConditionFunction* cf;
- double result;
-
- cf = ConditionFunction_New(func, "quadratic");
-
- ConditionFunction_Apply(cf, 4, 2, NULL, &result);
- pcu_check_true( TEST_CF_RESULT == result );
-
- Stg_Class_Delete(cf);
-}
-
-
-void ConditionFunctionSuite( pcu_suite_t* suite ) {
- pcu_suite_setData( suite, ConditionFunctionSuiteData );
- pcu_suite_setFixtures( suite, ConditionFunctionSuite_Setup, ConditionFunctionSuite_Teardown );
- pcu_suite_addTest( suite, ConditionFunctionSuite_TestApply );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/ConditionFunctionSuite.h
--- a/Base/Automation/tests/ConditionFunctionSuite.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef StGermain_ConditionFunctionSuite_h
-#define StGermain_ConditionFunctionSuite_h
-
-void ConditionFunctionSuite( pcu_suite_t* suite );
-
-#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/HierarchyTableSuite.c
--- a/Base/Automation/tests/HierarchyTableSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Automation/tests/HierarchyTableSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -42,7 +42,7 @@ typedef struct {
typedef struct {
HierarchyTable* hTable;
HierarchyTable* savedHierarchyTable;
- unsigned int rank;
+ int rank;
} HierarchyTableSuiteData;
@@ -176,3 +176,5 @@ void HierarchyTableSuite( pcu_suite_t* s
pcu_suite_addTest( suite, HierarchyTableSuite_TestPrintParents );
pcu_suite_addTest( suite, HierarchyTableSuite_TestPrintChildren );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/LiveComponentRegisterSuite.c
--- a/Base/Automation/tests/LiveComponentRegisterSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-**
-** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "pcu/pcu.h"
-#include "StGermain/Base/Foundation/Foundation.h"
-#include "StGermain/Base/IO/IO.h"
-#include "StGermain/Base/Container/Container.h"
-#include "StGermain/Base/Automation/Automation.h"
-#include "LiveComponentRegisterSuite.h"
-
-typedef struct {
- LiveComponentRegister* lcRegister;
-} LiveComponentRegisterSuiteData;
-
-
-void LiveComponentRegisterSuite_Setup( LiveComponentRegisterSuiteData* data ) {
- data->lcRegister = LiveComponentRegister_New( );
-}
-
-void LiveComponentRegisterSuite_Teardown( LiveComponentRegisterSuiteData* data ) {
- Stg_Class_Delete( data->lcRegister );
-}
-
-
-void LiveComponentRegisterSuite_TestGet( LiveComponentRegisterSuiteData* data ) {
- typedef float Triple[3];
-
- float* array;
- Triple* structArray;
-
- Variable* var;
- Variable* vec;
- Variable* vecVar[3];
- Variable* tempVar = NULL;
- Index length = 10;
-
- Variable_Register* reg;
-
- array = Memory_Alloc_Array( float, length, "test" );
- structArray = Memory_Alloc_Array( Triple, length, "test" );
-
- reg = Variable_Register_New();
-
- var = Variable_NewScalar(
- "Scalar",
- Variable_DataType_Float,
- &length,
- NULL,
- (void**)&array,
- reg );
-
- vec = Variable_NewVector(
- "Three",
- Variable_DataType_Float,
- 3,
- &length,
- NULL,
- (void**)&structArray,
- reg,
- "a",
- "b",
- "c" );
-
- vecVar[0] = Variable_Register_GetByName( reg, "a" );
- vecVar[1] = Variable_Register_GetByName( reg, "b" );
- vecVar[2] = Variable_Register_GetByName( reg, "c" );
-
- Variable_Register_BuildAll( reg );
-
- LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) var );
- LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) vec );
- LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) vecVar[0] );
- LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) vecVar[1] );
- LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) vecVar[2] );
-
- tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "Scalar" );
- pcu_check_true( tempVar == var );
-
- tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "Three" );
- pcu_check_true( tempVar == vec );
-
- tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "a" );
- pcu_check_true( tempVar == vecVar[0] );
-
- tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "b" );
- pcu_check_true( tempVar == vecVar[1] );
-
- tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "c" );
- pcu_check_true( tempVar == vecVar[2] );
-}
-
-
-void LiveComponentRegisterSuite( pcu_suite_t* suite ) {
- pcu_suite_setData( suite, LiveComponentRegisterSuiteData );
- pcu_suite_setFixtures( suite, LiveComponentRegisterSuite_Setup, LiveComponentRegisterSuite_Teardown );
- pcu_suite_addTest( suite, LiveComponentRegisterSuite_TestGet );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/LiveComponentRegisterSuite.h
--- a/Base/Automation/tests/LiveComponentRegisterSuite.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef StGermain_LiveComponentRegisterSuite_h
-#define StGermain_LiveComponentRegisterSuite_h
-
-void LiveComponentRegisterSuite( pcu_suite_t* suite );
-
-#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/SetVC_Suite.c
--- a/Base/Automation/tests/SetVC_Suite.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,255 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-**
-** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "pcu/pcu.h"
-#include "StGermain/Base/Foundation/Foundation.h"
-#include "StGermain/Base/IO/IO.h"
-#include "StGermain/Base/Container/Container.h"
-#include "StGermain/Base/Automation/Automation.h"
-#include "SetVC_Suite.h"
-
-/* Note that these params below must match up with setVC.xml input file for the test to work */
-#define NUM_VARS 7
-#define X_INDEX 0
-#define Y_INDEX 1
-#define Z_INDEX 2
-#define VX_INDEX 3
-#define VY_INDEX 4
-#define VZ_INDEX 5
-#define TEMP_INDEX 6
-
-#define NUM_NODES 64
-#define LAST_VC_NODE_INDEX 26
-#define TEMP_VAR_ARRAYSIZE 5
-
-#define VX_CONDVALUE 2
-#define VY_CONDVALUE 20.0
-#define VZ_CONDVALUE 1
-#define TEMP_CONDVALUE_BASE 5
-
-
-typedef struct {
- Variable_Register* vr;
- ConditionFunction_Register* conFunc_Register;
- Dictionary* dict;
- ConditionFunction* quadCF;
- double* array[NUM_VARS];
- Index arraySize;
- char* varNames[NUM_VARS];
- Variable* var[NUM_VARS];
- VariableCondition* vc;
-} SetVC_SuiteData;
-
-
-void quadratic(Index index, Variable_Index var_I, void* context, void* result)
-{
- *(double *)result = 20.0;
-}
-
-
-void SetVC_Suite_Setup( SetVC_SuiteData* data ) {
- Index ii=0;
- char setVC_XMLFilename[PCU_PATH_MAX];
- XML_IO_Handler* io_handler = XML_IO_Handler_New();
-
- data->vr = Variable_Register_New();
- data->conFunc_Register = ConditionFunction_Register_New();
- data->dict = Dictionary_New();
- data->arraySize = NUM_NODES;
-
- Stg_asprintf( &data->varNames[X_INDEX], "x" );
- Stg_asprintf( &data->varNames[Y_INDEX], "y" );
- Stg_asprintf( &data->varNames[Z_INDEX], "z" );
- Stg_asprintf( &data->varNames[VX_INDEX], "vx" );
- Stg_asprintf( &data->varNames[VY_INDEX], "vy" );
- Stg_asprintf( &data->varNames[VZ_INDEX], "vz" );
- Stg_asprintf( &data->varNames[TEMP_INDEX], "temp" );
-
- /* Load the definition of the SetVC from XML */
- pcu_filename_input( "setVC.xml", setVC_XMLFilename );
- IO_Handler_ReadAllFromFile( io_handler, setVC_XMLFilename, data->dict );
-
- /* Create CF stuff */
- data->quadCF = ConditionFunction_New( quadratic, "quadratic" );
- ConditionFunction_Register_Add( data->conFunc_Register, data->quadCF );
-
- /* Create variables */
- for (ii = 0; ii < (TEMP_INDEX); ii++) {
- data->array[ii] = Memory_Alloc_Array( double, data->arraySize, "data->array[]" );
- data->var[ii] = Variable_NewScalar( data->varNames[ii], Variable_DataType_Double, &data->arraySize, NULL,
- (void**)&data->array[ii], 0 );
- Variable_Register_Add(data->vr, data->var[ii]);
- }
-
- data->array[TEMP_INDEX] = Memory_Alloc_Array( double , data->arraySize*TEMP_VAR_ARRAYSIZE, "data->array[TEMP_INDEX]" );
- data->var[TEMP_INDEX] = Variable_NewVector( data->varNames[TEMP_INDEX], Variable_DataType_Double, TEMP_VAR_ARRAYSIZE,
- &data->arraySize, NULL, (void**)&data->array[TEMP_INDEX], 0, "a", "b", "c", "d", "e" );
- Variable_Register_Add( data->vr, data->var[TEMP_INDEX] );
-
- Variable_Register_BuildAll( data->vr );
-
- /* Create the VC */
- data->vc = (VariableCondition*)SetVC_New( "setVC", "setVC", data->vr, data->conFunc_Register, data->dict );
- Stg_Component_Build( data->vc, 0, False );
-
- /* Blank the memory to be applied to before the test */
- for (ii = 0; ii < (TEMP_INDEX); ii++) {
- memset(data->array[ii], 0, sizeof(double)*NUM_NODES);
- }
- memset(data->array[TEMP_INDEX], 0, sizeof(double)*NUM_NODES*TEMP_VAR_ARRAYSIZE);
-
- Memory_Free( io_handler );
-}
-
-
-void SetVC_Suite_Teardown( SetVC_SuiteData* data ) {
- Index ii=0;
-
- Stg_Class_Delete(data->vr);
- Stg_Class_Delete(data->conFunc_Register);
- Stg_Class_Delete(data->dict);
-
- Stg_Class_Delete(data->quadCF);
-
- for (ii = 0; ii < NUM_VARS; ii++) {
- if (data->array[ii]) Memory_Free(data->array[ii]);
- Stg_Class_Delete( data->var[ii] );
- }
-
- Stg_Class_Delete(data->vc);
-}
-
-
-void SetVC_Suite_TestIsCondition( SetVC_SuiteData* data ) {
- Index var_I=0, node_I=0;
-
- /* remember varName[] = {"x", "y", "z", "vx", "vy", "vz", "temp"}*/
-
- /* X, Y, and Z shouldn't have Conditions applied to them */
- for( var_I = 0; var_I < VX_INDEX; var_I++ ) {
- for (node_I = 0; node_I < NUM_NODES; node_I++) {
- pcu_check_true( False == VariableCondition_IsCondition(data->vc, node_I, var_I) );
- }
- }
- /* VX, VY, VZ, and temp should have Conditions applied to them, at even indices */
- for( var_I = VX_INDEX; var_I < NUM_VARS; var_I++ ) {
- for (node_I = 0; node_I < NUM_NODES; node_I++) {
- if ( (node_I % 2 == 0) && node_I <= LAST_VC_NODE_INDEX ) {
- pcu_check_true( True == VariableCondition_IsCondition(data->vc, node_I, var_I) );
- }
- else {
- pcu_check_true( False == VariableCondition_IsCondition(data->vc, node_I, var_I) );
- }
- }
- }
-}
-
-
-void SetVC_Suite_TestGetValueIndex( SetVC_SuiteData* data ) {
- Index var_I=0, node_I=0;
-
- /* remember varName[] = {"x", "y", "z", "vx", "vy", "vz", "temp"}*/
- /* These results are dependent on the order the conditions are added in the dictionary */
-
- for( var_I = 0; var_I < VX_INDEX; var_I++ ) {
- for (node_I = 0; node_I < NUM_NODES; node_I++) {
- pcu_check_true( (unsigned)-1 == VariableCondition_GetValueIndex(data->vc, node_I, var_I) );
- }
- }
- for( var_I = VX_INDEX; var_I < NUM_VARS; var_I++ ) {
- for (node_I = 0; node_I < NUM_NODES; node_I++) {
- if ( (node_I % 2 == 0) && node_I <= LAST_VC_NODE_INDEX ) {
- /* Condition indices will start at 0, starting at condition 3 "vx" */
- pcu_check_true( (var_I-VX_INDEX) == VariableCondition_GetValueIndex(data->vc, node_I, var_I) );
- }
- else {
- pcu_check_true( (unsigned)-1 == VariableCondition_GetValueIndex(data->vc, node_I, var_I) );
- }
- }
- }
-}
-
-
-void SetVC_Suite_TestApply( SetVC_SuiteData* data ) {
- Index var_I=0, node_I=0, array_I=0;
-
- /* remember varName[] = {"x", "y", "z", "vx", "vy", "vz", "temp"}; */
-
- VariableCondition_Apply(data->vc, NULL);
-
- for( var_I = 0; var_I < VX_INDEX; var_I++ ) {
- for (node_I = 0; node_I < NUM_NODES; node_I++) {
- pcu_check_true( 0 == data->array[var_I][node_I] );
- }
- }
- for( var_I = VX_INDEX; var_I < TEMP_INDEX; var_I++ ) {
- for (node_I = 0; node_I < NUM_NODES; node_I++) {
- if ( (node_I % 2 == 0) && node_I <= LAST_VC_NODE_INDEX ) {
- if (var_I == VX_INDEX) {
- pcu_check_true( VX_CONDVALUE == data->array[var_I][node_I] );
- }
- else if (var_I == VY_INDEX) {
- pcu_check_true( VY_CONDVALUE == data->array[var_I][node_I] );
- }
- else if (var_I == VZ_INDEX) {
- pcu_check_true( VZ_CONDVALUE == data->array[var_I][node_I] );
- }
- }
- else {
- pcu_check_true( 0 == data->array[var_I][node_I] );
- }
- }
- }
- /* Now for the "temp" variable */
- for (node_I = 0; node_I < NUM_NODES; node_I++) {
- for( array_I = 0; array_I < TEMP_VAR_ARRAYSIZE; array_I++ ) {
- if ( (node_I % 2 == 0) && node_I <= LAST_VC_NODE_INDEX ) {
- pcu_check_true( (TEMP_CONDVALUE_BASE+array_I) == data->array[TEMP_INDEX][node_I*TEMP_VAR_ARRAYSIZE + array_I] );
- }
- else {
- pcu_check_true( 0 == data->array[TEMP_INDEX][node_I*TEMP_VAR_ARRAYSIZE + array_I] );
- }
- }
- }
-}
-
-
-void SetVC_Suite( pcu_suite_t* suite ) {
- pcu_suite_setData( suite, SetVC_SuiteData );
- pcu_suite_setFixtures( suite, SetVC_Suite_Setup, SetVC_Suite_Teardown );
- pcu_suite_addTest( suite, SetVC_Suite_TestIsCondition );
- pcu_suite_addTest( suite, SetVC_Suite_TestGetValueIndex );
- pcu_suite_addTest( suite, SetVC_Suite_TestApply );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/SetVC_Suite.h
--- a/Base/Automation/tests/SetVC_Suite.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef StGermain_SetVC_Suite_h
-#define StGermain_SetVC_Suite_h
-
-void SetVC_Suite( pcu_suite_t* suite );
-
-#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/Stg_MetaSuite.c
--- a/Base/Automation/tests/Stg_MetaSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-**
-** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "pcu/pcu.h"
-#include "StGermain/Base/Foundation/Foundation.h"
-#include "StGermain/Base/IO/IO.h"
-#include "StGermain/Base/Container/Container.h"
-#include "StGermain/Base/Automation/Automation.h"
-#include "Stg_MetaSuite.h"
-
-
-typedef struct {
- XML_IO_Handler* io;
- Dictionary* metaDict;
- LiveComponentRegister* lcRegister;
-} Stg_MetaSuiteData;
-
-
-void Stg_MetaSuite_Setup( Stg_MetaSuiteData* data ) {
- data->io = XML_IO_Handler_New();
- data->metaDict = Dictionary_New();
- data->lcRegister = LiveComponentRegister_New( );
-}
-
-
-void Stg_MetaSuite_Teardown( Stg_MetaSuiteData* data ) {
- Stg_Class_Delete( data->io );
- Stg_Class_Delete( data->metaDict );
- Stg_Class_Delete( data->lcRegister );
-}
-
-
-/* Use this function if you need to regenerate the testing .xml file */
-void Stg_MetaSuite_RegenerateComponentVC_MetaFile( Stg_MetaSuiteData* data ) {
- Stg_Class_Delete( data->metaDict );
- data->metaDict = Stg_ComponentRegister_GetMetadata( Stg_ComponentRegister_Get_ComponentRegister(), CompositeVC_Type, "0" );
- IO_Handler_WriteAllToFile( data->io, "ComponentVCMetaDict.xml", data->metaDict );
-}
-
-
-void Stg_MetaSuite_TestGetFunctions( Stg_MetaSuiteData* data ) {
- char metaFilename[PCU_PATH_MAX];
- Index paramCount=0;
- Index assocCount=0;
-
- pcu_filename_input( "ComponentVCMetaDict.xml", metaFilename );
- IO_Handler_ReadAllFromFile( data->io, metaFilename, data->metaDict );
-
- pcu_check_streq( Stg_Meta_GetType( data->metaDict ), "CompositeVC" );
- pcu_check_streq( Stg_Meta_GetCreator( data->metaDict ), "VPAC" );
- pcu_check_streq( Stg_Meta_GetPublisher( data->metaDict ), "VPAC" );
- pcu_check_streq( Stg_Meta_GetRights( data->metaDict ), "The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html" );
- pcu_check_streq( Stg_Meta_GetSource( data->metaDict ), "./StGermain/Base/Automation/src/" );
- pcu_check_streq( Stg_Meta_GetSubject( data->metaDict ), "StGermain" );
- pcu_check_streq( Stg_Meta_GetDescription( data->metaDict ), "CompositeVC is used as a container to combine multiple variable conditions." );
- pcu_check_streq( Stg_Meta_GetExampleDocumentation( data->metaDict ), "" );
- pcu_check_streq( Stg_Meta_GetExampleCode( data->metaDict ), "Refer to ./StgFEM/Apps/StokesMomentumUzawa/lidDrivenBCs.xml" );
- pcu_check_streq( Stg_Meta_GetInherits( data->metaDict ), "VariableCondition" );
-
- pcu_check_streq( Stg_Meta_GetReference( data->metaDict ), "" );
- pcu_check_streq( Stg_Meta_GetEquation( data->metaDict ), "" );
-
- paramCount = Stg_Meta_GetParameterCount( data->metaDict );
- pcu_check_true( paramCount == 2 );
- pcu_check_streq( Stg_Meta_GetParameterName( data->metaDict, 0 ), "vcName" );
- pcu_check_streq( Stg_Meta_GetParameterType( data->metaDict, 0 ), "xsd:string" );
- pcu_check_streq( Stg_Meta_GetParameterDefault( data->metaDict, 0 ), "self->name" );
- pcu_check_streq( Stg_Meta_GetParameterDocumentation( data->metaDict, 0 ), "Deprecated; should not be used." );
- pcu_check_streq( Stg_Meta_GetParameterName( data->metaDict, 1 ), "vcList" );
- pcu_check_streq( Stg_Meta_GetParameterType( data->metaDict, 1 ), "stg:list" );
- pcu_check_streq( Stg_Meta_GetParameterDefault( data->metaDict, 1 ), "" );
- pcu_check_streq( Stg_Meta_GetParameterDocumentation( data->metaDict, 1 ), "A list of other VariableCondition definitions." );
-
- assocCount = Stg_Meta_GetAssociationCount( data->metaDict );
- pcu_check_true( assocCount == 1 );
- pcu_check_streq( Stg_Meta_GetAssociationName( data->metaDict, 0 ), "Data" );
- pcu_check_streq( Stg_Meta_GetAssociationType( data->metaDict, 0 ), "Stg_Component" );
- pcu_check_streq( Stg_Meta_GetAssociationNillable( data->metaDict, 0 ), "true" );
- pcu_check_streq( Stg_Meta_GetAssociationDocumentation( data->metaDict, 0 ), "User defined data in the form of a Stg_Component." );
-}
-
-
-void Stg_MetaSuite( pcu_suite_t* suite ) {
- pcu_suite_setData( suite, Stg_MetaSuiteData );
- pcu_suite_setFixtures( suite, Stg_MetaSuite_Setup, Stg_MetaSuite_Teardown );
- pcu_suite_addTest( suite, Stg_MetaSuite_TestGetFunctions );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/Stg_MetaSuite.h
--- a/Base/Automation/tests/Stg_MetaSuite.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef StGermain_Stg_MetaSuite_h
-#define StGermain_Stg_MetaSuite_h
-
-void Stg_MetaSuite( pcu_suite_t* suite );
-
-#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/VariableAllVC_Suite.c
--- a/Base/Automation/tests/VariableAllVC_Suite.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-**
-** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "pcu/pcu.h"
-#include "StGermain/Base/Foundation/Foundation.h"
-#include "StGermain/Base/IO/IO.h"
-#include "StGermain/Base/Container/Container.h"
-#include "StGermain/Base/Automation/Automation.h"
-#include "VariableAllVC_Suite.h"
-
-#define TEST_CONDVALUE 2.0
-
-
-typedef struct {
- Variable_Register* vr;
- ConditionFunction_Register* conFunc_Register;
- Dictionary* dict;
- double* testArray;
- Index arraySize;
- Variable* var;
- char* vcKey;
- VariableCondition* vc;
-} VariableAllVC_SuiteData;
-
-
-void VariableAllVC_Suite_CreateDictEntries( VariableAllVC_SuiteData* data ) {
- Dictionary_Entry_Value* info;
- Dictionary_Entry_Value* varList;
- Dictionary_Entry_Value* varValue;
-
- info = Dictionary_Entry_Value_NewStruct();
- varList = Dictionary_Entry_Value_NewList();
- varValue = Dictionary_Entry_Value_NewStruct();
-
- Dictionary_Entry_Value_AddMember( varValue, "name", Dictionary_Entry_Value_FromString( "test" ) );
- Dictionary_Entry_Value_AddMember( varValue, "type", Dictionary_Entry_Value_FromString( "double" ) );
- Dictionary_Entry_Value_AddMember( varValue, "value", Dictionary_Entry_Value_FromDouble( TEST_CONDVALUE ) );
-
- Dictionary_Entry_Value_AddElement( varList, varValue );
- Dictionary_Entry_Value_AddMember( info, "variables", varList );
- Dictionary_Add( data->dict, data->vcKey, info );
-}
-
-
-void VariableAllVC_Suite_Setup( VariableAllVC_SuiteData* data ) {
-
- data->arraySize = 10;
- data->testArray = Memory_Alloc_Array( double, data->arraySize, "test" );
-
- data->dict = Dictionary_New();
- data->conFunc_Register = ConditionFunction_Register_New();
- data->vr = Variable_Register_New();
-
- Stg_asprintf( &data->vcKey, "VariableAllVC" );
- VariableAllVC_Suite_CreateDictEntries( data );
-
- data->var = Variable_NewScalar(
- "test",
- Variable_DataType_Double,
- &data->arraySize,
- NULL,
- (void**)&data->testArray,
- data->vr );
-
- Variable_Register_BuildAll(data->vr);
-
- data->vc = (VariableCondition*) VariableAllVC_New( "variableAllVC", "VariableAllVC", data->vr, data->conFunc_Register,
- data->dict, NULL );
-
- Stg_Component_Build( data->vc, 0, False );
-}
-
-
-void VariableAllVC_Suite_Teardown( VariableAllVC_SuiteData* data ) {
- Index ii=0;
-
- Stg_Class_Delete(data->vr);
- Stg_Class_Delete(data->conFunc_Register);
- Stg_Class_Delete(data->dict);
-
- Memory_Free( data->testArray );
- Stg_Class_Delete( data->var );
-
- Stg_Class_Delete(data->vc);
-}
-
-
-void VariableAllVC_Suite_TestIsCondition( VariableAllVC_SuiteData* data ) {
- Index node_I=0;
-
- for (node_I = 0; node_I < data->arraySize; node_I++) {
- pcu_check_true( True == VariableCondition_IsCondition(data->vc, node_I, 0) );
- }
-}
-
-
-void VariableAllVC_Suite_TestGetValueIndex( VariableAllVC_SuiteData* data ) {
- Index node_I=0;
-
- for (node_I = 0; node_I < data->arraySize; node_I++) {
- pcu_check_true( 0 == VariableCondition_GetValueIndex(data->vc, node_I, 0) );
- }
-}
-
-
-void VariableAllVC_Suite_TestApply( VariableAllVC_SuiteData* data ) {
- Index var_I=0, node_I=0;
-
- VariableCondition_Apply(data->vc, NULL);
-
- for (node_I = 0; node_I < data->arraySize; node_I++) {
- pcu_check_true( TEST_CONDVALUE == data->testArray[node_I] );
- }
-}
-
-
-void VariableAllVC_Suite( pcu_suite_t* suite ) {
- pcu_suite_setData( suite, VariableAllVC_SuiteData );
- pcu_suite_setFixtures( suite, VariableAllVC_Suite_Setup, VariableAllVC_Suite_Teardown );
- pcu_suite_addTest( suite, VariableAllVC_Suite_TestIsCondition );
- pcu_suite_addTest( suite, VariableAllVC_Suite_TestGetValueIndex );
- pcu_suite_addTest( suite, VariableAllVC_Suite_TestApply );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/VariableAllVC_Suite.h
--- a/Base/Automation/tests/VariableAllVC_Suite.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef StGermain_VariableAllVC_Suite_h
-#define StGermain_VariableAllVC_Suite_h
-
-void VariableAllVC_Suite( pcu_suite_t* suite );
-
-#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/VariableDumpStreamSuite.c
--- a/Base/Automation/tests/VariableDumpStreamSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-**
-** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "pcu/pcu.h"
-#include "StGermain/Base/Foundation/Foundation.h"
-#include "StGermain/Base/IO/IO.h"
-#include "StGermain/Base/Container/Container.h"
-#include "StGermain/Base/Automation/Automation.h"
-#include "VariableDumpStreamSuite.h"
-
-typedef struct {
- Variable_Register* vr;
-} VariableDumpStreamSuiteData;
-
-
-void VariableDumpStreamSuite_Setup( VariableDumpStreamSuiteData* data ) {
- /* Construction phase --------------------------------------------------------------------------------------------*/
- data->vr = Variable_Register_New();
-}
-
-
-void VariableDumpStreamSuite_Teardown( VariableDumpStreamSuiteData* data ) {
- Variable_Index var_I;
-
- /* manually delete all the created Variables */
- for( var_I = 0; var_I < data->vr->count; var_I++ ) {
- Stg_Class_Delete( data->vr->_variable[var_I] );
- }
-
- Stg_Class_Delete( data->vr );
-}
-
-
-void VariableDumpStreamSuite_TestDump( VariableDumpStreamSuiteData* data ) {
- typedef double Triple[3];
- double* array;
- Triple* structArray;
- Index length = 10;
- Variable* var;
- Variable* vec;
- Stream* dumpStream = NULL;
- Stream* dumpStream2 = NULL;
- int i;
- const Name scalarDumpFilename = "./scalardump.dat" ;
- const Name vectorDumpFilename = "./vectordump.dat" ;
- FILE* scalarDumpFile = NULL;
- FILE* vectorDumpFile = NULL;
- float scalarCheck = 0;
- float vectorCheck[3] = {0,0,0};
-
- array = Memory_Alloc_Array( double, length, "test" );
- structArray = Memory_Alloc_Array( Triple, length, "test" );
-
- data->vr = Variable_Register_New();
-
- var = Variable_NewScalar(
- "Scalar",
- Variable_DataType_Double,
- &length,
- NULL,
- (void**)&array,
- data->vr );
-
- vec = Variable_NewVector(
- "Three",
- Variable_DataType_Double,
- 3,
- &length,
- NULL,
- (void**)&structArray,
- data->vr,
- "a",
- "b",
- "c" );
-
- Variable_Register_BuildAll( data->vr );
-
- for ( i = 0; i < length; ++i ) {
- Variable_SetValueDouble( var, i, 123.456 );
-
- Variable_SetValueAtDouble( vec, i, 0, 1.2 );
- Variable_SetValueAtDouble( vec, i, 1, 3.4 );
- Variable_SetValueAtDouble( vec, i, 2, 5.6 );
- }
-
- dumpStream = Journal_Register( VariableDumpStream_Type, "scalar dump" );
- VariableDumpStream_SetVariable( dumpStream, var, 1, 0, scalarDumpFilename );
- pcu_check_true( Journal_Dump( dumpStream, NULL ) );
- Stream_Flush( dumpStream );
-
- dumpStream2 = Journal_Register( VariableDumpStream_Type, "vector dump" );
- VariableDumpStream_SetVariable( dumpStream2, vec, 1, 0, vectorDumpFilename );
- pcu_check_true( Journal_Dump( dumpStream2, NULL ) );
- Stream_Flush( dumpStream2 );
-
- /* Really, you'd think there'd be a function to read a dumpStream. Anyway, hard-code for now */
- /* Don't want to use expected files here, since we need to continually check the writing ability
- * of these dump streams */
- scalarDumpFile = fopen( scalarDumpFilename, "r" );
- vectorDumpFile = fopen( vectorDumpFilename, "r" );
- for ( i = 0; i < length; ++i ) {
- /* See VariableDumpStream.c:166 */
- pcu_check_true( fread( &scalarCheck, sizeof(float), 1, scalarDumpFile ));
- pcu_check_true( fabs( scalarCheck - 123.456) < 0.0001 );
-
- pcu_check_true( fread( vectorCheck, sizeof(float), 3, vectorDumpFile ));
- pcu_check_true( fabs( vectorCheck[0] - 1.2 ) < 0.001 );
- pcu_check_true( fabs( vectorCheck[1] - 3.4 ) < 0.001 );
- pcu_check_true( fabs( vectorCheck[2] - 5.6 ) < 0.001 );
- }
-
- Memory_Free( array );
- Memory_Free( structArray );
-
- fclose( scalarDumpFile );
- fclose( vectorDumpFile );
- remove( scalarDumpFilename );
- remove( vectorDumpFilename );
-}
-
-
-void VariableDumpStreamSuite( pcu_suite_t* suite ) {
- pcu_suite_setData( suite, VariableDumpStreamSuiteData );
- pcu_suite_setFixtures( suite, VariableDumpStreamSuite_Setup, VariableDumpStreamSuite_Teardown );
- pcu_suite_addTest( suite, VariableDumpStreamSuite_TestDump );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/VariableDumpStreamSuite.h
--- a/Base/Automation/tests/VariableDumpStreamSuite.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef StGermain_VariableDumpStreamSuite_h
-#define StGermain_VariableDumpStreamSuite_h
-
-void VariableDumpStreamSuite( pcu_suite_t* suite );
-
-#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/VariableSuite.c
--- a/Base/Automation/tests/VariableSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,949 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-**
-** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "pcu/pcu.h"
-#include "StGermain/Base/Foundation/Foundation.h"
-#include "StGermain/Base/IO/IO.h"
-#include "StGermain/Base/Container/Container.h"
-#include "StGermain/Base/Automation/Automation.h"
-#include "VariableSuite.h"
-
-typedef double VectorD[3];
-typedef double VectorF[3];
-
-typedef struct {
- int mass;
- VectorF force;
- short num;
- char* info;
-} Particle;
-
-typedef struct {
- Variable_Register* vr;
- Index aSize[3];
- double* temperature;
- VectorD* velocity;
- Particle* particle;
-} VariableSuiteData;
-
-
-
-void VariableSuite_Setup( VariableSuiteData* data ) {
- Particle tmpParticle;
- Name pNames[] = { "mass", "force", "info" };
- SizeT pOffsets[] = { 0, 0, 0 }; /* Init later... */
- Variable_DataType pDataTypes[] = {
- Variable_DataType_Int,
- Variable_DataType_Float,
- Variable_DataType_Pointer, };
- Index pDtCounts[] = { 1, 3, 1 };
- static SizeT pSize = sizeof(Particle);
-
- data->aSize[0] = 16;
- data->aSize[1] = 16;
- data->aSize[2] = 16;
-
- pOffsets[0] = (ArithPointer)&tmpParticle.mass - (ArithPointer)&tmpParticle;
- pOffsets[1] = (ArithPointer)&tmpParticle.force - (ArithPointer)&tmpParticle;
- pOffsets[2] = (ArithPointer)&tmpParticle.info - (ArithPointer)&tmpParticle;
-
- /* Construction phase --------------------------------------------------------------------------------------------*/
- data->vr = Variable_Register_New();
- Variable_NewScalar( "temperature", Variable_DataType_Double, &data->aSize[0], NULL, (void**)&data->temperature, data->vr );
- Variable_NewVector( "velocity", Variable_DataType_Double, 3, &data->aSize[1], NULL, (void**)&data->velocity, data->vr, "vx", "vy", "vz" );
- Variable_New( "particle", 3, pOffsets, pDataTypes, pDtCounts, pNames, &pSize, &data->aSize[2], NULL, (void**)&data->particle, data->vr );
-
- /* Build phase ---------------------------------------------------------------------------------------------------*/
- data->temperature = Memory_Alloc_Array( double, data->aSize[0], "temperature" );
- data->velocity = Memory_Alloc_Array( VectorD, data->aSize[1], "velocity" );
- data->particle = Memory_Alloc_Array( Particle, data->aSize[2], "array" );
-
- Variable_Register_BuildAll( data->vr );
-}
-
-
-void VariableSuite_Teardown( VariableSuiteData* data ) {
- Variable_Index var_I;
-
- /* manually delete all the created Variables */
- for( var_I = 0; var_I < data->vr->count; var_I++ ) {
- Stg_Class_Delete( data->vr->_variable[var_I] );
- }
-
- Memory_Free( data->particle );
- Memory_Free( data->velocity );
- Memory_Free( data->temperature );
-}
-
-
-void VariableSuite_TestGetValueDouble( VariableSuiteData* data ) {
- Index ii;
-
- /* Test the Get and Set of a scalar double....................................................................... */
- /* Fill the temperature array with a known pattern of kinda random (bit filling) numbers. */
- for( ii = 0; ii < data->aSize[0]; ii++ ) {
- data->temperature[ii] = 1.0f / (data->aSize[0]+2) * (ii+1);
- }
-
- /* Check that Variable_GetValueDouble on the temperature Variable returns the right numbers */
- for( ii = 0; ii < data->aSize[0]; ii++ ) {
- Variable* var = Variable_Register_GetByName( data->vr, "temperature" );
- const double tmp = 1.0f / (data->aSize[0]+2) * (ii+1);
-
- pcu_check_true( Variable_GetValueDouble( var, ii ) == tmp );
- }
-}
-
-
-void VariableSuite_TestSetValueDouble( VariableSuiteData* data ) {
- Index ii;
-
- /* Fill the temperature Variable with another known pattern of kinda random (bit filling) numbers */
- for( ii = 0; ii < data->aSize[0]; ii++ ) {
- Variable* var = Variable_Register_GetByName( data->vr, "temperature" );
-
- Variable_SetValueDouble( var, ii, 1.0f - ( 1.0f / (data->aSize[0]+2) * (ii+1) ) );
- }
-
- /* Check that Variable_SetValueDouble on the temperature Variable set the right numbers */
- for( ii = 0; ii < data->aSize[0]; ii++ ) {
- const double tmp = 1.0f - 1.0f / (data->aSize[0]+2) * (ii+1);
-
- pcu_check_true( data->temperature[ii] == tmp );
- }
-}
-
-
-/* Test the Get and Set of a vector double....................................................................... */
-void VariableSuite_TestGetValueAtDouble( VariableSuiteData* data ) {
- Index ii;
-
-/* Fill the velocity array with a known pattern of kinda random (bit filling) numbers. */
- for( ii = 0; ii < data->aSize[1]; ii++ ) {
- int d;
-
- for( d = 0; d < 3; d++ ) {
- data->velocity[ii][d] = 1.0f / ((data->aSize[1]*3)+2) * (ii*3+d+1);
- }
- }
-
- /* Check that Variable_GetPtrDouble on the velocity Variable returns the right numbers */
- for( ii = 0; ii < data->aSize[1]; ii++ ) {
- Variable* var = Variable_Register_GetByName( data->vr, "velocity" );
- int d;
-
- for( d = 0; d < 3; d++ ) {
- const double tmp = 1.0f / ((data->aSize[1]*3)+2) * (ii*3+d+1);
-
- pcu_check_true( Variable_GetValueAtDouble( var, ii, d ) == tmp );
- }
- }
-}
-
-
-void VariableSuite_TestSetValueAtDouble( VariableSuiteData* data ) {
- Index ii;
-
- /* Fill the variable Variable with another known pattern of kinda random (bit filling) numbers */
- for( ii = 0; ii < data->aSize[1]; ii++ ) {
- Variable* var = Variable_Register_GetByName( data->vr, "velocity" );
- int d;
-
- for( d = 0; d < 3; d++ ) {
- Variable_SetValueAtDouble( var, ii, d, 1.0f - ( 1.0f / ((data->aSize[1]*3)+2) * (ii*3+d+1) ) );
- }
- }
-
- /* Check that Variable_SetValueDouble on the temperature Variable set the right numbers */
- for( ii = 0; ii < data->aSize[1]; ii++ ) {
- int d;
-
- for( d = 0; d < 3; d++ ) {
- const double tmp = 1.0f - ( 1.0f / ((data->aSize[1]*3)+2) * (ii*3+d+1) );
-
- pcu_check_true( data->velocity[ii][d] == tmp );
- }
- }
-}
-
-
-/* TODO: try out vx, vy, vz, complex tests */
-
-void VariableSuite_TestVariable_Char( VariableSuiteData* data ) {
- typedef char Triple[3];
- char* array;
- Triple* structArray;
- Index length = 10;
- /* List of values to test the variable with.
- * Values to test are hex 5's and a's because they are a series of 0101 and 1010 respectively so they test
- * each bit in memory to read/set.
- */
- long int testValues[] = { 0x55, 0xaa };
- Index testValueCount = 2;
- Index test_I;
- long int testValue;
- Variable* var;
- Variable* vec;
- Variable* vecVar[3];
- int i, j;
-
- array = Memory_Alloc_Array( char, length, "test" );
- structArray = Memory_Alloc_Array( Triple, length, "test" );
-
- var = Variable_NewScalar(
- "Char-Scalar",
- Variable_DataType_Char,
- &length,
- NULL,
- (void**)&array,
- data->vr );
-
- vec = Variable_NewVector(
- "Char-Three",
- Variable_DataType_Char,
- 3,
- &length,
- NULL,
- (void**)&structArray,
- data->vr,
- "a",
- "b",
- "c" );
- vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
- vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
- vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
-
- Variable_Register_BuildAll( data->vr );
-
- for ( test_I = 0; test_I < testValueCount; ++test_I ) {
-
- testValue = testValues[test_I];
-
- for ( i = 0; i < length; ++i ) {
- Variable_SetValueChar( var, i, testValue );
- Variable_SetValueAtChar( vec, i, 0, testValue );
- Variable_SetValueAtChar( vec, i, 1, testValue );
- Variable_SetValueAtChar( vec, i, 2, testValue );
- }
-
- /* ~~~Scalar~~~*/
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueChar( var, i ) == (char)(char)testValue );
- pcu_check_true( Variable_GetValueCharAsShort( var, i ) == (short)(char)testValue );
- pcu_check_true( Variable_GetValueCharAsInt( var, i ) == (int)(char)testValue );
- pcu_check_true( Variable_GetValueCharAsFloat( var, i ) == (float)(char)testValue );
- pcu_check_true( Variable_GetValueCharAsDouble( var, i ) == (double)(char)testValue );
- }
-
- /*~~~Vector~~~*/
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueAtChar( vec, i, 0 ) == (char)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsShort( vec, i, 0 ) == (short)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsInt( vec, i, 0 ) == (int)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsFloat( vec, i, 0 ) == (float)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsDouble( vec, i, 0 ) == (double)(char)testValue );
-
- pcu_check_true( Variable_GetPtrAtChar( vec, i, 0 ) == &structArray[i][0] );
-
- pcu_check_true( Variable_GetValueAtChar( vec, i, 1 ) == (char)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsShort( vec, i, 1 ) == (short)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsInt( vec, i, 1 ) == (int)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsFloat( vec, i, 1 ) == (float)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsDouble( vec, i, 1 ) == (double)(char)testValue );
- pcu_check_true( Variable_GetPtrAtChar( vec, i, 1 ) == &structArray[i][1] );
-
- pcu_check_true( Variable_GetValueAtChar( vec, i, 2 ) == (char)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsShort( vec, i, 2 ) == (short)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsInt( vec, i, 2 ) == (int)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsFloat( vec, i, 2 ) == (float)(char)testValue );
- pcu_check_true( Variable_GetValueAtCharAsDouble( vec, i, 2 ) == (double)(char)testValue );
- pcu_check_true( Variable_GetPtrAtChar( vec, i, 2 ) == &structArray[i][2] );
- }
-
- /*~~~Vector: Sub-Variable~~~*/
- for ( i = 0; i < length; ++i ) {
- for ( j = 0; j < 3; ++j ) {
- pcu_check_true( _Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
- }
- }
- }
-}
-
-
-void VariableSuite_TestVariable_Double( VariableSuiteData* data ) {
- typedef double Triple[3];
-
- double* array;
- Triple* structArray;
- Index length = 10;
-
- double testValues[] = { 123456789.0, 0.987654321 };
- Index testValueCount = 2;
- Index test_I;
- double testValue;
-
- Variable* var;
- Variable* vec;
- Variable* vecVar[3];
-
- int i, j;
-
- array = Memory_Alloc_Array( double, length, "test" );
- structArray = Memory_Alloc_Array( Triple, length, "test" );
-
- var = Variable_NewScalar(
- "Double-Scalar",
- Variable_DataType_Double,
- &length,
- NULL,
- (void**)&array,
- data->vr );
-
- vec = Variable_NewVector(
- "Double-Three",
- Variable_DataType_Double,
- 3,
- &length,
- NULL,
- (void**)&structArray,
- data->vr,
- "a",
- "b",
- "c" );
- vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
- vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
- vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
-
- Variable_Register_BuildAll( data->vr );
-
-
- for ( test_I = 0; test_I < testValueCount; ++test_I ) {
-
- testValue = testValues[test_I];
-
- for ( i = 0; i < length; ++i ) {
- Variable_SetValueDouble( var, i, testValue );
-
- Variable_SetValueAtDouble( vec, i, 0, testValue );
- Variable_SetValueAtDouble( vec, i, 1, testValue );
- Variable_SetValueAtDouble( vec, i, 2, testValue );
- }
-
- /* "~~~Scalar~~~\n" */
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueDouble( var, i ) == (double)(double)testValue );
- pcu_check_true( Variable_GetValueDoubleAsChar( var, i ) == (char)(double)testValue );
- pcu_check_true( Variable_GetValueDoubleAsShort( var, i ) == (short)(double)testValue );
- pcu_check_true( Variable_GetValueDoubleAsInt( var, i ) == (int)(double)testValue );
- pcu_check_true( Variable_GetValueDoubleAsFloat( var, i ) == (float)(double)testValue );
- }
-
- /*~~~Vector~~~*/
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueAtDouble( vec, i, 0 ) == (double)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsChar( vec, i, 0 ) == (char)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsShort( vec, i, 0 ) == (short)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsInt( vec, i, 0 ) == (int)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsFloat( vec, i, 0 ) == (float)(double)testValue );
- pcu_check_true( Variable_GetPtrAtDouble( vec, i, 0 ) == &structArray[i][0] );
-
- pcu_check_true( Variable_GetValueAtDouble( vec, i, 1 ) == (double)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsChar( vec, i, 1 ) == (char)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsShort( vec, i, 1 ) == (short)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsInt( vec, i, 1 ) == (int)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsFloat( vec, i, 1 ) == (float)(double)testValue );
- pcu_check_true( Variable_GetPtrAtDouble( vec, i, 1 ) == &structArray[i][1] );
-
- pcu_check_true( Variable_GetValueAtDouble( vec, i, 2 ) == (double)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsChar( vec, i, 2 ) == (char)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsShort( vec, i, 2 ) == (short)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsInt( vec, i, 2 ) == (int)(double)testValue );
- pcu_check_true( Variable_GetValueAtDoubleAsFloat( vec, i, 2 ) == (float)(double)testValue );
- pcu_check_true( Variable_GetPtrAtDouble( vec, i, 2 ) == &structArray[i][2] );
- }
-
- /*~~~Vector: Sub-Variable~~~*/
- for ( i = 0; i < length; ++i ) {
- for ( j = 0; j < 3; ++j ) {
- pcu_check_true( Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
- }
- }
- }
-}
-
-
-void VariableSuite_TestVariable_Float( VariableSuiteData* data ) {
- typedef float Triple[3];
-
- float* array;
- Triple* structArray;
- Index length = 10;
-
- float testValues[] = { 123456789.0, 0.987654321 };
- Index testValueCount = 2;
- Index test_I;
- float testValue;
-
- Variable* var;
- Variable* vec;
- Variable* vecVar[3];
-
- int i, j;
-
- array = Memory_Alloc_Array( float, length, "test" );
- structArray = Memory_Alloc_Array( Triple, length, "test" );
-
- var = Variable_NewScalar(
- "Float-Scalar",
- Variable_DataType_Float,
- &length,
- NULL,
- (void**)&array,
- data->vr );
-
- vec = Variable_NewVector(
- "Float-Three",
- Variable_DataType_Float,
- 3,
- &length,
- NULL,
- (void**)&structArray,
- data->vr,
- "a",
- "b",
- "c" );
- vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
- vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
- vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
-
- Variable_Register_BuildAll( data->vr );
-
- for ( test_I = 0; test_I < testValueCount; ++test_I ) {
-
- testValue = testValues[test_I];
-
- for ( i = 0; i < length; ++i ) {
- Variable_SetValueFloat( var, i, testValue );
-
- Variable_SetValueAtFloat( vec, i, 0, testValue );
- Variable_SetValueAtFloat( vec, i, 1, testValue );
- Variable_SetValueAtFloat( vec, i, 2, testValue );
- }
-
- /* "~~~Scalar~~~\n" */
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueFloat( var, i ) == (float)(float)testValue );
- pcu_check_true( Variable_GetValueFloatAsChar( var, i ) == (float)(char)testValue );
- pcu_check_true( Variable_GetValueFloatAsShort( var, i ) == (float)(short)testValue );
- pcu_check_true( Variable_GetValueFloatAsInt( var, i ) == (float)(int)testValue );
- pcu_check_true( Variable_GetValueFloatAsDouble( var, i ) == (double)(float)testValue );
- }
-
- /*~~~Vector~~~*/
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueAtFloat( vec, i, 0 ) == (float)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsChar( vec, i, 0 ) == (char)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsShort( vec, i, 0 ) == (short)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsInt( vec, i, 0 ) == (int)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsDouble( vec, i, 0 ) == (double)(float)testValue );
- pcu_check_true( Variable_GetPtrAtFloat( vec, i, 0 ) == &structArray[i][0] );
-
- pcu_check_true( Variable_GetValueAtFloat( vec, i, 1 ) == (float)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsChar( vec, i, 1 ) == (char)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsShort( vec, i, 1 ) == (short)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsInt( vec, i, 1 ) == (int)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsDouble( vec, i, 1 ) == (double)(float)testValue );
- pcu_check_true( Variable_GetPtrAtFloat( vec, i, 1 ) == &structArray[i][1] );
-
- pcu_check_true( Variable_GetValueAtFloat( vec, i, 2 ) == (float)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsChar( vec, i, 2 ) == (char)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsShort( vec, i, 2 ) == (short)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsInt( vec, i, 2 ) == (int)(float)testValue );
- pcu_check_true( Variable_GetValueAtFloatAsDouble( vec, i, 2 ) == (double)(float)testValue );
- pcu_check_true( Variable_GetPtrAtFloat( vec, i, 2 ) == &structArray[i][2] );
- }
-
- /*~~~Vector: Sub-Variable~~~*/
- for ( i = 0; i < length; ++i ) {
- for ( j = 0; j < 3; ++j ) {
- pcu_check_true( Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
- }
- }
- }
-}
-
-
-void VariableSuite_TestVariable_Int( VariableSuiteData* data ) {
- typedef int Triple[3];
-
- int* array;
- Triple* structArray;
- Index length = 10;
-
- /* List of values to test the variable with.
- * Values to test are hex 5's and a's because they are a series of 0101 and 1010 respectively so they test
- * each bit in memory to read/set.
- */
- long int testValues[] = { 0x55555555, 0xaaaaaaaa };
- Index testValueCount = 2;
- Index test_I;
- long int testValue;
-
- Variable* var;
- Variable* vec;
- Variable* vecVar[3];
-
- int i, j;
-
- array = Memory_Alloc_Array( int, length, "test" );
- structArray = Memory_Alloc_Array( Triple, length, "test" );
-
- var = Variable_NewScalar(
- "Int-Scalar",
- Variable_DataType_Int,
- &length,
- NULL,
- (void**)&array,
- data->vr );
-
- vec = Variable_NewVector(
- "Int-Three",
- Variable_DataType_Int,
- 3,
- &length,
- NULL,
- (void**)&structArray,
- data->vr,
- "a",
- "b",
- "c" );
- vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
- vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
- vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
-
- Variable_Register_BuildAll( data->vr );
-
- for ( test_I = 0; test_I < testValueCount; ++test_I ) {
-
- testValue = testValues[test_I];
-
- for ( i = 0; i < length; ++i ) {
- Variable_SetValueInt( var, i, testValue );
-
- Variable_SetValueAtInt( vec, i, 0, testValue );
- Variable_SetValueAtInt( vec, i, 1, testValue );
- Variable_SetValueAtInt( vec, i, 2, testValue );
- }
-
- /*~~~Scalar~~~*/
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueInt( var, i ) == (int)(int)testValue );
- pcu_check_true( Variable_GetValueIntAsChar( var, i ) == (char)(int)testValue );
- pcu_check_true( Variable_GetValueIntAsShort( var, i ) == (short)(int)testValue );
- pcu_check_true( fabsf(Variable_GetValueIntAsFloat( var, i ) - (float)(int)testValue) < fabsf(0.00001*testValue) );
- pcu_check_true( fabs(Variable_GetValueIntAsDouble( var, i ) - (double)(int)testValue) < fabs(0.00001*testValue) );
- }
-
- /*~~~Vector~~~*/
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueAtInt( vec, i, 0 ) == (int)(int)testValue );
- pcu_check_true( Variable_GetValueAtIntAsChar( vec, i, 0 ) == (char)(int)testValue );
- pcu_check_true( Variable_GetValueAtIntAsShort( vec, i, 0 ) == (short)(int)testValue );
- pcu_check_true( fabsf(Variable_GetValueAtIntAsFloat( vec, i, 0 ) - (float)(int)testValue) < fabsf(0.00001*testValue) );
- pcu_check_true( fabs(Variable_GetValueAtIntAsDouble( vec, i, 0 ) - (double)(int)testValue) < fabs(0.00001*testValue));
- pcu_check_true( Variable_GetPtrAtInt( vec, i, 0 ) == &structArray[i][0] );
-
- pcu_check_true( Variable_GetValueAtInt( vec, i, 1 ) == (int)(int)testValue );
- pcu_check_true( Variable_GetValueAtIntAsChar( vec, i, 1 ) == (char)(int)testValue );
- pcu_check_true( Variable_GetValueAtIntAsShort( vec, i, 1 ) == (short)(int)testValue );
- pcu_check_true( fabsf(Variable_GetValueAtIntAsFloat( vec, i, 1 ) - (float)(int)testValue) < fabsf(0.00001*testValue) );
- pcu_check_true( fabs(Variable_GetValueAtIntAsDouble( vec, i, 1 ) - (double)(int)testValue) < fabs(0.00001*testValue));
- pcu_check_true( Variable_GetPtrAtInt( vec, i, 1 ) == &structArray[i][1] );
-
- pcu_check_true( Variable_GetValueAtInt( vec, i, 2 ) == (int)(int)testValue );
- pcu_check_true( Variable_GetValueAtIntAsChar( vec, i, 2 ) == (char)(int)testValue );
- pcu_check_true( Variable_GetValueAtIntAsShort( vec, i, 2 ) == (short)(int)testValue );
- pcu_check_true( fabsf(Variable_GetValueAtIntAsFloat( vec, i, 2 ) - (float)(int)testValue) < fabsf(0.00001*testValue));
- pcu_check_true( fabs(Variable_GetValueAtIntAsDouble( vec, i, 2 ) - (double)(int)testValue) < fabs(0.0001*testValue));
- pcu_check_true( Variable_GetPtrAtInt( vec, i, 2 ) == &structArray[i][2] );
- }
-
- /*~~~Vector: Sub-Variable~~~*/
- for ( i = 0; i < length; ++i ) {
- for ( j = 0; j < 3; ++j ) {
- pcu_check_true( Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
- }
- }
- }
-}
-
-
-void VariableSuite_TestVariable_Short( VariableSuiteData* data ) {
- typedef short Triple[3];
-
- short* array;
- Triple* structArray;
- Index length = 10;
-
- /* List of values to test the variable with.
- * Values to test are hex 5's and a's because they are a series of 0101 and 1010 respectively so they test
- * each bit in memory to read/set.
- */
- long int testValues[] = { 0x5555, 0xaaaa };
- Index testValueCount = 2;
- Index test_I;
- long int testValue;
-
- Variable* var;
- Variable* vec;
- Variable* vecVar[3];
-
- int i, j;
-
- array = Memory_Alloc_Array( short, length, "test" );
- structArray = Memory_Alloc_Array( Triple, length, "test" );
-
- var = Variable_NewScalar(
- "Short-Scalar",
- Variable_DataType_Short,
- &length,
- NULL,
- (void**)&array,
- data->vr );
-
- vec = Variable_NewVector(
- "Short-Three",
- Variable_DataType_Short,
- 3,
- &length,
- NULL,
- (void**)&structArray,
- data->vr,
- "a",
- "b",
- "c" );
- vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
- vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
- vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
-
- Variable_Register_BuildAll( data->vr );
-
-
- for ( test_I = 0; test_I < testValueCount; ++test_I ) {
-
- testValue = testValues[test_I];
-
-
- for ( i = 0; i < length; ++i ) {
- Variable_SetValueShort( var, i, testValue );
-
- Variable_SetValueAtShort( vec, i, 0, testValue );
- Variable_SetValueAtShort( vec, i, 1, testValue );
- Variable_SetValueAtShort( vec, i, 2, testValue );
- }
-
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueShort( var, i ) == (short)(short)testValue );
- pcu_check_true( Variable_GetValueShortAsChar( var, i ) == (char)(short)testValue );
- pcu_check_true( Variable_GetValueShortAsInt( var, i ) == (int)(short)testValue );
- pcu_check_true( Variable_GetValueShortAsFloat( var, i ) == (float)(short)testValue );
- pcu_check_true( Variable_GetValueShortAsDouble( var, i ) == (double)(short)testValue );
- }
-
- for ( i = 0; i < length; ++i ) {
- pcu_check_true( Variable_GetValueAtShort( vec, i, 0 ) == (short)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsChar( vec, i, 0 ) == (char)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsInt( vec, i, 0 ) == (int)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsFloat( vec, i, 0 ) == (float)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsDouble( vec, i, 0 ) == (double)(short)testValue );
- pcu_check_true( Variable_GetPtrAtShort( vec, i, 0 ) == &structArray[i][0] );
-
- pcu_check_true( Variable_GetValueAtShort( vec, i, 1 ) == (short)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsChar( vec, i, 1 ) == (char)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsInt( vec, i, 1 ) == (int)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsFloat( vec, i, 1 ) == (float)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsDouble( vec, i, 1 ) == (double)(short)testValue );
- pcu_check_true( Variable_GetPtrAtShort( vec, i, 1 ) == &structArray[i][1] );
-
- pcu_check_true( Variable_GetValueAtShort( vec, i, 2 ) == (short)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsChar( vec, i, 2 ) == (char)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsInt( vec, i, 2 ) == (int)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsFloat( vec, i, 2 ) == (float)(short)testValue );
- pcu_check_true( Variable_GetValueAtShortAsDouble( vec, i, 2 ) == (double)(short)testValue );
- pcu_check_true( Variable_GetPtrAtShort( vec, i, 2 ) == &structArray[i][2] );
- }
-
- for ( i = 0; i < length; ++i ) {
- for ( j = 0; j < 3; ++j ) {
- pcu_check_true( Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
- }
- }
- }
-}
-
-
-/* A few typedefs needed for the next test */
-#define VECTOR_DATA_COUNT 3
-typedef double Triple[VECTOR_DATA_COUNT];
-
-struct ComplexStuff {
- int x;
- float y;
- char z; /* variablise the y and z member */
-};
-typedef struct ComplexStuff ComplexStuff;
-
-struct MockContext {
- float* scalars;
- Index scalarCount;
- Triple* vectors;
- Index vectorCount;
- ComplexStuff* stuff;
- Index stuffCount;
- SizeT complexStuffSize;
- Variable_Register* vr;
-};
-typedef struct MockContext MockContext;
-
-void VariableSuite_TestVariableCopy( VariableSuiteData* data ) {
- MockContext* ctx1 = NULL;
- MockContext* ctx2 = NULL;
- Variable* scalar = NULL;
- Variable* vector = NULL;
- Variable* complexStuff = NULL;
- PtrMap* ptrMap = PtrMap_New( 10 );
- Index ii=0;
- Index jj=0;
- Index var_I=0;
-
-
- ctx1 = Memory_Alloc( MockContext, "ctx1" );
- ctx2 = Memory_Alloc( MockContext, "ctx2" );
-
- ctx1->scalarCount = 10;
- ctx1->vectorCount = 10;
- ctx1->stuffCount = 10;
- ctx1->complexStuffSize = sizeof( ComplexStuff );
-
- ctx1->scalars = Memory_Alloc_Array( float, ctx1->scalarCount, "ctx1->scalars" );
- ctx1->vectors = Memory_Alloc_Array( Triple, ctx1->vectorCount, "ctx1->vectors" );
- ctx1->stuff = Memory_Alloc_Array( ComplexStuff, ctx1->stuffCount, "ctx1->stuff" );
-
- ctx1->vr = Variable_Register_New();
-
- Variable_NewScalar(
- "Scalar",
- Variable_DataType_Float,
- &(ctx1->scalarCount),
- NULL,
- (void**)&(ctx1->scalars),
- ctx1->vr );
- Variable_NewVector(
- "Vector",
- Variable_DataType_Double,
- VECTOR_DATA_COUNT,
- &(ctx1->vectorCount),
- NULL,
- (void**)&(ctx1->vectors),
- ctx1->vr,
- "x",
- "y",
- "z" );
- {
- ComplexStuff tmp;
- SizeT dataOffsets[] = { 0, 0 };
- Variable_DataType dataTypes[] = { Variable_DataType_Float, Variable_DataType_Char };
- Index dataTypeCounts[] = { 1, 1 };
- Name dataNames[] = { "complexY", "complexZ" };
-
- dataOffsets[0] = (ArithPointer)&tmp.y - (ArithPointer)&tmp;
- dataOffsets[1] = (ArithPointer)&tmp.z - (ArithPointer)&tmp;
-
- Variable_New(
- "Complex",
- 2,
- dataOffsets,
- dataTypes,
- dataTypeCounts,
- dataNames,
- &(ctx1->complexStuffSize),
- &(ctx1->stuffCount),
- NULL,
- (void**)&(ctx1->stuff),
- ctx1->vr );
- }
-
- Variable_Register_BuildAll( ctx1->vr );
-
- scalar = Variable_Register_GetByName( ctx1->vr, "Scalar" );
- vector = Variable_Register_GetByName( ctx1->vr, "Vector" );
- complexStuff = Variable_Register_GetByName( ctx1->vr, "Complex" );
-
- for ( ii = 0; ii < ctx1->scalarCount; ++ii ) {
- Variable_SetValueFloat( scalar, ii, (float)ii );
- }
- for ( ii = 0; ii < ctx1->vectorCount; ++ii ) {
- Variable_SetValueAtDouble( vector, ii, 0, (double)ii );
- Variable_SetValueAtDouble( vector, ii, 1, (double)ii );
- Variable_SetValueAtDouble( vector, ii, 2, (double)ii );
- }
- for ( ii = 0; ii < ctx1->stuffCount; ++ii ) {
- ComplexStuff* stuff = Variable_GetStructPtr( complexStuff, ii );
- stuff->y = (float)ii;
- stuff->z = '0' + ii;
- }
-
- /* Indicate the area of memory which is given for data so that Variables can attach to it */
- PtrMap_Append( ptrMap, &(ctx1->scalars), &(ctx2->scalars) );
- PtrMap_Append( ptrMap, &(ctx1->vectors), &(ctx2->vectors) );
- PtrMap_Append( ptrMap, &(ctx1->stuff), &(ctx2->stuff) );
-
- PtrMap_Append( ptrMap, &(ctx1->scalarCount), &(ctx2->scalarCount) );
- PtrMap_Append( ptrMap, &(ctx1->vectorCount), &(ctx2->vectorCount) );
- PtrMap_Append( ptrMap, &(ctx1->stuffCount), &(ctx2->stuffCount) );
- PtrMap_Append( ptrMap, &(ctx1->complexStuffSize), &(ctx2->complexStuffSize) );
-
- ctx2->scalars = Memory_Alloc_Array( float, ctx1->scalarCount, "scalars" );
- ctx2->vectors = Memory_Alloc_Array( Triple, ctx1->vectorCount, "vectors" );
- ctx2->stuff = Memory_Alloc_Array( ComplexStuff, ctx1->stuffCount, "stuff" );
- PtrMap_Append( ptrMap, ctx1->scalars, ctx2->scalars );
- PtrMap_Append( ptrMap, ctx1->vectors, ctx2->vectors );
- PtrMap_Append( ptrMap, ctx1->stuff, ctx2->stuff );
-
- /* Doing a copy of the whole Variable Register, should trigger a copy of the values in all the variables */
- ctx2->vr = Stg_Class_Copy( ctx1->vr, NULL, True, NULL, ptrMap );
-
- /* test equality of copy */
- for ( ii = 0; ii < ctx1->scalarCount; ++ii ) {
- pcu_check_true( ctx1->scalars[ii] == ctx2->scalars[ii] );
- }
- for ( ii = 0; ii < ctx1->vectorCount; ++ii ) {
- for ( jj = 0; jj < VECTOR_DATA_COUNT; ++jj ) {
- pcu_check_true( ctx1->vectors[ii][jj] == ctx2->vectors[ii][jj] );
- }
- }
- for ( ii = 0; ii < ctx1->stuffCount; ++ii ) {
- pcu_check_true( ctx1->stuff->y == ctx2->stuff->y );
- pcu_check_true( ctx1->stuff->z == ctx2->stuff->z );
- }
-
- /* Clean up */
- for ( var_I = 0; var_I < ctx1->vr->count; ++var_I ) {
- Stg_Class_Delete( ctx1->vr->_variable[var_I] );
- }
- Memory_Free( ctx1->scalars );
- Memory_Free( ctx1->vectors );
- Memory_Free( ctx1->stuff );
- Stg_Class_Delete( ctx1->vr );
- Memory_Free( ctx1 );
- for ( var_I = 0; var_I < ctx2->vr->count; ++var_I ) {
- Stg_Class_Delete( ctx2->vr->_variable[var_I] );
- }
- Memory_Free( ctx2->scalars );
- Memory_Free( ctx2->vectors );
- Memory_Free( ctx2->stuff );
- Stg_Class_Delete( ctx2->vr );
- Memory_Free( ctx2 );
-}
-
-
-void VariableSuite_TestVariableValueCompare( VariableSuiteData* data ) {
- Variable* orig;
- Variable* compare;
- double* dataArray;
- double* dataArray2;
- Index arrayCount = 150;
- Index componentCount = 4;
- Index index;
- double amp = 0.1;
- double tolerance = 0.04;
-
- dataArray = Memory_Alloc_Array( double, arrayCount * componentCount, "test" );
- dataArray2 = Memory_Alloc_Array( double, arrayCount * componentCount, "test" );
- for( index = 0; index < arrayCount * componentCount; index++ ) {
- dataArray[index] = 1.0f / (arrayCount+2) * (index+1);
- dataArray2[ index ] = dataArray[ index ] + amp * cos( index );
- }
-
- orig = Variable_NewVector(
- "orig",
- Variable_DataType_Double,
- componentCount,
- &arrayCount,
- NULL,
- (void**)&dataArray,
- data->vr,
- "orig1",
- "orig2",
- "orig3",
- "orig4" );
- compare = Variable_NewVector(
- "compare",
- Variable_DataType_Double,
- componentCount,
- &arrayCount,
- NULL,
- (void**)&dataArray2,
- data->vr,
- "compare1",
- "compare2",
- "compare3",
- "compare4" );
- Stg_Component_Build( orig, 0, False );
- Stg_Component_Build( compare, 0, False );
-
- pcu_check_true( abs( 0.030987 - Variable_ValueCompare( orig, compare ) ) < 0.00001 );
- pcu_check_true( True == Variable_ValueCompareWithinTolerance( orig, compare, tolerance ) );
-
- Memory_Free( dataArray );
- Memory_Free( dataArray2 );
-}
-
-
-void VariableSuite( pcu_suite_t* suite ) {
- pcu_suite_setData( suite, VariableSuiteData );
- pcu_suite_setFixtures( suite, VariableSuite_Setup, VariableSuite_Teardown );
- pcu_suite_addTest( suite, VariableSuite_TestGetValueDouble );
- pcu_suite_addTest( suite, VariableSuite_TestSetValueDouble );
- pcu_suite_addTest( suite, VariableSuite_TestGetValueAtDouble );
- pcu_suite_addTest( suite, VariableSuite_TestSetValueAtDouble );
- pcu_suite_addTest( suite, VariableSuite_TestVariable_Char );
- pcu_suite_addTest( suite, VariableSuite_TestVariable_Double );
- pcu_suite_addTest( suite, VariableSuite_TestVariable_Float );
- pcu_suite_addTest( suite, VariableSuite_TestVariable_Int );
- pcu_suite_addTest( suite, VariableSuite_TestVariable_Short );
- pcu_suite_addTest( suite, VariableSuite_TestVariableCopy );
- pcu_suite_addTest( suite, VariableSuite_TestVariableValueCompare );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/VariableSuite.h
--- a/Base/Automation/tests/VariableSuite.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef StGermain_VariableSuite_h
-#define StGermain_VariableSuite_h
-
-void VariableSuite( pcu_suite_t* suite );
-
-#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/Variable_RegisterSuite.c
--- a/Base/Automation/tests/Variable_RegisterSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-**
-** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "pcu/pcu.h"
-#include "StGermain/Base/Foundation/Foundation.h"
-#include "StGermain/Base/IO/IO.h"
-#include "StGermain/Base/Container/Container.h"
-#include "StGermain/Base/Automation/Automation.h"
-#include "Variable_RegisterSuite.h"
-
-typedef struct {
- Variable_Register* reg;
-} Variable_RegisterSuiteData;
-
-
-void Variable_RegisterSuite_Setup( Variable_RegisterSuiteData* data ) {
- data->reg = Variable_Register_New();
-}
-
-void Variable_RegisterSuite_Teardown( Variable_RegisterSuiteData* data ) {
- Stg_Class_Delete( data->reg );
-}
-
-
-void Variable_RegisterSuite_TestAddGet( Variable_RegisterSuiteData* data ) {
- Variable* var[10];
- #define ARRAY_SIZE 4
- #define STRUCT_SIZE 4
- double array[ARRAY_SIZE];
- Index arraySize = ARRAY_SIZE;
- char* name[10] = {"testVar0", "testVar1", "testVar2", "testVar3",
- "testVar4", "testVar5", "testVar6", "testVar7",
- "testVar8", "testVar9"};
- Index i;
-
- for (i = 0; i < 10; i++) {
- var[i] = Variable_NewVector( name[i], Variable_DataType_Double, 4, &arraySize, NULL, (void**)&array, 0 );
- }
-
- for (i = 0; i < 10; i++)
- {
- Variable_Register_Add(data->reg, var[i]);
- }
-
- for (i = 0; i < 10; i++) {
- pcu_check_true( i == Variable_Register_GetIndex(data->reg, name[i]));
- }
-
- for (i = 0; i < 10; i++) {
- pcu_check_true( var[i] == Variable_Register_GetByName(data->reg, name[i]));
- }
-
- for (i = 0; i < 10; i++) {
- Stg_Class_Delete(var[i]);
- }
-}
-
-
-void Variable_RegisterSuite( pcu_suite_t* suite ) {
- pcu_suite_setData( suite, Variable_RegisterSuiteData );
- pcu_suite_setFixtures( suite, Variable_RegisterSuite_Setup, Variable_RegisterSuite_Teardown );
- pcu_suite_addTest( suite, Variable_RegisterSuite_TestAddGet );
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/Variable_RegisterSuite.h
--- a/Base/Automation/tests/Variable_RegisterSuite.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef StGermain_Variable_RegisterSuite_h
-#define StGermain_Variable_RegisterSuite_h
-
-void Variable_RegisterSuite( pcu_suite_t* suite );
-
-#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/input/ComponentVCMetaDict.xml
--- a/Base/Automation/tests/input/ComponentVCMetaDict.xml Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-<?xml version="1.0"?>
-<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
- <element type="param" name="xml"><?xml version="1.0" ?>
-<meta xmlns="urn:stgermainmeta-schema" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://purl.org/dc/elements/1.1/ dc.xsd http://www.w3.org/2001/XMLSchema XMLSchema.xsd urn:stgermainmeta-schema stgermainmeta.xsd">
- <info>
- <dc:title>
- CompositeVC
- </dc:title>
- <dc:creator>
- VPAC
- </dc:creator>
- <dc:publisher>
- VPAC
- </dc:publisher>
- <dc:rights>
- The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
- </dc:rights>
- <dc:source>
- ./StGermain/Base/Automation/src/
- </dc:source>
- <dc:subject>
- StGermain
- </dc:subject>
- <dc:description>
-<![CDATA[
- CompositeVC is used as a container to combine multiple variable conditions.
-]]> </dc:description>
- </info>
- <code>
- <xsd:annotation>
- <xsd:documentation/>
- <xsd:appinfo>
-<![CDATA[
- Refer to ./StgFEM/Apps/StokesMomentumUzawa/lidDrivenBCs.xml
-]]> </xsd:appinfo>
- </xsd:annotation>
- <inherits>
- VariableCondition
- </inherits>
- </code>
- <implements>
- <reference/>
- <equation/>
- </implements>
- <parameters>
- <xsd:element default="self-&gt;name" name="vcName" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
-<![CDATA[
- Deprecated; should not be used.
- ]]> </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element default="" name="vcList" type="stg:list">
- <xsd:annotation>
- <xsd:documentation>
-<![CDATA[
- A list of other VariableCondition definitions.
- ]]> </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </parameters>
- <associations>
- <xsd:element name="Data" nillable="true" type="Stg_Component">
- <xsd:annotation>
- <xsd:documentation>
-<![CDATA[
- User defined data in the form of a Stg_Component.
- ]]> </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </associations>
-</meta>
-</element>
- <element type="struct" name="info">
- <element type="param" name="title">CompositeVC</element>
- <element type="param" name="creator">VPAC</element>
- <element type="param" name="publisher">VPAC</element>
- <element type="param" name="rights">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</element>
- <element type="param" name="source">./StGermain/Base/Automation/src/</element>
- <element type="param" name="subject">StGermain</element>
- <element type="param" name="description">
- CompositeVC is used as a container to combine multiple variable conditions.
-</element>
- </element>
- <element type="struct" name="code">
- <element type="param" name="example-code">
- Refer to ./StgFEM/Apps/StokesMomentumUzawa/lidDrivenBCs.xml
-</element>
- <element type="param" name="inherits">VariableCondition</element>
- </element>
- <element type="struct" name="implements"/>
- <element type="struct" name="parameters">
- <element type="struct" name="vcName">
- <element type="param" name="name">vcName</element>
- <element type="param" name="type">xsd:string</element>
- <element type="param" name="default">self->name</element>
- <element type="param" name="documentation">
- Deprecated; should not be used.
- </element>
- </element>
- <element type="struct" name="vcList">
- <element type="param" name="name">vcList</element>
- <element type="param" name="type">stg:list</element>
- <element type="param" name="default"></element>
- <element type="param" name="documentation">
- A list of other VariableCondition definitions.
- </element>
- </element>
- </element>
- <element type="struct" name="associations">
- <element type="struct" name="Data">
- <element type="param" name="name">Data</element>
- <element type="param" name="type">Stg_Component</element>
- <element type="param" name="nillable">true</element>
- <element type="param" name="documentation">
- User defined data in the form of a Stg_Component.
- </element>
- </element>
- </element>
-</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Automation/tests/input/setVC.xml
--- a/Base/Automation/tests/input/setVC.xml Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
-<!-- A StGermain input file -->
-<!-- DTD to validate against -->
-<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
-
- <struct name="setVC">
- <param name="type">SetVC</param>
- <param name="indexCount">64</param>
- <list name="indices">
- <param>0</param>
- <param>2</param>
- <param>4</param>
- <param>6</param>
- <param>8</param>
- <param>10</param>
- <param>12</param>
- <param>14</param>
- <param>16</param>
- <param>18</param>
- <param>20</param>
- <param>22</param>
- <param>24</param>
- <param>26</param>
- </list>
- <list name="variables">
- <struct>
- <param name="name">vx</param>
- <param name="type">double</param>
- <param name="value" type="double">2</param>
- </struct>
- <struct>
- <param name="name">vy</param>
- <param name="type">func</param>
- <param name="value">quadratic</param>
- </struct>
- <struct>
- <param name="name">vz</param>
- <param name="type">double</param>
- <param name="value" type="double">1</param>
- </struct>
- <struct>
- <param name="name">temp</param>
- <param name="type">array</param>
- <list name="value">
- <param type="double">5</param>
- <param type="double">6</param>
- <param type="double">7</param>
- <param type="double">8</param>
- <param type="double">9</param>
- </list>
- </struct>
- </list>
- </struct>
-
-</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/AbsArray.c
--- a/Base/Container/src/AbsArray.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/AbsArray.c Tue Jan 12 14:38:16 2010 +1100
@@ -153,3 +153,5 @@ const int* AbsArray_GetPtr( const void*
return self->ptr;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/BTree.c
--- a/Base/Container/src/BTree.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/BTree.c Tue Jan 12 14:38:16 2010 +1100
@@ -731,3 +731,5 @@ void BTree_Delete( void* tree ) {
void BTree_Delete( void* tree ) {
Stg_Class_Delete( tree );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/BTree.h
--- a/Base/Container/src/BTree.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/BTree.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation__BTree_h__
-#define __Base_Foundation__BTree_h__
+#ifndef __StGermain_Base_Container_BTree_h__
+#define __StGermain_Base_Container_BTree_h__
#define MAX_DEPTH 100
@@ -159,4 +159,4 @@
/** Added ss alias to Stg_Class_Delete for forward declaraion wrappers */
void BTree_Delete( void* tree );
-#endif /* __Base_Foundation__BTree_h__ */
+#endif /* __StGermain_Base_Container_BTree_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/BTreeIterator.c
--- a/Base/Container/src/BTreeIterator.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/BTreeIterator.c Tue Jan 12 14:38:16 2010 +1100
@@ -176,3 +176,5 @@ void _BTreeIterator_PrintFunc( void *sel
Journal_Printf( myStream, "\tTree (ptr): (%p)\n", iterator->tree );
Journal_Printf( myStream, "\tDepth : %d\n", iterator->depth );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/BTreeIterator.h
--- a/Base/Container/src/BTreeIterator.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/BTreeIterator.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation__BTreeIterator_h__
-#define __Base_Foundation__BTreeIterator_h__
+#ifndef __StGermain_Base_Container_BTreeIterator_h__
+#define __StGermain_Base_Container_BTreeIterator_h__
#define MAX_DEPTH 100
@@ -87,4 +87,4 @@
/* Returns the data stored inside the Tree's next node ( will be used for iterating through the tree ) */
void *BTreeIterator_Next( BTreeIterator *self );
-#endif /* __Base_Foundation__BTreeIterator_h__ */
+#endif /* __StGermain_Base_Container_BTreeIterator_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/BTreeNode.c
--- a/Base/Container/src/BTreeNode.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/BTreeNode.c Tue Jan 12 14:38:16 2010 +1100
@@ -92,3 +92,5 @@ void _BTreeNode_Init( BTreeNode* self ){
self->sizeOfData = 0;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/BTreeNode.h
--- a/Base/Container/src/BTreeNode.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/BTreeNode.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation__BTreeNode_h__
-#define __Base_Foundation__BTreeNode_h__
+#ifndef __StGermain_Base_Container_BTreeNode_h__
+#define __StGermain_Base_Container_BTreeNode_h__
/** Textual name for BTreeNode class. */
extern const Type BTreeNode_Type;
@@ -76,5 +76,5 @@
/** Print interface. */
-#endif /* __Base_Foundation__BTreeNode_h__ */
+#endif /* __StGermain_Base_Container_BTreeNode_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/ChunkArray.c
--- a/Base/Container/src/ChunkArray.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/ChunkArray.c Tue Jan 12 14:38:16 2010 +1100
@@ -502,3 +502,5 @@ char* ChunkArray_ObjectAt(ChunkArray *ch
return (char*)&(chunkArray->chunks[chunkID].memory[arrayIdx]);
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/ChunkArray.h
--- a/Base/Container/src/ChunkArray.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/ChunkArray.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**/
-#ifndef __Base_Foundation__ChunkArray_h__
-#define __Base_Foundation__ChunkArray_h__
+#ifndef __StGermain_Base_Container_ChunkArray_h__
+#define __StGermain_Base_Container_ChunkArray_h__
#define CHUNK_ARRAY_DELTA 10
#define INVALID -1
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Container.h
--- a/Base/Container/src/Container.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Container.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_h__
-#define __Base_Container_h__
+#ifndef __StGermain_Base_Container_h__
+#define __StGermain_Base_Container_h__
#include "units.h"
#include "types.h"
@@ -75,5 +75,5 @@
#include "Init.h"
#include "Finalise.h"
-#endif /* __Base_Container_h__ */
+#endif /* __StGermain_Base_Container_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Finalise.c
--- a/Base/Container/src/Finalise.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Finalise.c Tue Jan 12 14:38:16 2010 +1100
@@ -44,3 +44,5 @@ Bool BaseContainer_Finalise( void ) {
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Finalise.h
--- a/Base/Container/src/Finalise.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Finalise.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,9 +38,9 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_Finalise_h__
-#define __Base_Container_Finalise_h__
+#ifndef __StGermain_Base_Container_Finalise_h__
+#define __StGermain_Base_Container_Finalise_h__
Bool BaseContainer_Finalise( void );
-#endif /* __Base_Container_Finalise_h__ */
+#endif /* __StGermain_Base_Container_Finalise_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/HashTable.c
--- a/Base/Container/src/HashTable.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/HashTable.c Tue Jan 12 14:38:16 2010 +1100
@@ -46,22 +46,11 @@ const Type HashTable_Type = "HashTable";
/*----------------------------------------------------------------------------------------------------------------------------------
** Constructors
*/
-HashTable* _HashTable_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy
- )
+HashTable* _HashTable_New( HASHTABLE_DEFARGS )
{
HashTable *self = NULL;
- self = (HashTable*)_Stg_Class_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy);
+ self = (HashTable*)_Stg_Class_New( STG_CLASS_PASSARGS );
return self;
}
@@ -71,16 +60,18 @@ HashTable* HashTable_New(
HashTable_dataDeleteFunction* dataDeleteFunction,
KeyType keyType)
{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(HashTable);
+ Type type = HashTable_Type;
+ Stg_Class_DeleteFunction* _delete = _HashTable_DeleteFunc;
+ Stg_Class_PrintFunction* _print = _HashTable_PrintFunc;
+ Stg_Class_CopyFunction* _copy = _HashTable_CopyFunc;
+
HashTable* self;
/* General info */
- self = _HashTable_New(
- sizeof(HashTable),
- HashTable_Type,
- _HashTable_DeleteFunc,
- _HashTable_PrintFunc,
- _HashTable_CopyFunc);
+ self = _HashTable_New( HASHTABLE_PASSARGS );
/* List info */
/* At the moment only String keys are supported */
@@ -609,3 +600,5 @@ HashTable_Index* HashTable_First( HashTa
return HashTable_Next( hi );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/HashTable.h
--- a/Base/Container/src/HashTable.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/HashTable.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __HashTable_h__
-#define __HashTable_h__
+#ifndef __StGermain_Base_Container_HashTable_h__
+#define __StGermain_Base_Container_HashTable_h__
/** Textual name for List class. */
extern const Type HashTable_Type;
@@ -111,13 +111,18 @@
HashTable_dataDeleteFunction* dataDeleteFunction,
KeyType keyType);
- HashTable* _HashTable_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy
- );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define HASHTABLE_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define HASHTABLE_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ HashTable* _HashTable_New( HASHTABLE_DEFARGS );
/** Init interface. */
@@ -166,5 +171,6 @@
struct HashTable_Index* HashTable_Next( struct HashTable_Index *hi );
struct HashTable_Index* HashTable_First( struct HashTable *ht );
-#endif /* __HashTable_h__ */
+#endif /* __StGermain_Base_Container_HashTable_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Heap.c
--- a/Base/Container/src/Heap.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Heap.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,30 +51,11 @@
const Type Heap_Type = "Heap";
-_Heap* _Heap_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Heap_HeapifyFunction *heapify,
- Heap_ExtractFunction *extract,
- Heap_InsertFunction *insert,
- Heap_KeySwapFunction* keySwapFunction,
- Heap_CompareFunction *compareFunction,
- Heap_ExtendArrayFunc *extendArray,
- void **keys,
- int keyLength,
- int numArrayElements )
+_Heap* _Heap_New( HEAP_DEFARGS )
{
_Heap *self = NULL;
- self = (_Heap*)_Stg_Class_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy);
+ self = (_Heap*)_Stg_Class_New( STG_CLASS_PASSARGS );
assert( heapify );
assert( extract );
@@ -177,3 +158,5 @@ int _Heap_Right( _Heap *heap, int i )
{
return 2*i+1;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Heap.h
--- a/Base/Container/src/Heap.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Heap.h Tue Jan 12 14:38:16 2010 +1100
@@ -46,8 +46,8 @@
**
**/
-#ifndef __Heap_h__
-#define __Heap_h__
+#ifndef __StGermain_Base_Container_Heap_h__
+#define __StGermain_Base_Container_Heap_h__
/** Textual name for List class. */
extern const Type Heap_Type;
@@ -81,22 +81,36 @@
int numArrayElements;
struct _Heap { __Heap };
- _Heap* _Heap_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Heap_HeapifyFunction *heapify,
- Heap_ExtractFunction *extract,
- Heap_InsertFunction *insert,
- Heap_KeySwapFunction* KeySwapFunction,
- Heap_CompareFunction *compareFunction,
- Heap_ExtendArrayFunc *extendArray,
- void **keys,
- int keyLength,
- int numArrayElements
- );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define HEAP_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ Heap_HeapifyFunction* heapify, \
+ Heap_ExtractFunction* extract, \
+ Heap_InsertFunction* insert, \
+ Heap_KeySwapFunction* keySwapFunction, \
+ Heap_CompareFunction* compareFunction, \
+ Heap_ExtendArrayFunc* extendArray, \
+ void** keys, \
+ int keyLength, \
+ int numArrayElements
+
+ #define HEAP_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ heapify, \
+ extract, \
+ insert, \
+ keySwapFunction, \
+ compareFunction, \
+ extendArray, \
+ keys, \
+ keyLength, \
+ numArrayElements
+
+ _Heap* _Heap_New( HEAP_DEFARGS );
void _Heap_Init( _Heap* self );
@@ -124,5 +138,6 @@
int _Heap_Right( _Heap *heap, int i );
-#endif /* __Heap_h__ */
+#endif /* __StGermain_Base_Container_Heap_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/IArray.c
--- a/Base/Container/src/IArray.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/IArray.c Tue Jan 12 14:38:16 2010 +1100
@@ -218,3 +218,5 @@ void IArray_ZeroAll( IArray* self ) {
self->ptr = NULL;
self->own = True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/IMap.c
--- a/Base/Container/src/IMap.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/IMap.c Tue Jan 12 14:38:16 2010 +1100
@@ -319,3 +319,5 @@ void IMap_First( const void* _self, IMap
}
iter->valid = False;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/IMapIter.c
--- a/Base/Container/src/IMapIter.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/IMapIter.c Tue Jan 12 14:38:16 2010 +1100
@@ -94,3 +94,5 @@ int IMapIter_GetValue( const void* self
assert( ((IMapIter*)self)->valid && ((IMapIter*)self)->cur );
return ((IMapIter*)self)->cur->val;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/ISet.c
--- a/Base/Container/src/ISet.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/ISet.c Tue Jan 12 14:38:16 2010 +1100
@@ -425,3 +425,5 @@ void ISet_First( const void* _self, ISet
}
iter->valid = False;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/ISetIter.c
--- a/Base/Container/src/ISetIter.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/ISetIter.c Tue Jan 12 14:38:16 2010 +1100
@@ -89,3 +89,5 @@ int ISetIter_GetKey( const void* self )
assert( ((ISetIter*)self)->valid && ((ISetIter*)self)->cur );
return ((ISetIter*)self)->cur->key;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/IndexMap.c
--- a/Base/Container/src/IndexMap.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/IndexMap.c Tue Jan 12 14:38:16 2010 +1100
@@ -55,13 +55,14 @@ IndexMap* IndexMap_New_Param(
IndexMap* IndexMap_New_Param(
unsigned delta )
{
- return _IndexMap_New(
- sizeof(IndexMap),
- IndexMap_Type,
- _IndexMap_Delete,
- _IndexMap_Print,
- _IndexMap_Copy,
- delta );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(IndexMap);
+ Type type = IndexMap_Type;
+ Stg_Class_DeleteFunction* _delete = _IndexMap_Delete;
+ Stg_Class_PrintFunction* _print = _IndexMap_Print;
+ Stg_Class_CopyFunction* _copy = _IndexMap_Copy;
+
+ return _IndexMap_New( INDEXMAP_PASSARGS );
}
@@ -85,24 +86,13 @@ void IndexMap_Init(
}
-IndexMap* _IndexMap_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- unsigned delta )
+IndexMap* _IndexMap_New( INDEXMAP_DEFARGS )
{
IndexMap* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(IndexMap) );
- self = (IndexMap*)_Stg_Class_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy );
+ self = (IndexMap*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -280,3 +270,5 @@ void IndexMap_Remap( void* indexMap, voi
** Private Functions
*/
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/IndexMap.h
--- a/Base/Container/src/IndexMap.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/IndexMap.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_IndexMap_h__
-#define __Base_Container_IndexMap_h__
+#ifndef __StGermain_Base_Container_IndexMap_h__
+#define __StGermain_Base_Container_IndexMap_h__
/** Textual name of this class */
@@ -85,13 +85,20 @@
unsigned delta );
/* Creation implementation */
- IndexMap* _IndexMap_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- unsigned delta );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define INDEXMAP_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ unsigned delta
+
+ #define INDEXMAP_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ delta
+
+ IndexMap* _IndexMap_New( INDEXMAP_DEFARGS );
/* Initialise a IndexMap */
@@ -143,4 +150,5 @@
*/
-#endif /* __Base_Container_IndexMap_h__ */
+#endif /* __StGermain_Base_Container_IndexMap_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/IndexSet.c
--- a/Base/Container/src/IndexSet.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/IndexSet.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,7 +51,15 @@ const Type IndexSet_Type = "IndexSet";
((indexSet)->_container[(index) / (sizeof(char) * 8 )] & (1 << ((index) % (sizeof(char) * 8))))
IndexSet* IndexSet_New( IndexSet_Index size ) {
- return _IndexSet_New( sizeof(IndexSet), IndexSet_Type, _IndexSet_Delete, _IndexSet_Print, _IndexSet_Copy, _IndexSet_Duplicate, size );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(IndexSet);
+ Type type = IndexSet_Type;
+ Stg_Class_DeleteFunction* _delete = _IndexSet_Delete;
+ Stg_Class_PrintFunction* _print = _IndexSet_Print;
+ Stg_Class_CopyFunction* _copy = _IndexSet_Copy;
+ IndexSet_DuplicateFunction* _duplicate = _IndexSet_Duplicate;
+
+ return _IndexSet_New( INDEXSET_PASSARGS );
}
void IndexSet_Init( IndexSet* self, IndexSet_Index size ) {
@@ -72,20 +80,13 @@ void IndexSet_Init( IndexSet* self, Inde
}
-IndexSet* _IndexSet_New(
- SizeT sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- IndexSet_DuplicateFunction* _duplicate,
- IndexSet_Index size )
+IndexSet* _IndexSet_New( INDEXSET_DEFARGS )
{
IndexSet* self;
/* Allocate memory */
- assert( sizeOfSelf >= sizeof(IndexSet) );
- self = (IndexSet*)_Stg_Class_New( sizeOfSelf, type, _delete, _print, _copy );
+ assert( _sizeOfSelf >= sizeof(IndexSet) );
+ self = (IndexSet*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -391,3 +392,5 @@ void _IndexSet_Duplicate( void* indexSet
memcpy( ((IndexSet*)newIndexSet)->_container, ((IndexSet*)indexSet)->_container, sizeof(char)*((IndexSet*)indexSet)->_containerSize );
newSet->membersCount = self->membersCount;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/IndexSet.h
--- a/Base/Container/src/IndexSet.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/IndexSet.h Tue Jan 12 14:38:16 2010 +1100
@@ -45,8 +45,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_IndexSet_h__
-#define __Base_Container_IndexSet_h__
+#ifndef __StGermain_Base_Container_IndexSet_h__
+#define __StGermain_Base_Container_IndexSet_h__
/** Virtual function template */
@@ -92,14 +92,22 @@
void IndexSet_Init( IndexSet* self, IndexSet_Index size );
/** IndexSet_New() implementation. */
- IndexSet* _IndexSet_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- IndexSet_DuplicateFunction* _duplicate,
- IndexSet_Index size );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define INDEXSET_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ IndexSet_DuplicateFunction* _duplicate, \
+ IndexSet_Index size
+
+ #define INDEXSET_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ _duplicate, \
+ size
+
+ IndexSet* _IndexSet_New( INDEXSET_DEFARGS );
/** IndexSet_Init() implementation. */
void _IndexSet_Init( IndexSet* self, IndexSet_Index size );
@@ -187,4 +195,5 @@
/** Prints message and exits properly when bad access/write detected. */
void _IndexSet_Abort( IndexSet* indexSet, const char* const funcName, IndexSet_Index index );
-#endif /* __Base_Container_IndexSet_h__ */
+#endif /* __StGermain_Base_Container_IndexSet_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Init.c
--- a/Base/Container/src/Init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Init.c Tue Jan 12 14:38:16 2010 +1100
@@ -43,3 +43,5 @@ Bool BaseContainer_Init( int* argc, char
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Init.h
--- a/Base/Container/src/Init.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Init.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,9 +39,9 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_Init_h__
-#define __Base_Container_Init_h__
+#ifndef __StGermain_Base_Container_Init_h__
+#define __StGermain_Base_Container_Init_h__
Bool BaseContainer_Init( int* argc, char** argv[] );
-#endif /* __Base_Container_Init_h__ */
+#endif /* __StGermain_Base_Container_Init_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Iter.c
--- a/Base/Container/src/Iter.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Iter.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,3 +51,5 @@ Bool Iter_IsValid( void* self ) {
assert( self );
return ((Iter*)self)->valid;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/LinkedList.c
--- a/Base/Container/src/LinkedList.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/LinkedList.c Tue Jan 12 14:38:16 2010 +1100
@@ -45,22 +45,11 @@ const Type LinkedList_Type = "LinkedList
/*----------------------------------------------------------------------------------------------------------------------------------
** Constructors
*/
-LinkedList* _LinkedList_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy
- )
+LinkedList* _LinkedList_New( LINKEDLIST_DEFARGS )
{
LinkedList *self = NULL;
- self = (LinkedList*)_Stg_Class_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy);
+ self = (LinkedList*)_Stg_Class_New( STG_CLASS_PASSARGS );
return self;
}
@@ -71,18 +60,20 @@ LinkedList* LinkedList_New(
LinkedList_dataDeleteFunction* dataDeleteFunction,
Order listOrder )
{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(LinkedList);
+ Type type = LinkedList_Type;
+ Stg_Class_DeleteFunction* _delete = _LinkedList_DeleteFunc;
+ Stg_Class_PrintFunction* _print = _LinkedList_PrintFunc;
+ Stg_Class_CopyFunction* _copy = NULL;
+
LinkedList* self;
/* General info */
assert ( compareFunction );
- self = _LinkedList_New(
- sizeof(LinkedList),
- LinkedList_Type,
- _LinkedList_DeleteFunc,
- _LinkedList_PrintFunc,
- NULL);
+ self = _LinkedList_New( LINKEDLIST_PASSARGS );
/* List info */
self->compareFunction = compareFunction;
@@ -388,3 +379,5 @@ void *LinkedList_ReturnNodeDataAtFunc( L
}
return NULL;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/LinkedList.h
--- a/Base/Container/src/LinkedList.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/LinkedList.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __LinkedList_h__
-#define __LinkedList_h__
+#ifndef __StGermain_Base_Container_LinkedList_h__
+#define __StGermain_Base_Container_LinkedList_h__
/** Textual name for List class. */
extern const Type LinkedList_Type;
@@ -88,13 +88,18 @@
LinkedList_dataDeleteFunction* dataDeleteFunction,
Order listOrder);
- LinkedList* _LinkedList_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy
- );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define LINKEDLIST_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define LINKEDLIST_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ LinkedList* _LinkedList_New( LINKEDLIST_DEFARGS );
/** Init interface. */
@@ -150,5 +155,6 @@
/** Private Functions */
-#endif /* __LinkedList_h__ */
+#endif /* __StGermain_Base_Container_LinkedList_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/LinkedListIterator.c
--- a/Base/Container/src/LinkedListIterator.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/LinkedListIterator.c Tue Jan 12 14:38:16 2010 +1100
@@ -42,41 +42,31 @@
const Type LinkedListIterator_Type = "LinkedListIterator";
-LinkedListIterator *_LinkedListIterator_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy
- )
+LinkedListIterator *_LinkedListIterator_New( LINKEDLISTITERATOR_DEFARGS )
{
LinkedListIterator *self = NULL;
/** LinkedListIterator using Class_New, because Memory module has been initialized */
- self = (LinkedListIterator*)_Stg_Class_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy );
+ self = (LinkedListIterator*)_Stg_Class_New( STG_CLASS_PASSARGS );
return self;
}
LinkedListIterator *LinkedListIterator_New( LinkedList *list )
{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(LinkedListIterator);
+ Type type = LinkedListIterator_Type;
+ Stg_Class_DeleteFunction* _delete = _LinkedListIterator_DeleteFunc;
+ Stg_Class_PrintFunction* _print = _LinkedListIterator_PrintFunc;
+ Stg_Class_CopyFunction* _copy = NULL;
+
LinkedListIterator* self;
assert( list );
- self = _LinkedListIterator_New(
- sizeof(LinkedListIterator),
- LinkedListIterator_Type,
- _LinkedListIterator_DeleteFunc,
- _LinkedListIterator_PrintFunc,
- NULL
- );
+ self = _LinkedListIterator_New( LINKEDLISTITERATOR_PASSARGS );
/* General info */
/* Virtual functions */
@@ -113,3 +103,5 @@ void _LinkedListIterator_PrintFunc( void
Journal_Printf( myStream, "LinkedListIterator (ptr): (%p)\n", iterator );
Journal_Printf( myStream, "\tlist (ptr): (%p)\n", iterator->list );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/LinkedListIterator.h
--- a/Base/Container/src/LinkedListIterator.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/LinkedListIterator.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation__LinkedListIterator_h__
-#define __Base_Foundation__LinkedListIterator_h__
+#ifndef __StGermain_Base_Container_LinkedListIterator_h__
+#define __StGermain_Base_Container_LinkedListIterator_h__
/** Textual name for LinkedListIterator class. */
extern const Type LinkedListIterator_Type;
@@ -58,13 +58,18 @@
/** Constructor interface. */
LinkedListIterator* LinkedListIterator_New( LinkedList *list );
- LinkedListIterator *_LinkedListIterator_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy
- );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define LINKEDLISTITERATOR_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define LINKEDLISTITERATOR_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ LinkedListIterator *_LinkedListIterator_New( LINKEDLISTITERATOR_DEFARGS );
/** Init interface. */
void _LinkedListIterator_Init( LinkedListIterator *self );
@@ -82,4 +87,5 @@
(it==NULL)?NULL:(it->curr == NULL)?NULL:((it->curr = it->curr->next)==NULL)?NULL:it->curr->data
-#endif /* __Base_Foundation__LinkedListIterator_h__ */
+#endif /* __StGermain_Base_Container_LinkedListIterator_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/LinkedListNode.c
--- a/Base/Container/src/LinkedListNode.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/LinkedListNode.c Tue Jan 12 14:38:16 2010 +1100
@@ -71,3 +71,5 @@ void _LinkedListNode_Init( LinkedListNod
self->data = NULL;
self->sizeOfData = 0;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/LinkedListNode.h
--- a/Base/Container/src/LinkedListNode.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/LinkedListNode.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __LinkedListNode_h__
-#define __LinkedListNode_h__
+#ifndef __StGermain_Base_Container_LinkedListNode_h__
+#define __StGermain_Base_Container_LinkedListNode_h__
/** Textual name for ListNode class. */
extern const Type LinkedListNode_Type;
@@ -68,5 +68,5 @@
/** Print interface. */
-#endif /* __LinkedListNode_h__ */
+#endif /* __StGermain_Base_Container_LinkedListNode_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/List.c
--- a/Base/Container/src/List.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/List.c Tue Jan 12 14:38:16 2010 +1100
@@ -50,19 +50,22 @@ const Type List_Type = "List";
*/
List* List_New( Name name ) {
- return _List_New( sizeof(List),
- List_Type,
- _List_Delete,
- _List_Print,
- NULL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(List);
+ Type type = List_Type;
+ Stg_Class_DeleteFunction* _delete = _List_Delete;
+ Stg_Class_PrintFunction* _print = _List_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ return _List_New( LIST_PASSARGS );
}
-List* _List_New( LIST_DEFARGS ) {
+List* _List_New( LIST_DEFARGS ) {
List* self;
/* Allocate memory */
- assert( sizeOfSelf >= sizeof(List) );
- self = (List*)_Stg_Class_New( STG_CLASS_PASSARGS );
+ assert( _sizeOfSelf >= sizeof(List) );
+ self = (List*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* Virtual info */
@@ -260,3 +263,5 @@ void List_Destruct( List* self ) {
self->itemSize = 0;
self->maxItems = 0;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/List.h
--- a/Base/Container/src/List.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/List.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_List_h__
-#define __Base_Contianer_List_h__
+#ifndef __StGermain_Base_Container_List_h__
+#define __StGermain_Base_Contianer_List_h__
/** Textual name of this class */
extern const Type List_Type;
@@ -66,14 +66,21 @@
** Constructors
*/
- #define LIST_DEFARGS \
- STG_CLASS_DEFARGS
- #define LIST_PASSARGS \
- STG_CLASS_PASSARGS
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define LIST_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define LIST_PASSARGS \
+ STG_CLASS_PASSARGS
List* List_New();
- List* _List_New( LIST_DEFARGS );
+ List* _List_New( LIST_DEFARGS );
void _List_Init( List* self );
/*--------------------------------------------------------------------------------------------------------------------------
@@ -111,4 +118,5 @@
void List_Contract( List* self );
void List_Destruct( List* self );
-#endif /* __Base_Container_List_h__ */
+#endif /* __StGermain_Base_Container_List_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/MPIRoutines.c
--- a/Base/Container/src/MPIRoutines.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/MPIRoutines.c Tue Jan 12 14:38:16 2010 +1100
@@ -350,3 +350,5 @@ void Array_2DTo1D( unsigned nBlocks, uns
*disps = tmpDisps;
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/MPIRoutines.h
--- a/Base/Container/src/MPIRoutines.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/MPIRoutines.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation_MPIRoutines_h__
-#define __Base_Foundation_MPIRoutines_h__
+#ifndef __StGermain_Base_Container_MPIRoutines_h__
+#define __StGermain_Base_Container_MPIRoutines_h__
void MPIArray_Bcast( unsigned* arraySize, void** array, size_t itemSize,
unsigned root, MPI_Comm comm );
@@ -62,4 +62,4 @@ void Array_2DTo1D( unsigned nBlocks, uns
void Array_2DTo1D( unsigned nBlocks, unsigned* sizes, void** srcArrays,
void** dstArray, size_t itemSize, unsigned** disps );
-#endif /* __Base_Foundation_MPIRoutines_h__ */
+#endif /* __StGermain_Base_Container_MPIRoutines_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/MaxHeap.c
--- a/Base/Container/src/MaxHeap.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/MaxHeap.c Tue Jan 12 14:38:16 2010 +1100
@@ -57,54 +57,26 @@ MaxHeap* MaxHeap_New( void **keys, int k
Heap_CompareFunction *keyCompare,
Heap_ExtendArrayFunc *extendArray )
{
- return _MaxHeap_New( sizeof( MaxHeap ),
- MaxHeap_Type,
- _MaxHeap_DeleteFunc,
- _MaxHeap_PrintFunc,
- NULL,
- MaxHeap_Heapify,
- (Heap_ExtractFunction*)MaxHeap_Extract,
- MaxHeap_InsertFunc,
- keySwap,
- keyCompare,
- extendArray,
- keys,
- keyLength,
- numArrayElements );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( MaxHeap );
+ Type type = MaxHeap_Type;
+ Stg_Class_DeleteFunction* _delete = _MaxHeap_DeleteFunc;
+ Stg_Class_PrintFunction* _print = _MaxHeap_PrintFunc;
+ Stg_Class_CopyFunction* _copy = NULL;
+ Heap_HeapifyFunction* heapify = MaxHeap_Heapify;
+ Heap_ExtractFunction* extract = (Heap_ExtractFunction*)MaxHeap_Extract;
+ Heap_InsertFunction* insert = MaxHeap_InsertFunc;
+ Heap_KeySwapFunction* keySwapFunction = keySwap;
+ Heap_CompareFunction* compareFunction = keyCompare;
+
+ return _MaxHeap_New( MAXHEAP_PASSARGS );
}
-MaxHeap* _MaxHeap_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Heap_HeapifyFunction *heapify,
- Heap_ExtractFunction *extract,
- Heap_InsertFunction *insert,
- Heap_KeySwapFunction* keySwapFunction,
- Heap_CompareFunction *compareFunction,
- Heap_ExtendArrayFunc *extendArray,
- void **keys,
- int keyLength,
- int numArrayElements )
+MaxHeap* _MaxHeap_New( MAXHEAP_DEFARGS )
{
_Heap *heap;
- heap = _Heap_New( _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- heapify,
- extract,
- insert,
- keySwapFunction,
- compareFunction,
- extendArray,
- keys,
- keyLength,
- numArrayElements );
+ heap = _Heap_New( HEAP_PASSARGS );
_MaxHeap_Init( (MaxHeap*)heap );
return ( MaxHeap* )heap;
@@ -222,3 +194,5 @@ void MaxHeap_InsertFunc( _Heap *maxHeap,
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/MaxHeap.h
--- a/Base/Container/src/MaxHeap.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/MaxHeap.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __MaxHeap_h__
-#define __MaxHeap_h__
+#ifndef __StGermain_Base_Container_MaxHeap_h__
+#define __StGermain_Base_Container_MaxHeap_h__
/** Textual name for List class. */
extern const Type MaxHeap_Type;
@@ -55,22 +55,18 @@
Heap_CompareFunction *keyCompare,
Heap_ExtendArrayFunc *extendArray );
- MaxHeap* _MaxHeap_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Heap_HeapifyFunction *heapify,
- Heap_ExtractFunction *extract,
- Heap_InsertFunction *insert,
- Heap_KeySwapFunction* keySwapFunction,
- Heap_CompareFunction *compareFunction,
- Heap_ExtendArrayFunc *extendArray,
- void **keys,
- int keyLength,
- int numArrayElements
- );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define MAXHEAP_DEFARGS \
+ HEAP_DEFARGS
+
+ #define MAXHEAP_PASSARGS \
+ HEAP_PASSARGS
+
+ MaxHeap* _MaxHeap_New( MAXHEAP_DEFARGS );
void _MaxHeap_Init( MaxHeap* self );
@@ -96,5 +92,6 @@
/** Private Functions */
-#endif /* __MaxHeap_h__ */
+#endif /* __StGermain_Base_Container_MaxHeap_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/MemoryPool.c
--- a/Base/Container/src/MemoryPool.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/MemoryPool.c Tue Jan 12 14:38:16 2010 +1100
@@ -44,25 +44,11 @@ const Type MemoryPool_Type = "MemoryPool
/*----------------------------------------------------------------------------------------------------------------------------------
** Constructors
*/
-MemoryPool* _MemoryPool_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- int elementSize,
- int numElements,
- int delta
- )
+MemoryPool* _MemoryPool_New( MEMORYPOOL_DEFARGS )
{
MemoryPool *self = NULL;
- self = (MemoryPool*)_Stg_Class_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy);
+ self = (MemoryPool*)_Stg_Class_New( STG_CLASS_PASSARGS );
self->numMemChunks = 1;
self->delta = delta;
@@ -78,19 +64,17 @@ MemoryPool* _MemoryPool_New(
MemoryPool* MemoryPool_NewFunc( SizeT elementSize, int numElements, int delta )
{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(MemoryPool);
+ Type type = MemoryPool_Type;
+ Stg_Class_DeleteFunction* _delete = _MemoryPool_DeleteFunc;
+ Stg_Class_PrintFunction* _print = _MemoryPool_PrintFunc;
+ Stg_Class_CopyFunction* _copy = NULL;
+
MemoryPool* self;
- self = _MemoryPool_New(
- sizeof(MemoryPool),
- MemoryPool_Type,
- _MemoryPool_DeleteFunc,
- _MemoryPool_PrintFunc,
- NULL,
- elementSize,
- numElements,
- delta
- );
+ self = _MemoryPool_New( MEMORYPOOL_PASSARGS );
/* Virtual functions */
_MemoryPool_Init( self );
@@ -359,3 +343,5 @@ void MemoryPool_SetCallbackFuncArg( Memo
memPool->callbackFuncArg = callbackFuncArg;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/MemoryPool.h
--- a/Base/Container/src/MemoryPool.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/MemoryPool.h Tue Jan 12 14:38:16 2010 +1100
@@ -41,8 +41,8 @@
**
**/
-#ifndef __MemoryPool_h__
-#define __MemoryPool_h__
+#ifndef __StGermain_Base_Container_MemoryPool_h__
+#define __StGermain_Base_Container_MemoryPool_h__
/** Textual name for List class. */
extern const Type MemoryPool_Type;
@@ -83,16 +83,24 @@
MemoryPool* MemoryPool_NewFunc( SizeT elementSize, int numElements, int delta );
- MemoryPool* _MemoryPool_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- int elementSize,
- int numElements,
- int delta
- );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define MEMORYPOOL_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ int elementSize, \
+ int numElements, \
+ int delta
+
+ #define MEMORYPOOL_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ elementSize, \
+ numElements, \
+ delta
+
+ MemoryPool* _MemoryPool_New( MEMORYPOOL_DEFARGS );
/** Init interface. */
@@ -125,5 +133,6 @@
/** Private Functions */
-#endif /* __MemoryPool_h__ */
+#endif /* __StGermain_Base_Container_MemoryPool_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/PtrMap.c
--- a/Base/Container/src/PtrMap.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/PtrMap.c Tue Jan 12 14:38:16 2010 +1100
@@ -54,13 +54,14 @@ PtrMap* PtrMap_New(
PtrMap* PtrMap_New(
unsigned delta )
{
- return _PtrMap_New(
- sizeof(PtrMap),
- PtrMap_Type,
- _PtrMap_Delete,
- _PtrMap_Print,
- NULL,
- delta );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(PtrMap);
+ Type type = PtrMap_Type;
+ Stg_Class_DeleteFunction* _delete = _PtrMap_Delete;
+ Stg_Class_PrintFunction* _print = _PtrMap_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ return _PtrMap_New( PTRMAP_PASSARGS );
}
@@ -84,24 +85,13 @@ void PtrMap_Init(
}
-PtrMap* _PtrMap_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- unsigned delta )
+PtrMap* _PtrMap_New( PTRMAP_DEFARGS )
{
PtrMap* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(PtrMap) );
- self = (PtrMap*)_Stg_Class_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy );
+ self = (PtrMap*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -227,3 +217,5 @@ void* PtrMap_Find( void* ptrMap, void* k
/*----------------------------------------------------------------------------------------------------------------------------------
** Private Functions
*/
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/PtrMap.h
--- a/Base/Container/src/PtrMap.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/PtrMap.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_PtrMap_h__
-#define __Base_Container_PtrMap_h__
+#ifndef __StGermain_Base_Container_PtrMap_h__
+#define __StGermain_Base_Container_PtrMap_h__
/** Textual name of this class */
@@ -79,13 +79,20 @@
unsigned delta );
/* Creation implementation */
- PtrMap* _PtrMap_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- unsigned delta );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define PTRMAP_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ unsigned delta
+
+ #define PTRMAP_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ delta
+
+ PtrMap* _PtrMap_New( PTRMAP_DEFARGS );
/* Initialise a PtrMap */
@@ -124,4 +131,5 @@
*/
-#endif /* __Base_Container_PtrMap_h__ */
+#endif /* __StGermain_Base_Container_PtrMap_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/PtrSet.c
--- a/Base/Container/src/PtrSet.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/PtrSet.c Tue Jan 12 14:38:16 2010 +1100
@@ -54,20 +54,21 @@ PtrSet* PtrSet_New(
PtrSet* PtrSet_New(
Dictionary* dictionary )
{
- return _PtrSet_New(
- sizeof(PtrSet),
- PtrSet_Type,
- _PtrSet_Delete,
- _PtrSet_Print,
- NULL,
- _PtrSet_Union,
- _PtrSet_Intersection,
- _PtrSet_Subtraction,
- dictionary,
- 0,
- _PtrSet_CompareData,
- NULL,
- _PtrSet_DeleteData );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(PtrSet);
+ Type type = PtrSet_Type;
+ Stg_Class_DeleteFunction* _delete = _PtrSet_Delete;
+ Stg_Class_PrintFunction* _print = _PtrSet_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ Set_UnionFunc* _unionFunc = _PtrSet_Union;
+ Set_IntersectionFunc* _intersectionFunc = _PtrSet_Intersection;
+ Set_SubtractionFunc* _subtractionFunc = _PtrSet_Subtraction;
+ SizeT elementSize = 0;
+ BTree_compareFunction* compareFunc = _PtrSet_CompareData;
+ BTree_dataCopyFunction* dataCopyFunc = NULL;
+ BTree_dataDeleteFunction* dataDeleteFunc = _PtrSet_DeleteData;
+
+ return _PtrSet_New( PTRSET_PASSARGS );
}
@@ -95,39 +96,13 @@ void PtrSet_Init(
}
-PtrSet* _PtrSet_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Set_UnionFunc* _unionFunc,
- Set_IntersectionFunc* _intersectionFunc,
- Set_SubtractionFunc* _subtractionFunc,
- Dictionary* dictionary,
- SizeT elementSize,
- BTree_compareFunction* compareFunc,
- BTree_dataCopyFunction* dataCopyFunc,
- BTree_dataDeleteFunction* dataDeleteFunc )
+PtrSet* _PtrSet_New( PTRSET_DEFARGS )
{
PtrSet* self;
/* allocate memory */
assert( _sizeOfSelf >= sizeof(PtrSet) );
- self = (PtrSet*)_Set_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _unionFunc,
- _intersectionFunc,
- _subtractionFunc,
- dictionary,
- elementSize,
- compareFunc,
- dataCopyFunc,
- dataDeleteFunc );
+ self = (PtrSet*)_Set_New( SET_PASSARGS );
/* general info */
@@ -244,3 +219,5 @@ int _PtrSet_CompareData( void* left, voi
void _PtrSet_DeleteData( void* data ) {
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/PtrSet.h
--- a/Base/Container/src/PtrSet.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/PtrSet.h Tue Jan 12 14:38:16 2010 +1100
@@ -37,8 +37,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_PtrSet_h__
-#define __Base_Container_PtrSet_h__
+#ifndef __StGermain_Base_Container_PtrSet_h__
+#define __StGermain_Base_Container_PtrSet_h__
/* Textual name of this class */
@@ -69,20 +69,18 @@
Dictionary* dictionary );
/* Creation implementation */
- PtrSet* _PtrSet_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Set_UnionFunc* _unionFunc,
- Set_IntersectionFunc* _intersectionFunc,
- Set_SubtractionFunc* _subtractionFunc,
- Dictionary* dictionary,
- SizeT elementSize,
- BTree_compareFunction* compareFunc,
- BTree_dataCopyFunction* dataCopyFunc,
- BTree_dataDeleteFunction* dataDeleteFunc );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define PTRSET_DEFARGS \
+ SET_DEFARGS
+
+ #define PTRSET_PASSARGS \
+ SET_PASSARGS
+
+ PtrSet* _PtrSet_New( PTRSET_DEFARGS );
/* Initialise an instance */
@@ -128,4 +126,5 @@
void _PtrSet_DeleteData( void* data );
-#endif /* __Base_Container_PtrSet_h__ */
+#endif /* __StGermain_Base_Container_PtrSet_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/RangeSet.c
--- a/Base/Container/src/RangeSet.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/RangeSet.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,19 +51,22 @@ const Type RangeSet_Type = "RangeSet";
*/
RangeSet* RangeSet_New() {
- return _RangeSet_New( sizeof(RangeSet),
- RangeSet_Type,
- _RangeSet_Delete,
- _RangeSet_Print,
- _RangeSet_Copy );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(RangeSet);
+ Type type = RangeSet_Type;
+ Stg_Class_DeleteFunction* _delete = _RangeSet_Delete;
+ Stg_Class_PrintFunction* _print = _RangeSet_Print;
+ Stg_Class_CopyFunction* _copy = _RangeSet_Copy;
+
+ return _RangeSet_New( RANGESET_PASSARGS );
}
-RangeSet* _RangeSet_New( RANGESET_DEFARGS ) {
+RangeSet* _RangeSet_New( RANGESET_DEFARGS ) {
RangeSet* self;
/* Allocate memory */
- assert( sizeOfSelf >= sizeof(RangeSet) );
- self = (RangeSet*)_Stg_Class_New( STG_CLASS_PASSARGS );
+ assert( _sizeOfSelf >= sizeof(RangeSet) );
+ self = (RangeSet*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* Virtual info */
@@ -609,3 +612,5 @@ void RangeSet_Destruct( RangeSet* self )
self->btree = BTree_New( RangeSet_DataCompare, RangeSet_DataCopy, RangeSet_DataDelete, NULL,
BTREE_NO_DUPLICATES );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/RangeSet.h
--- a/Base/Container/src/RangeSet.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/RangeSet.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_RangeSet_h__
-#define __Base_Container_RangeSet_h__
+#ifndef __StGermain_Base_Container_RangeSet_h__
+#define __StGermain_Base_Container_RangeSet_h__
/** Textual name of this class */
extern const Type RangeSet_Type;
@@ -63,14 +63,21 @@
** Constructors
*/
+
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
#define RANGESET_DEFARGS \
- STG_CLASS_DEFARGS
+ STG_CLASS_DEFARGS
#define RANGESET_PASSARGS \
- STG_CLASS_PASSARGS
+ STG_CLASS_PASSARGS
RangeSet* RangeSet_New();
- RangeSet* _RangeSet_New( RANGESET_DEFARGS );
+ RangeSet* _RangeSet_New( RANGESET_DEFARGS );
void _RangeSet_Init( RangeSet* self );
/*--------------------------------------------------------------------------------------------------------------------------
@@ -132,4 +139,5 @@
void RangeSet_Destruct( RangeSet* self );
-#endif /* __Base_Container_RangeSet_h__ */
+#endif /* __StGermain_Base_Container_RangeSet_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/STree.c
--- a/Base/Container/src/STree.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/STree.c Tue Jan 12 14:38:16 2010 +1100
@@ -361,3 +361,5 @@ int STree_IntCmp( const void* left, cons
void STree_IntDel( void* itm ) {
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/STreeMap.c
--- a/Base/Container/src/STreeMap.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/STreeMap.c Tue Jan 12 14:38:16 2010 +1100
@@ -104,3 +104,5 @@ Bool STreeMap_HasKey( const void* _self,
return STree_Has( self, key );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Set.c
--- a/Base/Container/src/Set.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Set.c Tue Jan 12 14:38:16 2010 +1100
@@ -57,20 +57,17 @@ Set* Set_New_all(
BTree_dataCopyFunction* dataCopyFunc,
BTree_dataDeleteFunction* dataDeleteFunc )
{
- return _Set_New(
- sizeof(Set),
- Set_Type,
- _Set_Delete,
- _Set_Print,
- NULL,
- _Set_Union,
- _Set_Intersection,
- _Set_Subtraction,
- dictionary,
- elementSize,
- compareFunc,
- dataCopyFunc,
- dataDeleteFunc );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Set);
+ Type type = Set_Type;
+ Stg_Class_DeleteFunction* _delete = _Set_Delete;
+ Stg_Class_PrintFunction* _print = _Set_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ Set_UnionFunc* _unionFunc = _Set_Union;
+ Set_IntersectionFunc* _intersectionFunc = _Set_Intersection;
+ Set_SubtractionFunc* _subtractionFunc = _Set_Subtraction;
+
+ return _Set_New( SET_PASSARGS );
}
@@ -102,31 +99,13 @@ void Set_Init(
}
-Set* _Set_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Set_UnionFunc* _unionFunc,
- Set_IntersectionFunc* _intersectionFunc,
- Set_SubtractionFunc* _subtractionFunc,
- Dictionary* dictionary,
- SizeT elementSize,
- BTree_compareFunction* compareFunc,
- BTree_dataCopyFunction* dataCopyFunc,
- BTree_dataDeleteFunction* dataDeleteFunc )
+Set* _Set_New( SET_DEFARGS )
{
Set* self;
/* allocate memory */
assert( _sizeOfSelf >= sizeof(Set) );
- self = (Set*)_Stg_Class_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy );
+ self = (Set*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* general info */
self->dictionary = dictionary;
@@ -297,3 +276,5 @@ void _Set_BTreeSubtraction( void* data,
Set_Insert( ((Set**)pack)[1], data );
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/Set.h
--- a/Base/Container/src/Set.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/Set.h Tue Jan 12 14:38:16 2010 +1100
@@ -37,8 +37,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_Set_h__
-#define __Base_Container_Set_h__
+#ifndef __StGermain_Base_Container_Set_h__
+#define __StGermain_Base_Container_Set_h__
/* Textual name of this class */
@@ -86,20 +86,34 @@
BTree_dataDeleteFunction* dataDeleteFunc );
/* Creation implementation */
- Set* _Set_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Set_UnionFunc* _unionFunc,
- Set_IntersectionFunc* _intersectionFunc,
- Set_SubtractionFunc* _subtractionFunc,
- Dictionary* dictionary,
- SizeT elementSize,
- BTree_compareFunction* compareFunc,
- BTree_dataCopyFunction* dataCopyFunc,
- BTree_dataDeleteFunction* dataDeleteFunc );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define SET_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ Set_UnionFunc* _unionFunc, \
+ Set_IntersectionFunc* _intersectionFunc, \
+ Set_SubtractionFunc* _subtractionFunc, \
+ Dictionary* dictionary, \
+ SizeT elementSize, \
+ BTree_compareFunction* compareFunc, \
+ BTree_dataCopyFunction* dataCopyFunc, \
+ BTree_dataDeleteFunction* dataDeleteFunc
+
+ #define SET_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ _unionFunc, \
+ _intersectionFunc, \
+ _subtractionFunc, \
+ dictionary, \
+ elementSize, \
+ compareFunc, \
+ dataCopyFunc, \
+ dataDeleteFunc
+
+ Set* _Set_New( SET_DEFARGS );
/* Initialise an instance */
@@ -171,4 +185,5 @@
void _Set_BTreeSubtraction( void* data, void* pack );
-#endif /* __Base_Container_Set_h__ */
+#endif /* __StGermain_Base_Container_Set_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/UIntMap.c
--- a/Base/Container/src/UIntMap.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/UIntMap.c Tue Jan 12 14:38:16 2010 +1100
@@ -58,19 +58,22 @@ const Type UIntMap_Type = "UIntMap";
*/
UIntMap* UIntMap_New() {
- return _UIntMap_New( sizeof(UIntMap),
- UIntMap_Type,
- _UIntMap_Delete,
- _UIntMap_Print,
- _UIntMap_Copy );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(UIntMap);
+ Type type = UIntMap_Type;
+ Stg_Class_DeleteFunction* _delete = _UIntMap_Delete;
+ Stg_Class_PrintFunction* _print = _UIntMap_Print;
+ Stg_Class_CopyFunction* _copy = _UIntMap_Copy;
+
+ return _UIntMap_New( UINTMAP_PASSARGS );
}
-UIntMap* _UIntMap_New( UINTMAP_DEFARGS ) {
+UIntMap* _UIntMap_New( UINTMAP_DEFARGS ) {
UIntMap* self;
/* Allocate memory */
- assert( sizeOfSelf >= sizeof(UIntMap) );
- self = (UIntMap*)_Stg_Class_New( STG_CLASS_PASSARGS );
+ assert( _sizeOfSelf >= sizeof(UIntMap) );
+ self = (UIntMap*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* Virtual info */
@@ -260,3 +263,5 @@ void UIntMap_ParseNode( void* data, void
parseStruct->keys[parseStruct->curItem] = ((unsigned*)data)[0];
parseStruct->vals[parseStruct->curItem++] = ((unsigned*)data)[1];
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/UIntMap.h
--- a/Base/Container/src/UIntMap.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/UIntMap.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_UIntMap_h__
-#define __Base_Container_UIntMap_h__
+#ifndef __StGermain_Base_Container_UIntMap_h__
+#define __StGermain_Base_Container_UIntMap_h__
/** Textual name of this class */
extern const Type UIntMap_Type;
@@ -63,14 +63,21 @@
** Constructors
*/
- #define UINTMAP_DEFARGS \
- STG_CLASS_DEFARGS
- #define UINTMAP_PASSARGS \
- STG_CLASS_PASSARGS
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define UINTMAP_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define UINTMAP_PASSARGS \
+ STG_CLASS_PASSARGS
UIntMap* UIntMap_New();
- UIntMap* _UIntMap_New( UINTMAP_DEFARGS );
+ UIntMap* _UIntMap_New( UINTMAP_DEFARGS );
void _UIntMap_Init( UIntMap* self );
/*--------------------------------------------------------------------------------------------------------------------------
@@ -106,4 +113,5 @@
void UIntMap_DataDelete( void* data );
void UIntMap_ParseNode( void* data, void* _parseStruct );
-#endif /* __Base_Container_UIntMap_h__ */
+#endif /* __StGermain_Base_Container_UIntMap_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/types.h
--- a/Base/Container/src/types.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/types.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_types_h__
-#define __Base_Container_types_h__
+#ifndef __StGermain_Base_Container_types_h__
+#define __StGermain_Base_Container_types_h__
typedef struct Iter Iter;
typedef struct AbsArray AbsArray;
@@ -154,5 +154,5 @@ struct IMapItem {
} RangeSet_ParseStruct;
-#endif /* __Base_Container_types_h__ */
+#endif /* __StGermain_Base_Container_types_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/src/units.h
--- a/Base/Container/src/units.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/src/units.h Tue Jan 12 14:38:16 2010 +1100
@@ -36,7 +36,7 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Container_units_h__
-#define __Base_Container_units_h__
+#ifndef __StGermain_Base_Container_units_h__
+#define __StGermain_Base_Container_units_h__
-#endif /* __Base_Container_units_h__ */
+#endif /* __StGermain_Base_Container_units_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/BTreeSuite.c
--- a/Base/Container/tests/BTreeSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/BTreeSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -291,3 +291,5 @@ void BTreeSuite( pcu_suite_t* suite ) {
pcu_suite_addTest( suite, BTreeSuite_TestComplexityPerformance );
pcu_suite_addTest( suite, BTreeSuite_TestParseTreeForAverage );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/HashTableSuite.c
--- a/Base/Container/tests/HashTableSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/HashTableSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -268,3 +268,5 @@ void HashTableSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, HashTableSuite_TestInsertPointers );
pcu_suite_addTest( suite, HashTableSuite_TestSearchPointers );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/IArraySuite.c
--- a/Base/Container/tests/IArraySuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/IArraySuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -114,3 +114,5 @@ void IArraySuite( pcu_suite_t* suite ) {
pcu_suite_addTest( suite, IArraySuite_TestAdd );
pcu_suite_addTest( suite, IArraySuite_TestRemove );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/IMapSuite.c
--- a/Base/Container/tests/IMapSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/IMapSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -139,3 +139,5 @@ void IMapSuite( pcu_suite_t* suite ) {
pcu_suite_addTest( suite, IMapSuite_TestMap );
pcu_suite_addTest( suite, IMapSuite_TestRemove );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/ISetSuite.c
--- a/Base/Container/tests/ISetSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/ISetSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -160,3 +160,5 @@ void ISetSuite( pcu_suite_t* suite ) {
pcu_suite_addTest( suite, ISetSuite_TestIsect );
pcu_suite_addTest( suite, ISetSuite_TestSubtr );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/IndexMapSuite.c
--- a/Base/Container/tests/IndexMapSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/IndexMapSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -73,3 +73,5 @@ void IndexMapSuite( pcu_suite_t* suite )
pcu_suite_setFixtures( suite, IndexMapSuite_Setup, IndexMapSuite_Teardown );
pcu_suite_addTest( suite, IndexMapSuite_TestAppendFind );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/IndexSetSuite.c
--- a/Base/Container/tests/IndexSetSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/IndexSetSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -422,3 +422,5 @@ void IndexSetSuite( pcu_suite_t* suite )
pcu_suite_addTest( suite, IndexSetSuite_TestBadAssign );
#endif
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/LinkedListIteratorSuite.c
--- a/Base/Container/tests/LinkedListIteratorSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/LinkedListIteratorSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -112,3 +112,5 @@ void LinkedListIteratorSuite( pcu_suite_
pcu_suite_setFixtures( suite, LinkedListIteratorSuite_Setup, LinkedListIteratorSuite_Teardown );
pcu_suite_addTest( suite, LinkedListIteratorSuite_TestRetreive );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/LinkedListSuite.c
--- a/Base/Container/tests/LinkedListSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/LinkedListSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -117,7 +117,6 @@ void LinkedListSuite_Teardown( LinkedLis
void LinkedListSuite_TestInsert( LinkedListSuiteData* data ) {
- LinkedList* numList = NULL;
Index ii = 0;
LinkedListNode* currNode=NULL;
@@ -212,3 +211,5 @@ void LinkedListSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, LinkedListSuite_TestReturnArray );
pcu_suite_addTest( suite, LinkedListSuite_TestFindNodeData );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/ListSuite.c
--- a/Base/Container/tests/ListSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/ListSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -177,3 +177,5 @@ void ListSuite( pcu_suite_t* suite ) {
pcu_suite_addTest( suite, ListSuite_TestRemove );
pcu_suite_addTest( suite, ListSuite_TestExists );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/MPIRoutinesSuite.c
--- a/Base/Container/tests/MPIRoutinesSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/MPIRoutinesSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
#include "MPIRoutinesSuite.h"
typedef struct {
- unsigned rank;
- unsigned nProcs;
+ int rank;
+ int nProcs;
} MPIRoutinesSuiteData;
void MPIRoutinesSuite_Setup( MPIRoutinesSuiteData* data ) {
@@ -299,3 +299,5 @@ void MPIRoutinesSuite( pcu_suite_t* suit
pcu_suite_addTest( suite, MPIRoutinesSuite_TestAlltoall_1D );
pcu_suite_addTest( suite, MPIRoutinesSuite_TestAlltoall_2D );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/MaxHeapSuite.c
--- a/Base/Container/tests/MaxHeapSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/MaxHeapSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -172,3 +172,5 @@ void MaxHeapSuite( pcu_suite_t* suite )
pcu_suite_addTest( suite, MaxHeapSuite_TestCreationExtraction );
pcu_suite_addTest( suite, MaxHeapSuite_TestInsertionExtraction );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/MemoryPoolSuite.c
--- a/Base/Container/tests/MemoryPoolSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/MemoryPoolSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -191,3 +191,5 @@ void MemoryPoolSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, MemoryPoolSuite_TestDeallocation );
pcu_suite_addTest( suite, MemoryPoolSuite_TestIllegalDeallocation );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/PtrMapSuite.c
--- a/Base/Container/tests/PtrMapSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/PtrMapSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -72,3 +72,5 @@ void PtrMapSuite( pcu_suite_t* suite ) {
pcu_suite_setFixtures( suite, PtrMapSuite_Setup, PtrMapSuite_Teardown );
pcu_suite_addTest( suite, PtrMapSuite_TestAppendFind );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/PtrSetSuite.c
--- a/Base/Container/tests/PtrSetSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/PtrSetSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -83,7 +83,6 @@ static void markArray( void* setItem, vo
void PtrSetSuite_TestInsertTraverse( PtrSetSuiteData* data ) {
unsigned ptr_I;
- unsigned* ptr;
for( ptr_I = 0; ptr_I < NUM_ITEMS; ptr_I++ ) {
Set_Insert( data->setA, &data->dataArray[ptr_I] );
@@ -203,3 +202,5 @@ void PtrSetSuite( pcu_suite_t* suite ) {
pcu_suite_addTest( suite, PtrSetSuite_TestSubtraction );
pcu_suite_addTest( suite, PtrSetSuite_TestPerformance );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/RangeSetSuite.c
--- a/Base/Container/tests/RangeSetSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/RangeSetSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -62,7 +62,6 @@ void RangeSetSuite_Teardown( RangeSetSui
void RangeSetSuite_TestIndices( RangeSetSuiteData* data ) {
- Bool result = True;
unsigned nInds = NUM_ITEMS;
unsigned inds[NUM_ITEMS];
unsigned nDstInds, *dstInds;
@@ -90,7 +89,6 @@ void RangeSetSuite_TestIndices( RangeSet
void RangeSetSuite_TestRanges( RangeSetSuiteData* data ) {
- Bool result = True;
unsigned nInds = NUM_ITEMS;
unsigned inds[NUM_ITEMS];
unsigned nDstInds, *dstInds;
@@ -264,3 +262,5 @@ void RangeSetSuite( pcu_suite_t* suite )
pcu_suite_addTest( suite, RangeSetSuite_TestSubtraction );
pcu_suite_addTest( suite, RangeSetSuite_TestPickle );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/STreeMapSuite.c
--- a/Base/Container/tests/STreeMapSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/STreeMapSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -93,3 +93,5 @@ void STreeMapSuite( pcu_suite_t* suite )
pcu_suite_addTest( suite, STreeMapSuite_TestInsert );
pcu_suite_addTest( suite, STreeMapSuite_TestMap );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/STreeSuite.c
--- a/Base/Container/tests/STreeSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/STreeSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -120,3 +120,5 @@ void STreeSuite( pcu_suite_t* suite ) {
pcu_suite_addTest( suite, STreeSuite_TestRemove );
pcu_suite_addTest( suite, STreeSuite_TestHas );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/SetSuite.c
--- a/Base/Container/tests/SetSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/SetSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -228,3 +228,5 @@ void SetSuite( pcu_suite_t* suite ) {
pcu_suite_addTest( suite, SetSuite_TestSubtraction );
pcu_suite_addTest( suite, SetSuite_TestPerformance );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Container/tests/UIntMapSuite.c
--- a/Base/Container/tests/UIntMapSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Container/tests/UIntMapSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -109,3 +109,5 @@ void UIntMapSuite( pcu_suite_t* suite )
pcu_suite_addTest( suite, UIntMapSuite_TestMap );
pcu_suite_addTest( suite, UIntMapSuite_TestMemoryMap );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/AbstractContext.c
--- a/Base/Context/src/AbstractContext.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/AbstractContext.c Tue Jan 12 14:38:16 2010 +1100
@@ -39,6 +39,8 @@
#include "units.h"
#include "types.h"
#include "shortcuts.h"
+#include "Variable.h"
+#include "Variable_Register.h"
#include "AbstractContext.h"
#include "ContextEntryPoint.h"
#include "DictionaryCheck.h"
@@ -50,99 +52,66 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
+#include <unistd.h>
#if defined(READ_HDF5) || defined(WRITE_HDF5)
#include <hdf5.h>
#endif
/* AbstractContext entry point names */
-Type AbstractContext_EP_Construct = "Context_Construct";
-Type AbstractContext_EP_ConstructExtensions = "Context_ConstructExtensions";
-Type AbstractContext_EP_Build = "Context_Build";
-Type AbstractContext_EP_Initialise = "Context_Initialise";
-Type AbstractContext_EP_Execute = "Context_Execute";
-Type AbstractContext_EP_Destroy = "Context_Destroy";
-Type AbstractContext_EP_DestroyExtensions = "Context_DestroyExtensions";
+Type AbstractContext_EP_AssignFromXML = "Context_Construct";
+Type AbstractContext_EP_AssignFromXMLExtensions = "Context_ConstructExtensions";
+Type AbstractContext_EP_Build = "Context_Build";
+Type AbstractContext_EP_Initialise = "Context_Initialise";
+Type AbstractContext_EP_Execute = "Context_Execute";
+Type AbstractContext_EP_Destroy = "Context_Destroy";
+Type AbstractContext_EP_DestroyExtensions = "Context_DestroyExtensions";
-Type AbstractContext_EP_Dt = "Context_Dt";
-Type AbstractContext_EP_Step = "Context_Step";
-Type AbstractContext_EP_UpdateClass = "Context_UpdateClass";
-Type AbstractContext_EP_Solve = "Context_Solve";
-Type AbstractContext_EP_PostSolvePreUpdate = "Context_PostSolvePreUpdate";
-Type AbstractContext_EP_Sync = "Context_Sync";
-Type AbstractContext_EP_FrequentOutput = "Context_FrequentOutput";
-Type AbstractContext_EP_Dump = "Context_Dump";
-Type AbstractContext_EP_DumpClass = "Context_DumpClass";
-Type AbstractContext_EP_Save = "Context_Save";
-Type AbstractContext_EP_SaveClass = "Context_SaveClass";
-Type AbstractContext_EP_DataSave = "Context_DataSave";
-Type AbstractContext_EP_DataSaveClass = "Context_DataSaveClass";
-
+Type AbstractContext_EP_Dt = "Context_Dt";
+Type AbstractContext_EP_Step = "Context_Step";
+Type AbstractContext_EP_UpdateClass = "Context_UpdateClass";
+Type AbstractContext_EP_Solve = "Context_Solve";
+Type AbstractContext_EP_PostSolvePreUpdate = "Context_PostSolvePreUpdate";
+Type AbstractContext_EP_Sync = "Context_Sync";
+Type AbstractContext_EP_FrequentOutput = "Context_FrequentOutput";
+Type AbstractContext_EP_Dump = "Context_Dump";
+Type AbstractContext_EP_DumpClass = "Context_DumpClass";
+Type AbstractContext_EP_Save = "Context_Save";
+Type AbstractContext_EP_SaveClass = "Context_SaveClass";
+Type AbstractContext_EP_DataSave = "Context_DataSave";
+Type AbstractContext_EP_DataSaveClass = "Context_DataSaveClass";
/* Dictionary entry names */
const Type AbstractContext_Dict_Components = "components";
-
/* Class stuff ********************************************************************************************************************/
-
/* Textual name of this class */
const Type AbstractContext_Type = "Context";
const Type AbstractContext_Type_Verbose = "Context-verbose";
-AbstractContext* _AbstractContext_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- AbstractContext_SetDt* _setDt,
- double startTime,
- double stopTime,
- MPI_Comm communicator,
- Dictionary* dictionary )
-{
+AbstractContext* _AbstractContext_New( ABSTRACTCONTEXT_DEFARGS ) {
AbstractContext* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(AbstractContext) );
- self = (AbstractContext*)_Stg_Component_New( _sizeOfSelf, type, _delete, _print, _copy, _defaultConstructor, _construct,
- _build, _initialise, _execute, _destroy, name, NON_GLOBAL );
+ self = (AbstractContext*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
/* General info */
self->dictionary = dictionary;
- Journal_Firewall( self->dictionary->count,
- Journal_Register( Error_Type, "Error Stream" ),
- "Error in %s: The dictionary is empty, meaning no input parameters have been feed into your program. Perhaps you've forgot to pass any input files ( or command-line arguments ) in.\n", __func__);
-
/* Virtual info */
+ self->CF = 0; /* gets built in stgMain and passed in during the construct phase */
self->_setDt = _setDt;
-
- if( initFlag ){
- _AbstractContext_Init( self, startTime, stopTime, communicator );
- }
+ self->startTime = startTime;
+ self->stopTime = stopTime;
+ self->communicator = communicator;
return self;
}
-void _AbstractContext_Init(
- AbstractContext* self,
- double startTime,
- double stopTime,
- MPI_Comm communicator )
-{
+void _AbstractContext_Init( AbstractContext* self ) {
Stream* debug = Journal_Register( DebugStream_Type, AbstractContext_Type );
- Dictionary_Entry_Value* dictEntryVal = NULL;
- Dictionary *componentDict = NULL;
char buf[80];
#ifdef READ_HDF5
@@ -159,11 +128,13 @@ void _AbstractContext_Init(
/* General and Virtual info should already be set */
/* AbstractContext info */
- self->isConstructed = True;
- self->communicator = communicator;
MPI_Comm_rank( self->communicator, &self->rank );
MPI_Comm_size( self->communicator, &self->nproc );
self->debug = debug;
+
+ Journal_Enable_TypedStream( DebugStream_Type, False );
+ Journal_Enable_TypedStream( DumpStream_Type, False );
+
if( self->rank == 0 ) {
Journal_Printf(
debug,
@@ -176,6 +147,7 @@ void _AbstractContext_Init(
self->info = Journal_Register( InfoStream_Type, AbstractContext_Type );
self->verbose = Journal_Register( InfoStream_Type, AbstractContext_Type_Verbose );
sprintf( buf, "journal.info.%s", AbstractContext_Type_Verbose );
+
if( !Dictionary_Get( self->dictionary, buf ) ) {
Journal_Enable_NamedStream( InfoStream_Type, AbstractContext_Type_Verbose, False );
}
@@ -185,316 +157,79 @@ void _AbstractContext_Init(
}
/* Set up the registers and managers */
- self->CF = 0; /* gets built later */
- self->objectList = Stg_ObjectList_New();
- self->condFunc_Register = ConditionFunction_Register_New();
self->variable_Register = Variable_Register_New();
- self->extensionMgr_Register = ExtensionManager_Register_New();
self->extensionMgr = ExtensionManager_New_OfExistingObject( self->type, self );
- ExtensionManager_Register_Add( self->extensionMgr_Register, self->extensionMgr );
+ ExtensionManager_Register_Add( extensionMgr_Register, self->extensionMgr );
self->pointer_Register = Stg_ObjectList_New();
- self->register_Register = Stg_ObjectList_New();
self->plugins = PluginsManager_New();
- /* Main input parameters */
- self->frequentOutputEvery = Dictionary_Entry_Value_AsUnsignedInt(
- Dictionary_GetDefault( self->dictionary, "outputEvery", Dictionary_Entry_Value_FromUnsignedInt( 1 ) ) );
- self->dumpEvery = Dictionary_Entry_Value_AsUnsignedInt(
- Dictionary_GetDefault( self->dictionary, "dumpEvery", Dictionary_Entry_Value_FromUnsignedInt( 10 ) ) );
- self->checkpointEvery = Dictionary_Entry_Value_AsUnsignedInt(
- Dictionary_GetDefault( self->dictionary, "checkpointEvery", Dictionary_Entry_Value_FromUnsignedInt( 0 ) ) );
- self->saveDataEvery = Dictionary_Entry_Value_AsUnsignedInt(
- Dictionary_GetDefault( self->dictionary, "saveDataEvery", Dictionary_Entry_Value_FromUnsignedInt( 0 ) ) );
- self->checkpointAtTimeInc = Dictionary_Entry_Value_AsDouble(
- Dictionary_GetDefault( self->dictionary, "checkpointAtTimeInc", Dictionary_Entry_Value_FromDouble( 0 ) ) );
- self->nextCheckpointTime = self->checkpointAtTimeInc;
- self->experimentName = StG_Strdup( Dictionary_Entry_Value_AsString(
- Dictionary_GetDefault( self->dictionary, "experimentName", Dictionary_Entry_Value_FromString( "experiment" ) ) ) );
- self->outputPath = StG_Strdup( Dictionary_Entry_Value_AsString(
- Dictionary_GetDefault( self->dictionary, "outputPath", Dictionary_Entry_Value_FromString( "./" ) ) ) );
-
- self->checkpointReadPath = StG_Strdup( Dictionary_Entry_Value_AsString(
- Dictionary_GetDefault( self->dictionary, "checkpointPath", Dictionary_Entry_Value_FromString( self->outputPath ) ) ) );
- self->checkpointReadPath = StG_Strdup( Dictionary_Entry_Value_AsString(
- Dictionary_GetDefault( self->dictionary, "checkpointReadPath", Dictionary_Entry_Value_FromString( self->checkpointReadPath ) ) ) );
-
- self->checkpointWritePath = StG_Strdup( Dictionary_Entry_Value_AsString(
- Dictionary_GetDefault( self->dictionary, "checkpointPath", Dictionary_Entry_Value_FromString( self->outputPath ) ) ) );
- self->checkpointWritePath = StG_Strdup( Dictionary_Entry_Value_AsString(
- Dictionary_GetDefault( self->dictionary, "checkpointWritePath", Dictionary_Entry_Value_FromString( self->checkpointWritePath ) ) ) );
- self->checkpointAppendStep = Dictionary_Entry_Value_AsBool(
- Dictionary_GetDefault( self->dictionary, "checkpointAppendStep", Dictionary_Entry_Value_FromBool( False ) ) ) ;
- self->interpolateRestart = Dictionary_Entry_Value_AsBool(
- Dictionary_GetDefault( self->dictionary, "interpolateRestart", Dictionary_Entry_Value_FromBool( False ) ) ) ;
-
- if ( self->rank == 0 ) {
- if ( ! Stg_DirectoryExists( self->outputPath ) ) {
- Bool ret;
-
- if ( Stg_FileExists( self->outputPath ) ) {
- Journal_Firewall(
- 0,
- self->info,
- "outputPath '%s' is a file an not a directory! Exiting...\n", self->outputPath );
- }
-
- Journal_Printf( self->info, "outputPath '%s' does not exist, attempting to create...\n", self->outputPath );
- ret = Stg_CreateDirectory( self->outputPath );
- Journal_Firewall( ret, self->info, "Unable to create non-existing outputPath to '%s'\n", self->outputPath );
- /* else */
- Journal_Printf( self->info, "outputPath '%s' successfully created!\n", self->outputPath );
- }
- if ( ! Stg_DirectoryExists( self->checkpointWritePath ) ) {
- Bool ret;
-
- if ( Stg_FileExists( self->checkpointWritePath ) ) {
- Journal_Firewall(
- 0,
- self->info,
- "checkpointWritePath '%s' is a file an not a directory! Exiting...\n", self->checkpointWritePath );
- }
-
- Journal_Printf( self->info, "checkpointWritePath '%s' does not exist, attempting to create...\n", self->checkpointWritePath );
- ret = Stg_CreateDirectory( self->checkpointWritePath );
- Journal_Firewall( ret, self->info, "Unable to create non-existing checkpointWritePath to '%s'\n", self->checkpointWritePath );
- /* else */
- Journal_Printf( self->info, "checkpointWritePath '%s' successfully created!\n", self->checkpointWritePath );
- }
- }
-
- if ( self->rank == 0 ) {
- XML_IO_Handler* ioHandler;
- char* inputfileRecord;
- char* inputfileRecordWithDateTimeStamp;
- time_t currTime;
- struct tm* timeInfo;
- int adjustedYear;
- int adjustedMonth;
-
- Stream* s = Journal_Register( Info_Type, XML_IO_Handler_Type );
-
- /* Avoid confusing messages from XML_IO_Handler...turn it off temporarily */
- Bool isEnabled = Stream_IsEnable( s );
- Stream_EnableSelfOnly( s, False );
-
- ioHandler = XML_IO_Handler_New();
-
- /* Set file names */
- Stg_asprintf( &inputfileRecord, "%s/%s", self->outputPath, "input.xml" );
-
- currTime = time( NULL );
- timeInfo = localtime( &currTime );
- /* See man localtime() for why to adjust these */
- adjustedYear = 1900 + timeInfo->tm_year;
- adjustedMonth = 1 + timeInfo->tm_mon;
- /* Format; path/input-YYYY.MM.DD-HH.MM.SS.xml */
- Stg_asprintf( &inputfileRecordWithDateTimeStamp, "%s/%s-%.4d.%.2d.%.2d-%.2d.%.2d.%.2d.%s", self->outputPath, "input",
- adjustedYear, adjustedMonth, timeInfo->tm_mday,
- timeInfo->tm_hour, timeInfo->tm_min, timeInfo->tm_sec ,
- "xml" );
-
- IO_Handler_WriteAllToFile( ioHandler, inputfileRecord, self->dictionary );
- IO_Handler_WriteAllToFile( ioHandler, inputfileRecordWithDateTimeStamp, self->dictionary );
-
- Stream_EnableSelfOnly( s, isEnabled );
-
- Stg_Class_Delete( ioHandler );
- Memory_Free( inputfileRecord );
- Memory_Free( inputfileRecordWithDateTimeStamp );
- }
-
-
- /* Note: these try for deprecated keys "start", "end" and "stop" as well as new ones "startTime" and
- "stopTime" - Main.PatrickSunter - 4 November 2004 */
- dictEntryVal = Dictionary_Get( self->dictionary, "start" );
- if ( NULL == dictEntryVal ) {
- dictEntryVal = Dictionary_GetDefault( self->dictionary, "startTime",
- Dictionary_Entry_Value_FromDouble( startTime ) );
- }
- self->startTime = Dictionary_Entry_Value_AsDouble( dictEntryVal );
-
- dictEntryVal = Dictionary_Get( self->dictionary, "end" );
- if ( NULL == dictEntryVal ) {
- dictEntryVal = Dictionary_Get( self->dictionary, "stop" );
- if ( NULL == dictEntryVal ) {
- dictEntryVal = Dictionary_GetDefault( self->dictionary, "stopTime",
- Dictionary_Entry_Value_FromDouble( stopTime ) );
- }
- }
- self->stopTime = Dictionary_Entry_Value_AsDouble( dictEntryVal );
-
- /* maxTimeSteps of 0 means no maximum applied */
- /* Note: these try for deprecated key "maxLoops" as well as new one "maxTimeSteps" - Main.PatrickSunter - 4 November 2004 */
- dictEntryVal = Dictionary_Get( self->dictionary, "maxLoops" );
- if ( NULL == dictEntryVal ) {
- dictEntryVal = Dictionary_GetDefault( self->dictionary, "maxTimeSteps",
- Dictionary_Entry_Value_FromUnsignedInt( 0 ) );
- }
- self->maxTimeSteps = Dictionary_Entry_Value_AsUnsignedInt( dictEntryVal );
-
- self->finalTimeStep = Dictionary_GetUnsignedInt_WithDefault( self->dictionary, "finalTimeStep", 0 );
- self->gracefulQuit = False;
-
-
- /* TODO: does this need to be read from checkpoint file??? */
- self->currentTime = self->startTime;
- self->timeStep = 0;
- self->timeStepSinceJobRestart = 0;
-
- /* Read in the checkpointing info */
- self->restartTimestep = Dictionary_GetUnsignedInt_WithDefault( self->dictionary, "restartTimestep", 0 );
- self->checkPointPrefixString = Dictionary_GetString_WithDefault( self->dictionary, "checkPointPrefixString", "" );
- if ( self->restartTimestep != 0 ) {
- double dtFromFile;
- self->loadFromCheckPoint = True;
- self->timeStep = self->restartTimestep;
- _AbstractContext_LoadTimeInfoFromCheckPoint( self, self->restartTimestep, &dtFromFile );
- self->nextCheckpointTime += self->currentTime;
- }
- else {
- self->loadFromCheckPoint = False;
- }
-
/* Build the entryPoint table */
self->entryPoint_Register = EntryPoint_Register_New();
/* For the construct EP, override the run function such that the context/ptrToContext remain in sync in the loop. */
- self->constructK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Construct, EntryPoint_2VoidPtr_CastType ) );
- AbstractContext_GetEntryPoint( self, AbstractContext_EP_Construct )->_getRun = _AbstractContext_Construct_EP_GetRun;
- AbstractContext_GetEntryPoint( self, AbstractContext_EP_Construct )->run =
- EntryPoint_GetRun( AbstractContext_GetEntryPoint( self, AbstractContext_EP_Construct ) );
- self->constructExtensionsK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_ConstructExtensions, EntryPoint_VoidPtr_CastType ) );
- self->buildK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Build, EntryPoint_VoidPtr_CastType ) );
- self->initialiseK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Initialise, EntryPoint_VoidPtr_CastType ) );
- self->executeK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Execute, EntryPoint_VoidPtr_CastType ) );
- self->destroyK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Destroy, EntryPoint_VoidPtr_CastType ) );
- self->destroyExtensionsK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_DestroyExtensions, EntryPoint_VoidPtr_CastType ) );
+ self->constructK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_AssignFromXML, EntryPoint_2VoidPtr_CastType ) );
+ AbstractContext_GetEntryPoint( self, AbstractContext_EP_AssignFromXML )->_getRun = _AbstractContext_Construct_EP_GetRun;
+ AbstractContext_GetEntryPoint( self, AbstractContext_EP_AssignFromXML )->run = EntryPoint_GetRun( AbstractContext_GetEntryPoint( self, AbstractContext_EP_AssignFromXML ) );
+
+ self->constructExtensionsK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_AssignFromXMLExtensions, EntryPoint_VoidPtr_CastType ) );
+ self->buildK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Build, EntryPoint_VoidPtr_CastType ) );
+ self->initialiseK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Initialise, EntryPoint_VoidPtr_CastType ) );
+ self->executeK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Execute, EntryPoint_VoidPtr_CastType ) );
+ self->destroyK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Destroy, EntryPoint_VoidPtr_CastType ) );
+ self->destroyExtensionsK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_DestroyExtensions, EntryPoint_VoidPtr_CastType ) );
- self->dtK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Dt, ContextEntryPoint_Dt_CastType ) );
- self->stepK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Step, ContextEntryPoint_Step_CastType ) );
- self->updateClassK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_UpdateClass, EntryPoint_Class_VoidPtr_CastType ) );
- self->solveK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Solve, EntryPoint_VoidPtr_CastType ) );
- self->postSolveK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_PostSolvePreUpdate, EntryPoint_VoidPtr_CastType ) );
- self->syncK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Sync, EntryPoint_VoidPtr_CastType ) );
- self->frequentOutputK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_FrequentOutput, EntryPoint_VoidPtr_CastType ) );
- self->dumpK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Dump, EntryPoint_VoidPtr_CastType ) );
- self->dumpClassK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_DumpClass, EntryPoint_Class_VoidPtr_CastType ) );
- self->saveK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_Save, EntryPoint_VoidPtr_CastType ) );
- self->saveClassK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_SaveClass, EntryPoint_Class_VoidPtr_CastType ) );
- self->dataSaveK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_DataSave, EntryPoint_VoidPtr_CastType ) );
- self->dataSaveClassK = Context_AddEntryPoint(
- self,
- ContextEntryPoint_New( AbstractContext_EP_DataSaveClass, EntryPoint_Class_VoidPtr_CastType ) );
+ self->dtK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Dt, ContextEntryPoint_Dt_CastType ) );
+ self->stepK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Step, ContextEntryPoint_Step_CastType ) );
+ self->updateClassK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_UpdateClass, EntryPoint_Class_VoidPtr_CastType ) );
+ self->solveK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Solve, EntryPoint_VoidPtr_CastType ) );
+ self->postSolveK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_PostSolvePreUpdate, EntryPoint_VoidPtr_CastType ) );
+ self->syncK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Sync, EntryPoint_VoidPtr_CastType ) );
+ self->frequentOutputK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_FrequentOutput, EntryPoint_VoidPtr_CastType ) );
+ self->dumpK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Dump, EntryPoint_VoidPtr_CastType ) );
+ self->dumpClassK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_DumpClass, EntryPoint_Class_VoidPtr_CastType ) );
+ self->saveK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_Save, EntryPoint_VoidPtr_CastType ) );
+ self->saveClassK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_SaveClass, EntryPoint_Class_VoidPtr_CastType ) );
+ self->dataSaveK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_DataSave, EntryPoint_VoidPtr_CastType ) );
+ self->dataSaveClassK = Context_AddEntryPoint( self, ContextEntryPoint_New( AbstractContext_EP_DataSaveClass, EntryPoint_Class_VoidPtr_CastType ) );
/* add initial hooks */
- EntryPoint_Append(
- AbstractContext_GetEntryPoint( self, AbstractContext_EP_Construct ),
- "default",
- (Func_Ptr)_AbstractContext_Construct_Hook,
+ /* don't need now Stg_ComponentFactory_ConstructComponents, 13Nov09 JG, plan to rejig the context
+ post upcoming release */
+ EntryPoint_Append(
+ AbstractContext_GetEntryPoint( self, AbstractContext_EP_AssignFromXML ),
+ "_AbstractContext_Construct_Hook",
+ (Func_Ptr)_AbstractContext_Construct_Hook,
AbstractContext_Type );
EntryPoint_Append(
AbstractContext_GetEntryPoint( self, AbstractContext_EP_Execute ),
- "default",
+ "_AbstractContext_Execute_Hook",
(Func_Ptr)_AbstractContext_Execute_Hook,
AbstractContext_Type );
EntryPoint_Append(
AbstractContext_GetEntryPoint( self, AbstractContext_EP_Step ),
- "default",
+ "_AbstractContext_Step",
(Func_Ptr)_AbstractContext_Step,
AbstractContext_Type );
EntryPoint_Append(
AbstractContext_GetEntryPoint( self, AbstractContext_EP_Save ),
- "SaveTimeInfo",
+ "_AbstractContext_SaveTimeInfo",
(Func_Ptr)_AbstractContext_SaveTimeInfo,
AbstractContext_Type );
EntryPoint_Prepend_AlwaysFirst(
AbstractContext_GetEntryPoint( self, AbstractContext_EP_Save ),
- "CreateCheckpointDirectory",
+ "_AbstractContext_CreateCheckpointDirectory",
(Func_Ptr)_AbstractContext_CreateCheckpointDirectory,
AbstractContext_Type );
EntryPoint_Prepend_AlwaysFirst(
AbstractContext_GetEntryPoint( self, AbstractContext_EP_DataSave ),
- "CreateCheckpointDirectory",
+ "_AbstractContext_CreateCheckpointDirectory",
(Func_Ptr)_AbstractContext_CreateCheckpointDirectory,
AbstractContext_Type );
-
- Stg_ObjectList_ClassAppend( self->register_Register, (void*)self->extensionMgr_Register, "ExtensionManager_Register" );
- Stg_ObjectList_ClassAppend( self->register_Register, (void*)self->variable_Register, "Variable_Register" );
- Stg_ObjectList_ClassAppend( self->register_Register, (void*)self->condFunc_Register, "ConditionFunction_Register" );
- Stg_ObjectList_ClassAppend( self->register_Register, (void*)self->entryPoint_Register, "EntryPoint_Register" );
- Stg_ObjectList_ClassAppend( self->register_Register, (void*)self->pointer_Register, "Pointer_Register" );
-
- componentDict = Dictionary_GetDictionary( self->dictionary, "components" );
-
- /* Add functions to make sure all the live components are built and initialised */
- EntryPoint_Append(
- Context_GetEntryPoint( self, AbstractContext_EP_Build ),
- "BuildAllLiveComponents",
- AbstractContext_BuildAllLiveComponents,
- AbstractContext_Type );
- EntryPoint_Append(
- Context_GetEntryPoint( self, AbstractContext_EP_Initialise ),
- "InitialiseAllLiveComponents",
- AbstractContext_InitialiseAllLiveComponents,
- AbstractContext_Type );
-
- /* Check if we have been provided a constant to multiply our calculated dt values by. */
- self->dtFactor = Dictionary_GetDouble_WithDefault( self->dictionary, "timestepFactor", 1.0 );
}
void _AbstractContext_Delete( void* abstractContext ) {
AbstractContext* self = (AbstractContext*)abstractContext;
- Stg_Class_Delete( self->objectList );
- Stg_Class_Delete( self->condFunc_Register );
Stg_Class_Delete( self->variable_Register );
-
- Stg_Class_Delete( self->entryPoint_Register );
-
- Memory_Free( self->experimentName );
- Memory_Free( self->outputPath );
- Memory_Free( self->checkpointReadPath );
- Memory_Free( self->checkpointWritePath );
-
- Stg_Class_Delete( self->extensionMgr_Register );
- Stg_Class_Delete( self->plugins );
/* Stg_Class_Delete parent */
_Stg_Component_Delete( self );
@@ -565,8 +300,6 @@ void _AbstractContext_Print( void* abstr
Journal_Printf( (void*) stream, "\tsolveK: %u\n", self->solveK );
Journal_Printf( (void*) stream, "\tsyncK: %u\n", self->syncK );
- Stg_Class_Print( self->extensionMgr_Register, stream );
-
/* Print parent */
_Stg_Class_Print( self, stream );
}
@@ -589,28 +322,18 @@ Func_Ptr _AbstractContext_Construct_EP_G
}
void _AbstractContext_Construct_EP_Run( void* entryPoint, void* data0, void* data1 ) {
- /* This func should be _EntryPoint_Run_2VoidPtr, but with the synchronisation of context from ptrToContext after each
- * hook. */
EntryPoint* self = (EntryPoint*)entryPoint;
Hook_Index hookIndex;
AbstractContext* context = (AbstractContext*)data0;
- AbstractContext** ptrToContext = (AbstractContext**)data1;
-
#ifdef USE_PROFILE
Stg_CallGraph_Push( stgCallGraph, _EntryPoint_Run_2VoidPtr, self->name );
#endif
for( hookIndex = 0; hookIndex < self->hooks->count; hookIndex++ ) {
- ((EntryPoint_2VoidPtr_Cast*)((Hook*)self->hooks->data[hookIndex])->funcPtr)( context, ptrToContext );
+ ((EntryPoint_2VoidPtr_Cast*)((Hook*)self->hooks->data[hookIndex])->funcPtr)( context, NULL );
- /* BIG difference to default run function... we need to "re-sync" the context with the potentially new one. Once
- again this is only a HACK due to the implemented contexts NOT being extensions! What's also important, is
- that the list of things added to this "the contruct" entry point may have changed, but changed on this "new"
- context... need to "re-self" this EP. */
- context = *ptrToContext;
self = KeyHandle( context, context->constructK );
- /*context->entryPoint_Register */
}
#ifdef USE_PROFILE
@@ -622,35 +345,194 @@ void _AbstractContext_Construct_EP_Run(
/* Component stuff ****************************************************************************************************************/
-void _AbstractContext_Construct( void* context, Stg_ComponentFactory* cf, void* ptrToContext ) {
+void _AbstractContext_AssignFromXML( void* context, Stg_ComponentFactory* cf, void* data ) {
AbstractContext* self = (AbstractContext*)context;
- AbstractContext** ptrToSelf = (AbstractContext**)ptrToContext;
- Bool isConstructed;
+ Dictionary_Entry_Value* dictEntryVal = NULL;
+ double startTime, stopTime;
Journal_Printf( self->debug, "In: %s\n", __func__ );
- Journal_Firewall(
- self == *ptrToSelf,
- Journal_Register( Error_Type, AbstractContext_Type ),
- "ptrToContext is assumed to point to context\n" );
- #ifdef DEBUG
- Context_WarnIfNoHooks( self, self->buildK, __func__ );
- #endif
+ /* the following just pauses at this point to allow time to attach a debugger.. useful for mpi debugging */
+ sleep( Dictionary_Entry_Value_AsUnsignedInt(Dictionary_GetDefault( self->dictionary, "pauseToAttachDebugger", Dictionary_Entry_Value_FromUnsignedInt( 0 )) ) );
+
+ /* Main input parameters */
+ self->frequentOutputEvery = Dictionary_Entry_Value_AsUnsignedInt(
+ Dictionary_GetDefault( self->dictionary, "outputEvery", Dictionary_Entry_Value_FromUnsignedInt( 1 ) ) );
+ self->dumpEvery = Dictionary_Entry_Value_AsUnsignedInt(
+ Dictionary_GetDefault( self->dictionary, "dumpEvery", Dictionary_Entry_Value_FromUnsignedInt( 10 ) ) );
+ self->checkpointEvery = Dictionary_Entry_Value_AsUnsignedInt(
+ Dictionary_GetDefault( self->dictionary, "checkpointEvery", Dictionary_Entry_Value_FromUnsignedInt( 0 ) ) );
+ self->saveDataEvery = Dictionary_Entry_Value_AsUnsignedInt(
+ Dictionary_GetDefault( self->dictionary, "saveDataEvery", Dictionary_Entry_Value_FromUnsignedInt( 0 ) ) );
+ self->checkpointAtTimeInc = Dictionary_Entry_Value_AsDouble(
+ Dictionary_GetDefault( self->dictionary, "checkpointAtTimeInc", Dictionary_Entry_Value_FromDouble( 0 ) ) );
+ self->nextCheckpointTime = self->checkpointAtTimeInc;
+ self->experimentName = StG_Strdup( Dictionary_Entry_Value_AsString(
+ Dictionary_GetDefault( self->dictionary, "experimentName", Dictionary_Entry_Value_FromString( "experiment" ) ) ) );
+ self->outputPath = StG_Strdup( Dictionary_Entry_Value_AsString(
+ Dictionary_GetDefault( self->dictionary, "outputPath", Dictionary_Entry_Value_FromString( "./" ) ) ) );
- /* Pre-mark the phase as complete as a default hook will attempt to build all live components (including this again) */
- isConstructed = self->isConstructed;
- self->isConstructed = True;
+ if( Dictionary_Get( self->dictionary, "checkpointReadPath" ) ) {
+ self->checkpointReadPath = StG_Strdup( Dictionary_Entry_Value_AsString( Dictionary_Get( self->dictionary, "checkpointReadPath" ) ) );
+ }
+ else {
+ self->checkpointReadPath = StG_Strdup( self->outputPath );
+ }
+ if( Dictionary_Get( self->dictionary, "checkpointWritePath" ) ) {
+ self->checkpointWritePath = StG_Strdup( Dictionary_Entry_Value_AsString( Dictionary_Get( self->dictionary, "checkpointWritePath" ) ) );
+ }
+ else {
+ self->checkpointWritePath = StG_Strdup( self->outputPath );
+ }
- /* Construct all the components. There should be quite few in there right now, however, the context will do a toolbox
- and plugin load, which will add more and their dependencies. The toolboxes will be forced to construct within
- here*/
- KeyCall( self, self->constructK, EntryPoint_2VoidPtr_CallCast* )( KeyHandle(self,self->constructK), self, ptrToSelf );
- self = *ptrToSelf;
+ self->checkpointAppendStep = Dictionary_Entry_Value_AsBool(
+ Dictionary_GetDefault( self->dictionary, "checkpointAppendStep", Dictionary_Entry_Value_FromBool( False ) ) ) ;
+ self->interpolateRestart = Dictionary_Entry_Value_AsBool(
+ Dictionary_GetDefault( self->dictionary, "interpolateRestart", Dictionary_Entry_Value_FromBool( False ) ) ) ;
+ self->outputFlattenedXML = Dictionary_Entry_Value_AsBool(
+ Dictionary_GetDefault( self->dictionary, "outputFlattenedXML", Dictionary_Entry_Value_FromBool( True ) ) ) ;
- /* Construct the list of plugins. This wont reconstruct the components already constructed in the last step. By seperating
- the plugins contstruction out of the component construction EP gives an opportunity to do a wrap up before
- plugins start. The toolboxes will already be constructed by this stage. */
- ModulesManager_ConstructModules( self->plugins, self->CF, ptrToSelf );
+ if ( self->rank == 0 ) {
+ if ( ! Stg_DirectoryExists( self->outputPath ) ) {
+ Bool ret;
+
+ if ( Stg_FileExists( self->outputPath ) ) {
+ Journal_Firewall(
+ 0,
+ self->info,
+ "outputPath '%s' is a file an not a directory! Exiting...\n", self->outputPath );
+ }
+
+ Journal_Printf( self->info, "outputPath '%s' does not exist, attempting to create...\n", self->outputPath );
+ ret = Stg_CreateDirectory( self->outputPath );
+ Journal_Firewall( ret, self->info, "Unable to create non-existing outputPath to '%s'\n", self->outputPath );
+ /* else */
+ Journal_Printf( self->info, "outputPath '%s' successfully created!\n", self->outputPath );
+ }
+ if ( ! Stg_DirectoryExists( self->checkpointWritePath ) ) {
+ Bool ret;
+
+ if ( Stg_FileExists( self->checkpointWritePath ) ) {
+ Journal_Firewall(
+ 0,
+ self->info,
+ "checkpointWritePath '%s' is a file an not a directory! Exiting...\n", self->checkpointWritePath );
+ }
+
+ Journal_Printf( self->info, "checkpointWritePath '%s' does not exist, attempting to create...\n", self->checkpointWritePath );
+ ret = Stg_CreateDirectory( self->checkpointWritePath );
+ Journal_Firewall( ret, self->info, "Unable to create non-existing checkpointWritePath to '%s'\n", self->checkpointWritePath );
+ /* else */
+ Journal_Printf( self->info, "checkpointWritePath '%s' successfully created!\n", self->checkpointWritePath );
+ }
+ }
+
+ if ( self->rank == 0 && self->outputFlattenedXML) {
+ XML_IO_Handler* ioHandler;
+ char* inputfileRecord;
+ char* inputfileRecordWithDateTimeStamp;
+ time_t currTime;
+ struct tm* timeInfo;
+ int adjustedYear;
+ int adjustedMonth;
+
+ Stream* s = Journal_Register( Info_Type, XML_IO_Handler_Type );
+
+ /* Avoid confusing messages from XML_IO_Handler...turn it off temporarily */
+ Bool isEnabled = Stream_IsEnable( s );
+ Stream_EnableSelfOnly( s, False );
+
+ ioHandler = XML_IO_Handler_New();
+
+ /* Set file names */
+ Stg_asprintf( &inputfileRecord, "%s/%s", self->outputPath, "input.xml" );
+
+ currTime = time( NULL );
+ timeInfo = localtime( &currTime );
+ /* See man localtime() for why to adjust these */
+ adjustedYear = 1900 + timeInfo->tm_year;
+ adjustedMonth = 1 + timeInfo->tm_mon;
+ /* Format; path/input-YYYY.MM.DD-HH.MM.SS.xml */
+ Stg_asprintf( &inputfileRecordWithDateTimeStamp, "%s/%s-%.4d.%.2d.%.2d-%.2d.%.2d.%.2d.%s", self->outputPath, "input",
+ adjustedYear, adjustedMonth, timeInfo->tm_mday,
+ timeInfo->tm_hour, timeInfo->tm_min, timeInfo->tm_sec ,
+ "xml" );
+
+ IO_Handler_WriteAllToFile( ioHandler, inputfileRecord, self->dictionary );
+ IO_Handler_WriteAllToFile( ioHandler, inputfileRecordWithDateTimeStamp, self->dictionary );
+
+ Stream_EnableSelfOnly( s, isEnabled );
+
+ Stg_Class_Delete( ioHandler );
+ Memory_Free( inputfileRecord );
+ Memory_Free( inputfileRecordWithDateTimeStamp );
+ }
+
+
+ /* Note: these try for deprecated keys "start", "end" and "stop" as well as new ones "startTime" and
+ "stopTime" - Main.PatrickSunter - 4 November 2004 */
+ startTime = stopTime = 0;
+ dictEntryVal = Dictionary_Get( self->dictionary, "start" );
+ if ( NULL == dictEntryVal ) {
+ dictEntryVal = Dictionary_GetDefault( self->dictionary, "startTime",
+ Dictionary_Entry_Value_FromDouble( startTime ) );
+ }
+ self->startTime = Dictionary_Entry_Value_AsDouble( dictEntryVal );
+
+ dictEntryVal = Dictionary_Get( self->dictionary, "end" );
+ if ( NULL == dictEntryVal ) {
+ dictEntryVal = Dictionary_Get( self->dictionary, "stop" );
+ if ( NULL == dictEntryVal ) {
+ dictEntryVal = Dictionary_GetDefault( self->dictionary, "stopTime",
+ Dictionary_Entry_Value_FromDouble( stopTime ) );
+ }
+ }
+ self->stopTime = Dictionary_Entry_Value_AsDouble( dictEntryVal );
+
+ /* maxTimeSteps of 0 means no maximum applied */
+ /* Note: these try for deprecated key "maxLoops" as well as new one "maxTimeSteps" - Main.PatrickSunter - 4 November 2004 */
+ dictEntryVal = Dictionary_Get( self->dictionary, "maxLoops" );
+ if ( NULL == dictEntryVal ) {
+ dictEntryVal = Dictionary_GetDefault( self->dictionary, "maxTimeSteps", Dictionary_Entry_Value_FromUnsignedInt( 0 ) );
+ }
+ self->maxTimeSteps = Dictionary_Entry_Value_AsUnsignedInt( dictEntryVal );
+
+ self->finalTimeStep = Dictionary_GetUnsignedInt_WithDefault( self->dictionary, "finalTimeStep", 0 );
+ self->gracefulQuit = False;
+
+ /* TODO: does this need to be read from checkpoint file??? */
+ self->currentTime = self->startTime;
+ self->timeStep = 0;
+ self->timeStepSinceJobRestart = 0;
+
+ /* Read in the checkpointing info */
+ self->restartTimestep = Dictionary_GetUnsignedInt_WithDefault( self->dictionary, "restartTimestep", 0 );
+ self->checkPointPrefixString = Dictionary_GetString_WithDefault( self->dictionary, "checkPointPrefixString", "" );
+ if ( self->restartTimestep != 0 ) {
+ double dtFromFile;
+ self->loadFromCheckPoint = True;
+ self->timeStep = self->restartTimestep;
+ _AbstractContext_LoadTimeInfoFromCheckPoint( (void*)self, self->restartTimestep, &dtFromFile );
+ self->nextCheckpointTime += self->currentTime;
+ }
+ else {
+ self->loadFromCheckPoint = False;
+ }
+
+ /* Check if we have been provided a constant to multiply our calculated dt values by. */
+ self->dtFactor = Dictionary_GetDouble_WithDefault( self->dictionary, "timestepFactor", 1.0 );
+
+ /* this defines all the entryPoints, eg, self->constructK, etc...
+ so it must go before we start KeyCall */
+ _AbstractContext_Init( self );
+
+ /* construct entry point */
+ KeyCall( self, self->constructK, EntryPoint_2VoidPtr_CallCast* )( KeyHandle( self, self->constructK ), self, self );
+
+ /* Load the plugins desired by this context (dictionary) */
+ ModulesManager_Load( self->plugins, self->dictionary, self->name );
+
+ self->CF = cf;
/* Extensions are the last thing we want to do */
KeyCall( self, self->constructExtensionsK, EntryPoint_VoidPtr_CallCast* )( KeyHandle(self,self->constructExtensionsK), self );
@@ -661,7 +543,6 @@ void _AbstractContext_Construct( void* c
if ( True == Dictionary_GetBool_WithDefault( self->dictionary, "showJournalStatus", False ) ) {
Journal_PrintConcise();
}
- self->isConstructed = isConstructed;
}
@@ -678,6 +559,12 @@ void _AbstractContext_Build( void* conte
/* Pre-mark the phase as complete as a default hook will attempt to build all live components (including this again) */
isBuilt = self->isBuilt;
self->isBuilt = True;
+
+ /* Construct the list of plugins. do this in the build phase se that we know that any components required by the plugins
+ * have already been constructed */
+ if( self->plugins->codelets->count )
+ ModulesManager_ConstructModules( self->plugins, self->CF, data );
+
KeyCall( self, self->buildK, EntryPoint_VoidPtr_CallCast* )( KeyHandle(self,self->buildK), self );
self->isBuilt = isBuilt;
}
@@ -707,7 +594,7 @@ void _AbstractContext_Execute( void* con
Journal_Printf( self->debug, "In: %s\n", __func__ );
- #if DEBUG
+ #ifdef DEBUG
AbstractContext_WarnIfNoHooks( self, self->executeK, __func__ );
#endif
@@ -720,17 +607,29 @@ void _AbstractContext_Execute( void* con
void _AbstractContext_Destroy( void* context, void* data ) {
- AbstractContext* self = (AbstractContext*)context;
- Bool isDestroyed;
-
+ AbstractContext* self = (AbstractContext*)context;
+
Journal_Printf( self->debug, "In: %s\n", __func__ );
/* Pre-mark the phase as complete as a default hook will attempt to initialise all live components (including this again) */
- isDestroyed = self->isDestroyed;
- self->isDestroyed = True;
- KeyCall( self, self->destroyExtensionsK, EntryPoint_VoidPtr_CallCast* )( KeyHandle(self,self->destroyExtensionsK), self );
- KeyCall( self, self->destroyK, EntryPoint_VoidPtr_CallCast* )( KeyHandle(self,self->destroyK), self );
- self->isDestroyed = isDestroyed;
+ PluginsManager_RemoveAllFromComponentRegister( self->plugins );
+
+ KeyCall( self, self->destroyExtensionsK, EntryPoint_VoidPtr_CallCast* )( KeyHandle(self,self->destroyExtensionsK), self );
+ KeyCall( self, self->destroyK, EntryPoint_VoidPtr_CallCast* )( KeyHandle(self,self->destroyK), self );
+
+ Stg_Class_Delete( self->entryPoint_Register );
+ Stg_ObjectList_DeleteAllObjects( self->pointer_Register );
+ Stg_Class_Delete( self->pointer_Register );
+
+ /* remove the self->extensionMgr of this context from the extensionMgr_Register */
+ ExtensionManager_Register_Remove( extensionMgr_Register, self->extensionMgr );
+ Stg_Class_Delete( self->extensionMgr );
+ Stg_Class_Delete( self->dictionary );
+
+ Memory_Free( self->experimentName );
+ Memory_Free( self->outputPath );
+ Memory_Free( self->checkpointReadPath );
+ Memory_Free( self->checkpointWritePath );
}
@@ -758,10 +657,7 @@ EntryPoint_Index AbstractContext_AddEntr
}
-EntryPoint* AbstractContext_GetEntryPoint(
- void* abstractContext,
- const Name entryPointName )
-{
+EntryPoint* AbstractContext_GetEntryPoint( void* abstractContext, const Name entryPointName ) {
AbstractContext* self = (AbstractContext*)abstractContext;
EntryPoint_Index ep_I;
@@ -858,87 +754,14 @@ void AbstractContext_DataSave( void* con
KeyHandle(self,self->dataSaveClassK), self );
}
+/* Context hooks ******************************************************************************************************************/
-void AbstractContext_BuildAllLiveComponents( void* context ) {
- AbstractContext* self = (AbstractContext*) context;
-
- /* Build all on Live Stg_Component Register */
- if ( self->CF && self->CF->LCRegister )
- LiveComponentRegister_BuildAll( self->CF->LCRegister, self );
+void _AbstractContext_Construct_Hook( void* _context, void* data ) {
+
}
-
-void AbstractContext_InitialiseAllLiveComponents( void* context ) {
- AbstractContext* self = (AbstractContext*) context;
-
- /* Build all on Live Stg_Component Register */
- if ( self->CF && self->CF->LCRegister )
- LiveComponentRegister_InitialiseAll( self->CF->LCRegister, self );
-}
-
-
-/* Context hooks ******************************************************************************************************************/
-
-
-void _AbstractContext_Construct_Hook( void* context, void* ptrToContext ) {
- AbstractContext* self = (AbstractContext*)context;
- AbstractContext** ptrToSelf;
- Dictionary* componentDict;
- int index; /* needs to be signed */
-
- Journal_Printf( self->debug, "In: %s\n", __func__ );
-
- /* Obtain the components info from the global dictionary. Check that the dictionary has unique entry names. */
- if( (componentDict = Dictionary_GetDictionary( self->dictionary, AbstractContext_Dict_Components )) == NULL ) {
- componentDict = Dictionary_New();
- }
- CheckDictionaryKeys( componentDict, "Component dictionary must have unique names\n" );
-
- /* The component factory should be specific to this context, so create it here unless is already exists (i.e. desired
- behaviour has been purposely overridden). Add ourself to the global live register. */
- if( !self->CF ) {
- self->CF = Stg_ComponentFactory_New( self->dictionary, componentDict, self->register_Register );
- }
- LiveComponentRegister_Add( self->CF->LCRegister, (Stg_Component*)self );
-
- /* Boot up the toolboxes desired by this context (dictionary) */
- ModulesManager_Load( stgToolboxesManager, self->dictionary );
- /* SPECIAL BIT!
- Now that the toolboxes are loaded, now "contruct" each toolbox, ensuring that we "RE-construct" the context in the
- reverse order of the toolboxes. Ensuring that only the first (i.e. largest context) toolbox builds a new context.
- NOTE: This mechanism completely sucks! The way Contexts are replaced is crap but works for now. It shows that
- Context's should be implemented as extensions! */
- ptrToSelf = (AbstractContext**)ptrToContext;
- for( index = stgToolboxesManager->modules->count - 1; index >= 0; index-- ) {
- Module* module = (Module*)Stg_ObjectList_At( stgToolboxesManager->modules, index );
- char* mangledName = Module_MangledName( module );
-
- /* Contruct toolbox */
- Journal_Firewall(
- ModulesManager_ConstructModule( stgToolboxesManager, mangledName, self->CF, ptrToSelf ),
- Journal_Register( Error_Type, AbstractContext_Type ),
- "Error: Toolbox %s (mangled name: %s) could not be constructed."
- " Ensure it has a valid construction function.\n",
- module->name, mangledName );
-
- /* Swap self to the new one*/
- if( self != *ptrToSelf ) {
- self = *ptrToSelf;
- }
-
- Memory_Free( mangledName );
- }
-
- /* Load the plugins desired by this context (dictionary) */
- ModulesManager_Load( self->plugins, self->dictionary );
-
- Stg_ComponentFactory_CreateComponents( self->CF );
- Stg_ComponentFactory_ConstructComponents( self->CF, ptrToSelf );
-}
-
-
-void _AbstractContext_Execute_Hook( Context* context ) {
- AbstractContext* self = (AbstractContext*)context;
+void _AbstractContext_Execute_Hook( void* _context ) {
+ AbstractContext* self = (AbstractContext*)_context;
double dt = 0;
double dtLoadedFromFile = 0;
@@ -984,7 +807,7 @@ void _AbstractContext_Execute_Hook( Cont
at the end of the step we were restarting from, which should be equivalent to the
call here - and that calculation may be dependent on the solver info for that step,
so we need to reload it here */
- _AbstractContext_LoadTimeInfoFromCheckPoint( self, self->restartTimestep, &dtLoadedFromFile );
+ _AbstractContext_LoadTimeInfoFromCheckPoint( (void*)self, self->restartTimestep, &dtLoadedFromFile );
dt = dtLoadedFromFile;
}
else {
@@ -1005,21 +828,18 @@ void _AbstractContext_Execute_Hook( Cont
}
if ( self->checkpointEvery ) {
if ( self->timeStep % self->checkpointEvery == 0 ){
- self->isDataSave = False;
AbstractContext_Save( self );
}
}
if ( self->saveDataEvery ) {
if ( self->timeStep % self->saveDataEvery == 0 ){
- self->isDataSave = True;
AbstractContext_DataSave( self );
}
}
if ( self->checkpointAtTimeInc ) {
if ( self->currentTime >= self->nextCheckpointTime){
- self->isDataSave = False;
AbstractContext_Save( self );
self->nextCheckpointTime += self->checkpointAtTimeInc;
}
@@ -1037,15 +857,15 @@ void _AbstractContext_Execute_Hook( Cont
}
-void _AbstractContext_Step( Context* context, double dt ) {
- AbstractContext* self = (AbstractContext*)context;
+void _AbstractContext_Step( void* _context, double dt ) {
+ AbstractContext* self = (AbstractContext*)_context;
/* This will make it clear where the timestep starts when several procs
* running. Figure this 1 synchronisation is ok since we are likely to
* have just synchronised while calculating timestep anyway. */
MPI_Barrier( self->communicator );
Journal_DPrintf( self->debug, "In: %s\n", __func__ );
- Journal_RPrintf( self->info, "TimeStep = %d, Start time = %.6g + %.6g prev timeStep dt\n\n",
+ Journal_RPrintf( self->info, "TimeStep = %d, Start time = %.6g + %.6g prev timeStep dt\n",
self->timeStep, self->currentTime, dt );
if (self->loadFromCheckPoint) {
@@ -1064,7 +884,8 @@ void _AbstractContext_Step( Context* con
}
-void _AbstractContext_LoadTimeInfoFromCheckPoint( Context* self, Index timeStep, double* dtLoadedFromFile ) {
+void _AbstractContext_LoadTimeInfoFromCheckPoint( void* _context, Index timeStep, double* dtLoadedFromFile ) {
+ AbstractContext* self = (AbstractContext*)_context;
char* timeInfoFileName = NULL;
char* timeInfoFileNamePart = NULL;
FILE* timeInfoFile;
@@ -1077,6 +898,7 @@ void _AbstractContext_LoadTimeInfoFromCh
timeInfoFileNamePart = Context_GetCheckPointReadPrefixString( self );
#ifdef WRITE_HDF5
+ timeInfoFile = NULL;
Stg_asprintf( &timeInfoFileName, "%stimeInfo.%.5u.h5", timeInfoFileNamePart, self->restartTimestep );
/* Open the file and data set. */
@@ -1111,20 +933,7 @@ void _AbstractContext_LoadTimeInfoFromCh
H5Sclose( fileSpace );
H5Dclose( fileData );
-
- /* Read previous nproc from file */
- #if H5_VERS_MAJOR == 1 && H5_VERS_MINOR < 8
- fileData = H5Dopen( file, "/nproc" );
- #else
- fileData = H5Dopen( file, "/nproc", H5P_DEFAULT );
- #endif
- fileSpace = H5Dget_space( fileData );
-
- H5Dread( fileData, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(self->checkpointnproc) );
-
- H5Sclose( fileSpace );
- H5Dclose( fileData );
-
+
H5Fclose( file );
#else
@@ -1145,8 +954,8 @@ void _AbstractContext_LoadTimeInfoFromCh
}
-void _AbstractContext_SaveTimeInfo( Context* context ) {
- AbstractContext* self = context;
+void _AbstractContext_SaveTimeInfo( void* _context ) {
+ AbstractContext* self = (AbstractContext*)_context;
FILE* timeInfoFile = NULL;
char* timeInfoFileName = NULL;
char* timeInfoFileNamePart = NULL;
@@ -1161,6 +970,7 @@ void _AbstractContext_SaveTimeInfo( Cont
if ( self->rank == 0 ) {
timeInfoFileNamePart = Context_GetCheckPointWritePrefixString( self );
#ifdef WRITE_HDF5
+ timeInfoFile = NULL;
Stg_asprintf( &timeInfoFileName, "%stimeInfo.%.5u.h5", timeInfoFileNamePart, self->timeStep );
/* Create parallel file property list. */
@@ -1190,7 +1000,7 @@ void _AbstractContext_SaveTimeInfo( Cont
#endif
props = H5Pcreate( H5P_DATASET_XFER );
- H5Dwrite( fileData, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, props, &(context->currentTime) );
+ H5Dwrite( fileData, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, props, &(self->currentTime) );
H5Pclose( props );
H5Dclose( fileData );
H5Sclose( fileSpace );
@@ -1200,12 +1010,11 @@ void _AbstractContext_SaveTimeInfo( Cont
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR < 8
fileData = H5Dcreate( file, "/Dt", H5T_NATIVE_DOUBLE, fileSpace, H5P_DEFAULT );
#else
- fileData = H5Dcreate( file, "/Dt", H5T_NATIVE_DOUBLE, fileSpace,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
+ fileData = H5Dcreate( file, "/Dt", H5T_NATIVE_DOUBLE, fileSpace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
#endif
props = H5Pcreate( H5P_DATASET_XFER );
- Dt = AbstractContext_Dt( context );
+ Dt = AbstractContext_Dt( self );
H5Dwrite( fileData, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, props, &Dt );
H5Pclose( props );
H5Dclose( fileData );
@@ -1221,7 +1030,7 @@ void _AbstractContext_SaveTimeInfo( Cont
#endif
props = H5Pcreate( H5P_DATASET_XFER );
- H5Dwrite( fileData, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, props, &(context->nproc) );
+ H5Dwrite( fileData, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, props, &(self->nproc) );
H5Pclose( props );
H5Dclose( fileData );
H5Sclose( fileSpace );
@@ -1241,8 +1050,8 @@ void _AbstractContext_SaveTimeInfo( Cont
}
/* set currentTime and Dt loaded from file */
- fprintf( timeInfoFile, "%lg ", context->currentTime );
- fprintf( timeInfoFile, "%lg\n", AbstractContext_Dt( context ) );
+ fprintf( timeInfoFile, "%lg ", self->currentTime );
+ fprintf( timeInfoFile, "%lg\n", AbstractContext_Dt( self ) );
fclose( timeInfoFile );
#endif
@@ -1279,9 +1088,8 @@ Bool AbstractContext_CheckPointExists( v
}
char* Context_GetCheckPointReadPrefixString( void* context ) {
- AbstractContext* self = context;
- Index readStrLen = 0;
- char* readPathString = NULL;
+ AbstractContext* self = context;
+ char* readPathString = NULL;
if ( self->checkpointAppendStep ) {
if ( strlen(self->checkPointPrefixString) > 0 ) {
@@ -1303,9 +1111,8 @@ char* Context_GetCheckPointReadPrefixStr
}
char* Context_GetCheckPointWritePrefixString( void* context ) {
- AbstractContext* self = context;
- Index writeStrLen = 0;
- char* writePathString = NULL;
+ AbstractContext* self = context;
+ char* writePathString = NULL;
if ( self->checkpointAppendStep ) {
if ( strlen(self->checkPointPrefixString) > 0 ) {
@@ -1326,8 +1133,8 @@ char* Context_GetCheckPointWritePrefixSt
return writePathString;
}
-void _AbstractContext_CreateCheckpointDirectory( Context* context ) {
- AbstractContext* self = context;
+void _AbstractContext_CreateCheckpointDirectory( void* _context ) {
+ AbstractContext* self = (AbstractContext*)_context;
/* if we are creating individual directories for each checkpoint timestep, first create the directory if it doesn't exist. */
if ( self->checkpointAppendStep ) {
/* Only the master process creates the directory */
@@ -1353,3 +1160,5 @@ void _AbstractContext_CreateCheckpointDi
MPI_Barrier( self->communicator );
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/AbstractContext.h
--- a/Base/Context/src/AbstractContext.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/AbstractContext.h Tue Jan 12 14:38:16 2010 +1100
@@ -24,8 +24,6 @@
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**
-*/
-/** \file
** Role:
** Abstract class faciliting how "modellers"/"solvers" are laid out and execute.
**
@@ -39,19 +37,18 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Context_AbstractContext_h__
-#define __Base_Context_AbstractContext_h__
+#ifndef __StGermain_Base_Context_AbstractContext_h__
+#define __StGermain_Base_Context_AbstractContext_h__
/* Templates of virtual functions */
- typedef void (AbstractContext_SetDt) ( void* self, double dt );
-
+ typedef void (AbstractContext_SetDt) ( void* self, double dt );
/* Context_CallInfo info */
- #define __Base_Context_CallInfo \
- void* functionPointer; \
- void* entryPoint;
- struct Context_CallInfo { __Base_Context_CallInfo };
+ #define __StGermain_Base_Context_CallInfo \
+ void* functionPointer; \
+ void* entryPoint;
+ struct Context_CallInfo { __StGermain_Base_Context_CallInfo };
typedef enum CheckpointFileFormat {
CHECKPOINT_FORMAT_ASCII, /** Default Stg Ascii text format */
@@ -59,8 +56,8 @@
} CheckpointFileFormat;
/* AbstractContext entry point names */
- extern Type AbstractContext_EP_Construct;
- extern Type AbstractContext_EP_ConstructExtensions;
+ extern Type AbstractContext_EP_AssignFromXML;
+ extern Type AbstractContext_EP_AssignFromXMLExtensions;
extern Type AbstractContext_EP_Build;
extern Type AbstractContext_EP_Initialise;
extern Type AbstractContext_EP_Execute;
@@ -88,24 +85,24 @@
#define __AbstractContext \
/* General info */ \
__Stg_Component \
- Dictionary* dictionary; \
+ Dictionary* dictionary; \
\
/* Virtual info */ \
- AbstractContext_SetDt* _setDt; \
+ AbstractContext_SetDt* _setDt; \
\
/* AbstractContext info */ \
- MPI_Comm communicator; \
- int rank; \
- int nproc; \
+ MPI_Comm communicator; \
+ int rank; \
+ int nproc; \
/** Start time for the simulation. */ \
- double startTime; \
+ double startTime; \
/** Stop time for the simulation. Note that if this is 0, the sim will keep running unless a
max loops criterion is met. */ \
- double stopTime; \
- double currentTime; \
+ double stopTime; \
+ double currentTime; \
unsigned int timeStep; \
- double dtFactor; \
- double dt; \
+ double dtFactor; \
+ double dt; \
/** This additional timestep is necessary for checkpoint restart runs, so it can be compared against
maxTimeSteps (which is now relative to job restart).*/ \
unsigned int timeStepSinceJobRestart; \
@@ -114,31 +111,30 @@
/** Final Time Step: last time step to run till, no matter if maxTimeSteps still has some
left in a checkpoint restart run. If 0 (the default), not active. */ \
unsigned int finalTimeStep; \
- Bool gracefulQuit; \
+ Bool gracefulQuit; \
unsigned int frequentOutputEvery; \
unsigned int dumpEvery; \
unsigned int checkpointEvery; \
unsigned int saveDataEvery; \
- unsigned int checkpointnproc; \
- double checkpointAtTimeInc; \
- double nextCheckpointTime; \
- Name experimentName; \
- char* outputPath; \
- char* checkpointReadPath; \
- char* checkpointWritePath; \
+ double checkpointAtTimeInc; \
+ double nextCheckpointTime; \
+ Name experimentName; \
+ char* outputPath; \
+ char* checkpointReadPath; \
+ char* checkpointWritePath; \
/** user set bool to determine whether checkpoint (or data) files should be placed in a per timestep directory */ \
- Bool checkpointAppendStep; \
+ Bool checkpointAppendStep; \
/** user set bool to determine whether checkpoint restarts should interpolate to new
- resolution (where resolution is different from checkpoints) */ \
- Bool interpolateRestart; \
- Bool loadFromCheckPoint; \
- /** Bool to determine whether we are storing a full checkpoint (for restart) or only data for analysis */ \
- Bool isDataSave; \
- unsigned int restartTimestep; \
- char* checkPointPrefixString; \
- Stream* info; \
- Stream* verbose; \
- Stream* debug; \
+ resolution (where resolution is different from checkpoints) */ \
+ Bool interpolateRestart; \
+ Bool loadFromCheckPoint; \
+ /** flattened XML output can be disabled if desired (default True) */ \
+ Bool outputFlattenedXML; \
+ unsigned int restartTimestep; \
+ char* checkPointPrefixString; \
+ Stream* info; \
+ Stream* verbose; \
+ Stream* debug; \
\
/* These are stored keys to entrypoints in the table, used for O(1) lookup (i.e. speed) */ \
/* Contexts "are" Components implemented by entrypoints... there's an entry point per component phase */ \
@@ -165,51 +161,47 @@
EntryPoint_Index dataSaveK; \
EntryPoint_Index dataSaveClassK; \
\
- Stg_ObjectList* objectList; \
- ConditionFunction_Register* condFunc_Register; \
- Variable_Register* variable_Register; \
+ Variable_Register* variable_Register; \
Pointer_Register* pointer_Register; \
- EntryPoint_Register* entryPoint_Register; \
- ExtensionManager_Register* extensionMgr_Register; \
+ EntryPoint_Register* entryPoint_Register; \
ExtensionManager* extensionMgr; \
- Register_Register* register_Register; \
- Stg_ComponentFactory* CF; \
- PluginsManager* plugins;
+ Stg_ComponentFactory* CF; \
+ PluginsManager* plugins;
struct AbstractContext { __AbstractContext };
-
+
+
+
/* Class stuff ************************************************************************************************************/
/* No "AbstractContext_New" and "AbstractContext_Init" as this is an abstract class */
/* Creation implementation / Virtual constructor */
- AbstractContext* _AbstractContext_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- AbstractContext_SetDt* _setDt,
- double startTime,
- double stopTime,
- MPI_Comm communicator,
- Dictionary* dictionary );
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define ABSTRACTCONTEXT_DEFARGS \
+ STG_COMPONENT_DEFARGS, \
+ AbstractContext_SetDt* _setDt, \
+ double startTime, \
+ double stopTime, \
+ MPI_Comm communicator, \
+ Dictionary* dictionary
+
+ #define ABSTRACTCONTEXT_PASSARGS \
+ STG_COMPONENT_PASSARGS, \
+ _setDt, \
+ startTime, \
+ stopTime, \
+ communicator, \
+ dictionary
+
+ AbstractContext* _AbstractContext_New( ABSTRACTCONTEXT_DEFARGS );
+
/* Initialisation implementation */
- void _AbstractContext_Init(
- AbstractContext* self,
- double startTime,
- double stopTime,
- MPI_Comm communicator );
-
+ void _AbstractContext_Init( AbstractContext* self );
/* Stg_Class_Delete implementation */
void _AbstractContext_Delete( void* abstractContext );
@@ -222,7 +214,7 @@
/* Construct the context ... connect and validate component connections, and initialise non-bulk internal values */
- void _AbstractContext_Construct( void* context, Stg_ComponentFactory* cf, void* data );
+ void _AbstractContext_AssignFromXML( void* context, Stg_ComponentFactory* cf, void* data );
/* Build the context ... allocates memory (builds arrays) */
void _AbstractContext_Build( void* context, void* data );
@@ -278,9 +270,6 @@
/* function to error if no hooks to an entrypoint defined */
void AbstractContext_ErrorIfNoHooks( void* context, EntryPoint_Index epIndex, const char* caller );
- void AbstractContext_BuildAllLiveComponents( void* context ) ;
- void AbstractContext_InitialiseAllLiveComponents( void* context ) ;
-
Bool AbstractContext_CheckPointExists( void* context, Index timeStep );
/* Works out the prefix string to use for reading checkpoint files (input path + C.P. prefix)
@@ -295,17 +284,22 @@
/* Default construction hook, and overrides for the EP to handle the context/ptrToContext synchronisation */
- void _AbstractContext_Construct_Hook( void* context, void* ptrToContext );
+ void _AbstractContext_Construct_Hook( void* _context, void* data );
+
Func_Ptr _AbstractContext_Construct_EP_GetRun( void* entryPoint );
+
void _AbstractContext_Construct_EP_Run( void* entryPoint, void* data0, void* data1 );
/* Default construction hook */
- void _AbstractContext_Execute_Hook( Context* context );
+ void _AbstractContext_Execute_Hook( void* _context );
/* Step the solver implementation */
- void _AbstractContext_Step( Context* context, double dt );
+ void _AbstractContext_Step( void* _context, double dt );
- void _AbstractContext_LoadTimeInfoFromCheckPoint( Context* self, Index timeStep, double* dtLoadedFromFile );
- void _AbstractContext_SaveTimeInfo( Context* context );
- void _AbstractContext_CreateCheckpointDirectory( Context* context );
-#endif /* __Base_Context_AbstractContext_h__ */
+ void _AbstractContext_LoadTimeInfoFromCheckPoint( void* _context, Index timeStep, double* dtLoadedFromFile );
+
+ void _AbstractContext_SaveTimeInfo( void* _context );
+
+ void _AbstractContext_CreateCheckpointDirectory( void* _context );
+#endif /* __StGermain_Base_Context_AbstractContext_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Codelet.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/Codelet.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,139 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: Codelet.c 3192 2005-08-25 01:45:42Z AlanLo $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+#include "Base/Automation/Automation.h"
+#include "Base/Extensibility/Extensibility.h"
+
+#include "types.h"
+#include "shortcuts.h"
+#include "AbstractContext.h"
+#include "Codelet.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = NON_GLOBAL;
+
+const Type Codelet_Type = "Codelet";
+
+void* Codelet_New(
+ Type type,
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor,
+ Stg_Component_ConstructFunction* _construct,
+ Stg_Component_BuildFunction* _build,
+ Stg_Component_InitialiseFunction* _initialise,
+ Stg_Component_ExecuteFunction* _execute,
+ Stg_Component_DestroyFunction* _destroy,
+ Name name )
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( Codelet );
+ Stg_Class_DeleteFunction* _delete = _Codelet_Delete;
+ Stg_Class_PrintFunction* _print = _Codelet_Print;
+ Stg_Class_CopyFunction* _copy = _Codelet_Copy;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _Codelet_New( CODELET_PASSARGS );
+}
+
+void* _Codelet_New( CODELET_DEFARGS )
+{
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = NON_GLOBAL;
+
+ return _Stg_Component_New( STG_COMPONENT_PASSARGS );
+}
+
+void _Codelet_Delete( void* codelet ) {
+ _Stg_Component_Delete( codelet );
+}
+void _Codelet_Print( void* codelet, Stream* stream ) {
+ Codelet* self = (Codelet*)codelet;
+
+ Journal_Printf( stream, "Codelet: %s, Type %s\n", self->name, self->type );
+ _Stg_Component_Print( self, stream );
+}
+void* _Codelet_Copy( void* codelet, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
+ return _Stg_Component_Copy( codelet, dest, deep, nameExt, ptrMap );
+}
+
+
+void _Codelet_Build( void* codelet, void* data ) {
+
+}
+void _Codelet_Initialise( void* codelet, void* data ) {
+
+}
+void _Codelet_Execute( void* codelet, void* data ) {
+
+}
+void _Codelet_Destroy( void* codelet, void* data ) {
+
+}
+
+Dictionary* Codelet_GetPluginDictionary( void* codelet, Dictionary* rootDict ) {
+ Codelet* self = (Codelet*)codelet;
+ Dictionary_Entry_Value* pluginsDEV = Dictionary_Get( rootDict, "plugins" );
+ Dictionary* pluginDict;
+ unsigned pluginIndex;
+ Name pluginType;
+
+ for( pluginIndex = 0; pluginIndex < Dictionary_Entry_Value_GetCount( pluginsDEV ); pluginIndex++ ) {
+ pluginDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Entry_Value_GetElement( pluginsDEV, pluginIndex ) );
+ pluginType = Dictionary_GetString( pluginDict, "Type" );
+ if( !strcmp( self->type, pluginType ) )
+ return pluginDict;
+ }
+
+ return NULL;
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Codelet.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/Codelet.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,89 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: Codelet.h 3192 2005-08-25 01:45:42Z AlanLo $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Base_Context_Codelet_h__
+#define __StGermain_Base_Context_Codelet_h__
+
+ /* Textual name of this class */
+ extern const Type Codelet_Type;
+
+ /* Codelets info */
+ #define __Codelet \
+ __Stg_Component \
+ \
+ AbstractContext* context;
+
+ struct Codelet { __Codelet };
+
+
+ void* Codelet_New(
+ Type type,
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor,
+ Stg_Component_ConstructFunction* _construct,
+ Stg_Component_BuildFunction* _build,
+ Stg_Component_InitialiseFunction* _initialise,
+ Stg_Component_ExecuteFunction* _execute,
+ Stg_Component_DestroyFunction* _destroy,
+ Name name );
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define CODELET_DEFARGS \
+ STG_COMPONENT_DEFARGS
+
+ #define CODELET_PASSARGS \
+ STG_COMPONENT_PASSARGS
+
+ void* _Codelet_New( CODELET_DEFARGS );
+
+ void _Codelet_Delete( void* codelet );
+ void _Codelet_Print( void* codelet, Stream* stream );
+ void* _Codelet_Copy( void* codelet, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
+
+ void _Codelet_Build( void* codelet, void* data );
+ void _Codelet_Initialise( void* codelet, void* data );
+ void _Codelet_Execute( void* codelet, void* data );
+ void _Codelet_Destroy( void* codelet, void* data );
+
+ Dictionary* Codelet_GetPluginDictionary( void* codelet, Dictionary* rootDict );
+
+#endif
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Codelet.meta
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/Codelet.meta Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">Codelet</param>
+<param name="Author">Steve Quenette</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StGermain</param>
+<param name="Location">./StGermain/Base/Context/src/</param>
+<param name="Project Web">http://www.stgermainproject.org/</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
+<param name="Parent">Stg_Component</param>
+<param name="Reference"></param>
+<param name="Summary">Codelets are components that are used to encapsulate the concerns of a plugin into one object.</param>
+<param name="Description">
+<p>Codelets are essentially nothing more than Components that are used for encapsulating the concerns/features of a plugin into one object. The plugin registration process expects Codelet to be submitted for addition to the component factory. Codelets are assumed to be instantiated only one (i.e. are singletons) by the system.</p>
+
+<p>A Codelet is an abstract class that is used in the C API and not directly in the XML model description files</p>
+</param>
+
+
+<list name="Params">
+ <!-- None -->
+</list>
+
+
+<list name="Dependencies">
+ <!-- None -->
+</list>
+
+
+<param name="Example">n/a</param>
+
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/CompositeVC.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/CompositeVC.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,653 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: CompositeVC.c 4298 2008-08-25 01:14:56Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+#include "Base/Automation/Automation.h"
+#include "Base/Extensibility/Extensibility.h"
+
+#include "types.h"
+#include "Variable.h"
+#include "Variable_Register.h"
+#include "VariableCondition.h"
+#include "VariableCondition_Register.h"
+#include "ConditionFunction.h"
+#include "ConditionFunction_Register.h"
+#include "ContextEntryPoint.h"
+#include "AbstractContext.h"
+#include "CompositeVC.h"
+
+#include <string.h>
+#include <assert.h>
+
+
+const Type CompositeVC_Type = "CompositeVC";
+const Name defaultCompositeVCName = "defaultCompositeVCName";
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Constructor
+*/
+
+VariableCondition* CompositeVC_Factory(
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data )
+{
+ return (VariableCondition*)CompositeVC_New( defaultCompositeVCName, context, variable_Register, conFunc_Register, dictionary, data );
+}
+
+CompositeVC* CompositeVC_New(
+ Name name,
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data )
+{
+ CompositeVC* self = _CompositeVC_DefaultNew( name );
+
+ self->isConstructed = True;
+ _VariableCondition_Init( self, context, variable_Register, conFunc_Register, dictionary );
+ _CompositeVC_Init( self, data );
+
+ return self;
+}
+
+CompositeVC* _CompositeVC_DefaultNew( Name name ) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(CompositeVC);
+ Type type = CompositeVC_Type;
+ Stg_Class_DeleteFunction* _delete = _CompositeVC_Delete;
+ Stg_Class_PrintFunction* _print = _CompositeVC_Print;
+ Stg_Class_CopyFunction* _copy = _CompositeVC_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = (Stg_Component_DefaultConstructorFunction*)_CompositeVC_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _CompositeVC_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _CompositeVC_Build;
+ Stg_Component_InitialiseFunction* _initialise = _VariableCondition_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _VariableCondition_Execute;
+ Stg_Component_DestroyFunction* _destroy = _CompositeVC_Destroy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+ VariableCondition_BuildSelfFunc* _buildSelf = NULL;
+ VariableCondition_PrintConciseFunc* _printConcise = _CompositeVC_PrintConcise;
+ VariableCondition_ReadDictionaryFunc* _readDictionary = _CompositeVC_ReadDictionary;
+ VariableCondition_GetSetFunc* _getSet = _CompositeVC_GetSet;
+ VariableCondition_GetVariableCountFunc* _getVariableCount = _CompositeVC_GetVariableCount;
+ VariableCondition_GetVariableIndexFunc* _getVariableIndex = _CompositeVC_GetVariableIndex;
+ VariableCondition_GetValueIndexFunc* _getValueIndex = _CompositeVC_GetValueIndex;
+ VariableCondition_GetValueCountFunc* _getValueCount = _CompositeVC_GetValueCount;
+ VariableCondition_GetValueFunc* _getValue = _CompositeVC_GetValue;
+ VariableCondition_ApplyFunc* _apply = _CompositeVC_Apply;
+
+ return (CompositeVC*)_CompositeVC_New( COMPOSITEVC_PASSARGS );
+}
+
+CompositeVC* _CompositeVC_New( COMPOSITEVC_DEFARGS ) {
+ CompositeVC* self;
+
+ /* Allocate memory/General info */
+ assert (_sizeOfSelf >= sizeof(CompositeVC) );
+ self = (CompositeVC*)_VariableCondition_New( VARIABLECONDITION_PASSARGS );
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+
+ return self;
+}
+
+
+void _CompositeVC_Init( void* compositeVC, void* data ) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+
+ self->isConstructed = True;
+ self->itemCount = 0;
+ self->nIndepItems = 0;
+ self->indepItems = NULL;
+ self->_size = 8;
+ self->_delta = 8;
+ self->itemTbl = Memory_Alloc_Array( VariableCondition*, self->_size, "CompositeCV->itemTbl" );
+ memset(self->itemTbl, 0 , sizeof(VariableCondition*)*self->_size);
+ self->iOwnTbl = Memory_Alloc_Array( Bool, self->_size, "CompositeCV->iOwnTbl" );
+ memset(self->iOwnTbl, 0, sizeof(Bool)*self->_size);
+ self->data = data;
+ self->attachedSets = 0;
+ self->hasReadDictionary = False;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** General virtual functions
+*/
+
+void _CompositeVC_ReadDictionary( void* compositeVC, void* dictionary ) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+
+ /* View the dictionary as a list of variable conditions */
+ if( dictionary && !self->hasReadDictionary ) {
+ Dictionary_Entry_Value* vcList;
+
+ vcList = Dictionary_Get( dictionary, "independentVCList" );
+
+ if( vcList ) {
+ Index count;
+ Index entry_I;
+
+ count = Dictionary_Entry_Value_GetCount(vcList);
+
+ for (entry_I = 0; entry_I < count; entry_I++) {
+ Dictionary_Entry_Value* vcEntry;
+ Type type;
+ Dictionary* dictionary;
+ VariableCondition* vc;
+
+ vcEntry = Dictionary_Entry_Value_GetElement(vcList, entry_I);
+ type = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(vcEntry, "type"));
+ dictionary = Dictionary_Entry_Value_AsDictionary(vcEntry);
+ vc = VariableCondition_Register_CreateNew( self->context, variableCondition_Register, self->variable_Register,
+ self->conFunc_Register, type, dictionary, self->data );
+ vc->cf = self->cf;
+ vc->_readDictionary( vc, dictionary );
+
+ self->nIndepItems++;
+ self->indepItems = ReallocArray( self->indepItems, VariableCondition*, self->nIndepItems );
+ self->indepItems[self->nIndepItems - 1] = vc;
+
+ /* Don't add so we can modify the matrix later.
+ CompositeVC_Add(self, vc, True);
+ */
+ }
+ }
+ vcList = Dictionary_Get( dictionary, "vcList" );
+
+ if( vcList ) {
+ Index count;
+ Index entry_I;
+
+ count = Dictionary_Entry_Value_GetCount(vcList);
+
+ for (entry_I = 0; entry_I < count; entry_I++) {
+ Dictionary_Entry_Value* vcEntry;
+ Type type;
+ Dictionary* dictionary;
+ VariableCondition* vc;
+
+ vcEntry = Dictionary_Entry_Value_GetElement(vcList, entry_I);
+ type = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(vcEntry, "type"));
+ dictionary = Dictionary_Entry_Value_AsDictionary(vcEntry);
+ vc = VariableCondition_Register_CreateNew( self->context, variableCondition_Register, self->variable_Register,
+ self->conFunc_Register, type, dictionary, self->data );
+ vc->_readDictionary( vc, dictionary );
+ CompositeVC_Add(self, vc, True);
+ }
+ }
+ self->hasReadDictionary = True;
+ }
+}
+
+void _CompositeVC_AssignFromXML( void* compositeVC, Stg_ComponentFactory* cf, void* data ) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ void* variableRegister = NULL;
+ void* conditionFunctionRegister = NULL;
+ void* initData = NULL;
+ Dictionary* vcDict = NULL;
+ Name vcName;
+ AbstractContext* context;
+
+ /* Need to store this so we can get at components
+ later on when using the fucked up 'ReadDictionary' function. */
+ self->cf = cf;
+
+ context = Stg_ComponentFactory_ConstructByKey( cf, self->name, "Context", AbstractContext, False, data );
+ if( !context )
+ context = Stg_ComponentFactory_ConstructByName( cf, "context", AbstractContext, True, data );
+
+ variableRegister = context->variable_Register;
+ assert( variableRegister );
+ conditionFunctionRegister = condFunc_Register;
+ assert( conditionFunctionRegister );
+
+ vcName = Stg_ComponentFactory_GetString( cf, self->name, "vcName", self->name );
+
+ if ( cf->rootDict )
+ vcDict = Dictionary_GetDictionary( cf->rootDict, vcName );
+
+ initData = Stg_ComponentFactory_ConstructByKey( cf, self->name, "Data", Stg_Component, False, data );
+
+ _VariableCondition_Init( self, context, variableRegister, conditionFunctionRegister, vcDict );
+ _CompositeVC_Init( self, initData );
+}
+
+void _CompositeVC_Delete(void* compositeVC) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+
+ /* Stg_Class_Delete parent */
+ _VariableCondition_Delete(self);
+}
+
+void _CompositeVC_Destroy(void* compositeVC, void* data) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ int ii;
+
+ if( self->indepItems ) {
+ for( ii = 0; ii < self->nIndepItems; ii++ )
+ _VariableCondition_Delete( self->indepItems[ii]);
+ Memory_Free( self->indepItems );
+ }
+
+ if (self->itemTbl) {
+ VariableCondition_Index entry_I;
+
+ for (entry_I = 0; entry_I < self->itemCount; entry_I++) {
+ if (self->iOwnTbl[entry_I] && self->itemTbl[entry_I])
+ //Stg_Component_Destroy( self->itemTbl[entry_I], NULL, False );
+ _VariableCondition_Delete( self->itemTbl[entry_I]);
+ }
+ Memory_Free(self->itemTbl);
+ }
+
+ if( self->attachedSets ) {
+ Memory_Free( self->attachedSets );
+ }
+
+ Stg_Component_Destroy( self->data, NULL, False );
+
+ _VariableCondition_Destroy( self, data );
+}
+
+void _CompositeVC_Print(void* compositeVC, Stream* stream) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ Index item_I;
+
+ /* Set the Journal for printing informations */
+ Stream* info = stream;
+
+ /* General info */
+ Journal_Printf( info, "CompositeVC (ptr): %p\n", self);
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+ Journal_Printf( info, "\tdictionary (ptr): %p\n", self->dictionary);
+ Journal_Printf( info, "\titemCount: %u\n", self->itemCount );
+ Journal_Printf( info, "\titemTbl (ptr): %p\n", self->itemTbl);
+ if (self->itemTbl)
+ {
+ for (item_I = 0; item_I < self->itemCount; item_I++)
+ Journal_Printf( info, "\t\titemTbl[%u] (ptr): %p\n", item_I, self->itemTbl[item_I]);
+ }
+ Journal_Printf( info, "\tiOwnTbl (ptr): %p\n", self->iOwnTbl);
+ if (self->iOwnTbl)
+ {
+ for (item_I = 0; item_I < self->itemCount; item_I++)
+ Journal_Printf( info, "\t\tiOwnTbl[%u]: %s\n", item_I, self->iOwnTbl[item_I] ? "True" : "False");
+ }
+ Journal_Printf( info, "\t_size: %lu\n", self->_size);
+ Journal_Printf( info, "\t_delta: %lu\n", self->_delta);
+
+ /* Print parent */
+ _VariableCondition_Print(self);
+}
+
+
+void* _CompositeVC_Copy( void* compositeVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ CompositeVC* newCompositeVC;
+ PtrMap* map = ptrMap;
+ Bool ownMap = False;
+
+ if( !map ) {
+ map = PtrMap_New( 10 );
+ ownMap = True;
+ }
+
+ newCompositeVC = (CompositeVC*)_VariableCondition_Copy( self, dest, deep, nameExt, map );
+
+ newCompositeVC->itemCount = self->itemCount;
+ newCompositeVC->_size = self->_size;
+ newCompositeVC->_delta = self->_delta;
+ newCompositeVC->hasReadDictionary = self->hasReadDictionary;
+ newCompositeVC->data = self->data;
+
+ if( deep ) {
+ if( (newCompositeVC->itemTbl = PtrMap_Find( map, self->itemTbl )) == NULL && self->itemTbl ) {
+ Index item_I;
+
+ newCompositeVC->itemTbl = Memory_Alloc_Array( VariableCondition*, newCompositeVC->_size, "CompositeCV->itemTbl" );
+ memset( newCompositeVC->itemTbl, 0, sizeof(VariableCondition*) * newCompositeVC->_size );
+ for( item_I = 0; item_I < self->itemCount; item_I++ ) {
+ newCompositeVC->itemTbl[item_I] = (VariableCondition*)Stg_Class_Copy( self->itemTbl[item_I], NULL, deep, nameExt, map );
+ }
+ PtrMap_Append( map, newCompositeVC->itemTbl, self->itemTbl );
+ }
+
+ if( (newCompositeVC->iOwnTbl = PtrMap_Find( map, self->iOwnTbl )) == NULL && self->iOwnTbl ) {
+ newCompositeVC->iOwnTbl = Memory_Alloc_Array( Bool, newCompositeVC->_size, "CompositeCV->iOwnTbl" );
+ memcpy( newCompositeVC->iOwnTbl, self->iOwnTbl, sizeof(Bool) * newCompositeVC->_size );
+ PtrMap_Append( map, newCompositeVC->iOwnTbl, self->iOwnTbl );
+ }
+
+ if( (newCompositeVC->attachedSets = PtrMap_Find( map, self->attachedSets )) == NULL && self->attachedSets ) {
+ Index item_I;
+
+ self->attachedSets = Memory_Alloc_Array( IndexSet*, newCompositeVC->itemCount, "CompositeCV->attachedSets" );
+ for( item_I = 0; item_I < self->itemCount; item_I++ ) {
+ newCompositeVC->attachedSets[item_I] = (IndexSet*)Stg_Class_Copy( self->attachedSets[item_I], NULL, deep, nameExt, map );
+ }
+ PtrMap_Append( map, newCompositeVC->attachedSets, self->attachedSets );
+ }
+ }
+ else {
+ newCompositeVC->itemTbl = self->itemTbl;
+ newCompositeVC->iOwnTbl = self->iOwnTbl;
+ newCompositeVC->attachedSets = self->attachedSets;
+ }
+
+ if( ownMap ) {
+ Stg_Class_Delete( map );
+ }
+
+ return (void*)newCompositeVC;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Macros
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _CompositeVC_Build( void* compositeVC, void* data ) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ Index index;
+ int ii;
+
+ /* Read the dictionary... we have to do this early to get self->itemCount filled in. Hence we keep a flag to ensure we
+ dont read twice */
+ self->_readDictionary( self, self->dictionary );
+
+ /* Build a temporary array to store the sets of attached VCs for the build process and clear it afterward */
+ if( self->itemCount ) {
+ Index item_I;
+
+ self->attachedSets = Memory_Alloc_Array( IndexSet*, self->itemCount, "CompositeCV->attachedSets" );
+ memset( self->attachedSets, 0, sizeof(IndexSet*) * self->itemCount );
+
+ /* This guy is here so that a VC that was created by the composite VC can do any
+ build stuff it needs, without calling _VariableCondition_Build for itself. */
+ for( item_I = 0; item_I < self->itemCount; item_I++ ) {
+ VariableCondition_BuildSelf( self->itemTbl[item_I], data );
+ }
+
+ _VariableCondition_Build( self, data );
+ for( index = 0; index < self->itemCount; index++ ) {
+ Stg_Class_Delete( self->attachedSets[index] );
+ }
+ Memory_Free( self->attachedSets );
+ self->attachedSets = 0;
+ }
+
+ for( ii = 0; ii < self->nIndepItems; ii++ )
+ Stg_Component_Build( self->indepItems[ii], data, False );
+}
+
+
+IndexSet* _CompositeVC_GetSet( void* compositeVC ) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ IndexSet* set = NULL;
+ Index i;
+
+ /* Use the first attachment to obtain the size, etc. Be effecient by duplicating if for the my own set */
+ if( self->itemCount ) {
+ self->attachedSets[0] = self->itemTbl[0]->_getSet( self->itemTbl[0] );
+ set = IndexSet_Duplicate( self->attachedSets[0] );
+ }
+
+ /* For the remainder of the attachments, OR in their sets */
+ for( i = 1; i < self->itemCount; i++ ) {
+ self->attachedSets[i] = self->itemTbl[i]->_getSet( self->itemTbl[i] );
+ IndexSet_Merge_OR( set, self->attachedSets[i] );
+ }
+
+ return set;
+}
+
+
+Variable_Index _CompositeVC_GetVariableCount( void* compositeVC, Index globalIndex ) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ Variable_Index* varIndices;
+ Variable_Index varIndexCount = 0;
+ Index i;
+
+ varIndices = Memory_Alloc_Array( Variable_Index, self->variable_Register->count, "varIndices" );
+
+ for( i = 0; i < self->itemCount; i++ ) {
+ if( IndexSet_IsMember( self->attachedSets[i], globalIndex ) ) {
+ Index varCount = self->itemTbl[i]->_getVariableCount( self->itemTbl[i], globalIndex );
+ Index j;
+
+ for(j = 0; j < varCount; j++ ) {
+ Index newVarIndex = self->itemTbl[i]->_getVariableIndex(self->itemTbl[i], globalIndex, j);
+ Index k;
+
+ for (k = 0; k < varIndexCount; k++)
+ if (varIndices[k] == newVarIndex)
+ break;
+ if (k < varIndexCount)
+ continue;
+
+ varIndices[varIndexCount++] = newVarIndex;
+ }
+ }
+ }
+
+ if (varIndices) Memory_Free(varIndices);
+
+ return varIndexCount;
+}
+
+
+Variable_Index _CompositeVC_GetVariableIndex(
+ void* compositeVC,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex)
+{
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ Variable_Index* varIndices;
+ Variable_Index varIndexCount = 0;
+ Index i;
+
+ varIndices = Memory_Alloc_Array( Variable_Index, self->variable_Register->count, "varIndices" );
+
+ for( i = 0; i < self->itemCount; i++ ) {
+ if( IndexSet_IsMember( self->attachedSets[i], globalIndex ) ) {
+ Index varCount = self->itemTbl[i]->_getVariableCount(self->itemTbl[i], globalIndex);
+ Index j;
+
+ for (j = 0; j < varCount; j++)
+ {
+ Index newVarIndex = self->itemTbl[i]->_getVariableIndex(self->itemTbl[i], globalIndex, j);
+ Index k;
+
+ for (k = 0; k < varIndexCount; k++)
+ if (varIndices[k] == newVarIndex)
+ break;
+ if (k < varIndexCount)
+ continue;
+
+ if (varIndexCount == varIndex)
+ {
+ if (varIndices) Memory_Free(varIndices);
+ return newVarIndex;
+ }
+
+ varIndices[varIndexCount++] = newVarIndex;
+ }
+ }
+ }
+
+ if (varIndices) Memory_Free(varIndices);
+
+ return (Variable_Index)-1;
+}
+
+
+VariableCondition_ValueIndex _CompositeVC_GetValueIndex(
+ void* compositeVC,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex)
+{
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ VariableCondition_ValueIndex valIndex = (VariableCondition_ValueIndex)-1;
+ CompositeVC_ItemIndex valItem = 0;
+ Variable_Index varRegIndex = self->_getVariableIndex(self, globalIndex, varIndex);
+ Index i;
+
+ for( i = self->itemCount; i > 0; i-- ) {
+ if( IndexSet_IsMember( self->attachedSets[i-1], globalIndex ) ) {
+ Index j;
+
+ for (j = 0; j < self->itemTbl[i - 1]->_getVariableCount(self->itemTbl[i - 1], globalIndex); j++)
+ if (self->itemTbl[i - 1]->_getVariableIndex(self->itemTbl[i - 1], globalIndex, j) ==
+ varRegIndex)
+ break;
+ if (j == self->itemTbl[i - 1]->_getVariableCount(self->itemTbl[i - 1], globalIndex))
+ continue;
+
+ valItem = i - 1;
+ valIndex = self->itemTbl[valItem]->_getValueIndex(self->itemTbl[valItem], globalIndex, j);
+ break;
+ }
+ }
+
+ for (i = 0; i < valItem; i++)
+ valIndex += self->itemTbl[i]->_getValueCount(self->itemTbl[i]);
+
+ return valIndex;
+}
+
+
+VariableCondition_ValueIndex _CompositeVC_GetValueCount(void* compositeVC)
+{
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ VariableCondition_ValueIndex valCount = 0;
+ Index i;
+
+ for (i = 0; i < self->itemCount; i++)
+ valCount += self->itemTbl[i]->_getValueCount(self->itemTbl[i]);
+
+ return valCount;
+}
+
+
+VariableCondition_Value _CompositeVC_GetValue(void* compositeVC, VariableCondition_ValueIndex valIndex)
+{
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ VariableCondition_ValueIndex valPos = valIndex;
+ Index i = 0;
+
+ while (valPos >= self->itemTbl[i]->_getValueCount(self->itemTbl[i]))
+ {
+ valPos -= self->itemTbl[i]->_getValueCount(self->itemTbl[i]);
+ i++;
+/* if (++i >= self->itemCount) */
+ /* Then what? */
+ }
+
+ return self->itemTbl[i]->_getValue(self->itemTbl[i], valPos);
+}
+
+
+void _CompositeVC_PrintConcise( void* compositeVC, Stream* stream ) {
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ Index item_I;
+
+ Journal_Printf( stream, "\ttype: %s, {\n", self->type );
+ if( self->itemTbl ) {
+ for( item_I = 0; item_I < self->itemCount; item_I++ ) {
+ VariableCondition_PrintConcise( self->itemTbl[item_I], stream );
+ }
+ }
+ Journal_Printf( stream, "}\n" );
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Build functions
+*/
+
+CompositeVC_ItemIndex CompositeVC_Add(void* compositeVC, void* variableCondition, Bool iOwn)
+{
+ CompositeVC* self = (CompositeVC*)compositeVC;
+ CompositeVC_ItemIndex handle;
+
+ if (self->itemCount >= self->_size)
+ {
+ SizeT currentSize = self->_size;
+
+ self->_size += self->_delta;
+
+ self->itemTbl = Memory_Realloc_Array( self->itemTbl, VariableCondition*, self->_size );
+ memset( (Pointer)((ArithPointer)self->itemTbl + (sizeof(VariableCondition*) * currentSize) ),
+ 0, sizeof(VariableCondition*) * (self->_size - currentSize) );
+
+ self->iOwnTbl = Memory_Realloc_Array( self->iOwnTbl, Bool, self->_size );
+ memset( (Pointer)((ArithPointer)self->iOwnTbl + (sizeof(Bool) * currentSize )),
+ 0, sizeof(Bool) * (self->_size - currentSize ) );
+ }
+
+ handle = self->itemCount++;
+ self->itemTbl[handle] = (VariableCondition*) variableCondition;
+ self->iOwnTbl[handle] = iOwn;
+
+ return handle;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Functions
+*/
+
+void _CompositeVC_Apply( void* _self, void* _ctx ) {
+ CompositeVC* self = (CompositeVC*)_self;
+ int ii;
+
+ _VariableCondition_Apply( self, _ctx );
+
+ for( ii = 0; ii < self->nIndepItems; ii++ )
+ VariableCondition_Apply( self->indepItems[ii], _ctx );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/CompositeVC.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/CompositeVC.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,175 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/** \file
+** <b>Role:</b>
+**
+** <b>Assumptions:</b>
+**
+** <b>Comments:</b>
+**
+** $Id: CompositeVC.h 4297 2008-08-19 16:54:05Z LukeHodkinson $
+**
+**/
+
+#ifndef __StGermain_Base_Context_CompositeVC_h__
+#define __StGermain_Base_Context_CompositeVC_h__
+
+ extern const Type CompositeVC_Type;
+
+ #define __CompositeVC \
+ /* General info */ \
+ __VariableCondition \
+ \
+ /* Virtual info */ \
+ \
+ /* Stg_Class info */ \
+ CompositeVC_ItemIndex itemCount; \
+ VariableCondition** itemTbl; \
+ int nIndepItems; \
+ VariableCondition** indepItems; \
+ Bool* iOwnTbl; \
+ SizeT _size; \
+ SizeT _delta; \
+ void* data; \
+ IndexSet** attachedSets; \
+ Bool hasReadDictionary;
+
+ struct _CompositeVC { __CompositeVC };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructor
+ */
+
+ VariableCondition* CompositeVC_Factory(
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data );
+
+ CompositeVC* CompositeVC_New(
+ Name name,
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data );
+
+ CompositeVC* _CompositeVC_DefaultNew( Name name );
+
+ void CompositeVC_Init(
+ CompositeVC* self,
+ Name name,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data );
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define COMPOSITEVC_DEFARGS \
+ VARIABLECONDITION_DEFARGS
+
+ #define COMPOSITEVC_PASSARGS \
+ VARIABLECONDITION_PASSARGS
+
+ CompositeVC* _CompositeVC_New( COMPOSITEVC_DEFARGS );
+
+ void _CompositeVC_Init(
+ void* compositeVC,
+ void* data );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** General virtual functions
+ */
+
+ void _CompositeVC_Delete( void* compositeVC );
+
+ void _CompositeVC_Print( void* compositeVC, Stream* stream );
+
+ void _CompositeVC_Destroy( void* compositeVC, void* data );
+
+ /* Copy */
+ #define CompositeVC_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+ #define CompositeVC_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+
+ void* _CompositeVC_Copy( void* compositeVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Macros
+ */
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _CompositeVC_Build( void* compositeVC, void* data );
+
+ void _CompositeVC_AssignFromXML( void* compositeVC, Stg_ComponentFactory* cf, void* data );
+
+ void _CompositeVC_ReadDictionary( void* compositeVC, void* dictionary );
+
+ IndexSet* _CompositeVC_GetSet( void* compositeVC );
+
+ VariableCondition_VariableIndex _CompositeVC_GetVariableCount( void* compositeVC, Index globalIndex );
+
+ Variable_Index _CompositeVC_GetVariableIndex(
+ void* compositeVC,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex );
+
+ VariableCondition_ValueIndex _CompositeVC_GetValueIndex(
+ void* compositeVC,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex );
+
+ VariableCondition_ValueIndex _CompositeVC_GetValueCount( void* compositeVC );
+
+ VariableCondition_Value _CompositeVC_GetValue( void* compositeVC, VariableCondition_ValueIndex valIndex );
+
+ void _CompositeVC_PrintConcise( void* variableCondition, Stream* stream );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Build functions
+ */
+
+ CompositeVC_ItemIndex CompositeVC_Add( void* compositeVC, void* variableCondition, Bool iOwn );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Functions
+ */
+
+void _CompositeVC_Apply( void* _self, void* _ctx );
+
+
+#endif /* __StGermain_Base_Context_CompositeVC_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/CompositeVC.meta
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/CompositeVC.meta Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">CompositeVC</param>
+<param name="Author">...</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StGermain</param>
+<param name="Location">./StGermain/Base/Context/src/</param>
+<param name="Project Web">http://www.stgermainproject.org/</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
+<param name="Parent">VariableCondition</param>
+<param name="Reference">...</param>
+<param name="Summary">...</param>
+
+<param name="Description">
+ CompositeVC is used as a container to combine multiple variable conditions.
+</param>
+
+<list name="Params">
+ <struct>
+ <param name="Name">vcName</param>
+ <param name="Type">String</param>
+ <param name="Default">self->name</param>
+ <param name="Description">
+ Deprecated; should not be used.
+ </param>
+ </struct>
+ <struct>
+ <param name="Name">vcList</param>
+ <param name="Type">List</param>
+ <param name="Default"></param>
+ <param name="Description">
+ A list of other VariableCondition definitions.
+ </param>
+ </struct>
+</list>
+
+<list name="Dependencies">
+ <struct>
+ <param name="Essential">No</param>
+ <param name="Name">Data</param>
+ <param name="Type">Stg_Component</param>
+ <param name="Description">
+ User defined data in the form of a Stg_Component.
+ </param>
+ </struct>
+</list>
+
+<param name="Example">
+ Refer to ./StgFEM/Apps/StokesMomentumUzawa/lidDrivenBCs.xml
+</param>
+
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/ConditionFunction.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/ConditionFunction.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,172 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: ConditionFunction.c 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+
+#include "types.h"
+#include "ConditionFunction.h"
+
+#include <stdio.h>
+#include <assert.h>
+
+
+const Type ConditionFunction_Type = "ConditionFunction";
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Constructor
+*/
+
+ConditionFunction* ConditionFunction_New(ConditionFunction_ApplyFunc* apply, Name name)
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ConditionFunction);
+ Type type = ConditionFunction_Type;
+ Stg_Class_DeleteFunction* _delete = _ConditionFunction_Delete;
+ Stg_Class_PrintFunction* _print = _ConditionFunction_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ return _ConditionFunction_New( CONDITIONFUNCTION_PASSARGS );
+}
+
+
+void ConditionFunction_Init(ConditionFunction* self, ConditionFunction_ApplyFunc* apply, Name name)
+{
+ /* General info */
+ self->type = ConditionFunction_Type;
+ self->_sizeOfSelf = sizeof(ConditionFunction);
+ self->_deleteSelf = False;
+
+ /* Virtual info */
+ self->_delete = _ConditionFunction_Delete;
+ self->_print = _ConditionFunction_Print;
+ self->_copy = NULL;
+
+ _Stg_Class_Init((Stg_Class*)self);
+
+ /* Stg_Class info */
+ _ConditionFunction_Init(self, apply, name);
+}
+
+
+ConditionFunction* _ConditionFunction_New( CONDITIONFUNCTION_DEFARGS )
+{
+ ConditionFunction* self;
+
+ /* Allocate memory */
+ assert( _sizeOfSelf >= sizeof(ConditionFunction) );
+ self = (ConditionFunction*)_Stg_Class_New( STG_CLASS_PASSARGS );
+
+ /* General info */
+
+ /* Virtual functions */
+
+ /* Stg_Class info */
+ _ConditionFunction_Init(self, apply, name);
+
+ return self;
+}
+
+
+void _ConditionFunction_Init(void* conditionFunction, ConditionFunction_ApplyFunc* apply, Name name)
+{
+ ConditionFunction* self = (ConditionFunction*)conditionFunction;
+
+ self->apply = apply;
+ self->name = name;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** General virtual functions
+*/
+
+void _ConditionFunction_Delete(void* conditionFunction)
+{
+ ConditionFunction* self = (ConditionFunction*)conditionFunction;
+
+ /* Stg_Class_Delete parent class */
+ _Stg_Class_Delete(self);
+}
+
+
+void _ConditionFunction_Print(void* conditionFunction, Stream* stream)
+{
+ ConditionFunction* self = (ConditionFunction*)conditionFunction;
+
+ /* Set the Journal for printing informations */
+ Stream* conditionFunctionStream = stream;
+
+ /* General info */
+ Journal_Printf( conditionFunctionStream, "ConditionFunction (ptr): %p\n", self);
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+ Journal_Printf( conditionFunctionStream, "\tapply (func ptr): %p\n", self->apply);
+ Journal_Printf( conditionFunctionStream, "\tname (ptr): %p\n", self->name);
+ if (self->name)
+ Journal_Printf( conditionFunctionStream, "\t\tname: %s\n", self->name);
+
+ /* Print parent class */
+ _Stg_Class_Print( self, conditionFunctionStream );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Macros
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Build functions
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Functions
+*/
+
+void _ConditionFunction_Apply(void* conditionFunction, Index index, Variable_Index var_I, void* context, void* result)
+{
+ ConditionFunction* self = (ConditionFunction*)conditionFunction;
+
+ ConditionFunction_Apply(self, index, var_I, context, result);
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/ConditionFunction.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/ConditionFunction.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,129 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+** Abstract class faciliting the Boundary Condition definition of this system.
+** Meshs should only reference this... the base class, not the implementations.
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: ConditionFunction.h 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Base_Context_ConditionFunction_h__
+#define __StGermain_Base_Context_ConditionFunction_h__
+
+
+ typedef void (ConditionFunction_ApplyFunc) (Index index, Variable_Index var_I, void* context, void* result);
+
+
+ extern const Type ConditionFunction_Type;
+
+
+ #define __ConditionFunction \
+ /* General info */ \
+ __Stg_Class \
+ \
+ /* Virtual info */ \
+ \
+ /* Stg_Class info */ \
+ Dictionary* dictionary; \
+ ConditionFunction_ApplyFunc* apply; \
+ Name name; \
+
+ struct _ConditionFunction { __ConditionFunction };
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructor
+ */
+
+ ConditionFunction* ConditionFunction_New(ConditionFunction_ApplyFunc* apply, Name name);
+
+ void ConditionFunction_Init(ConditionFunction* self, ConditionFunction_ApplyFunc* apply, Name name);
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define CONDITIONFUNCTION_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ ConditionFunction_ApplyFunc* apply, \
+ Name name
+
+ #define CONDITIONFUNCTION_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ apply, \
+ name
+
+ ConditionFunction* _ConditionFunction_New( CONDITIONFUNCTION_DEFARGS );
+
+ void _ConditionFunction_Init(void* conditionFunction, ConditionFunction_ApplyFunc* apply, Name name);
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** General virtual functions
+ */
+
+ void _ConditionFunction_Delete(void* conditionFunction);
+
+ void _ConditionFunction_Print(void* conditionFunction, Stream* stream);
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Macros
+ */
+
+ #define ConditionFunction_Apply(self, index, var_I, context, result) \
+ (self)->apply((index), (var_I), (context), (result))
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Build functions
+ */
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Functions
+ */
+
+ /* Apply the condition function */
+ void _ConditionFunction_Apply(void* conditionFunction, Index index, Variable_Index var_I, void* context, void* result);
+
+
+#endif /* __StGermain_Base_Context_ConditionFunction_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/ConditionFunction_Register.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/ConditionFunction_Register.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,225 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: ConditionFunction_Register.c 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+
+#include "types.h"
+#include "ConditionFunction.h"
+#include "ConditionFunction_Register.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+
+const Type ConditionFunction_Register_Type = "ConditionFunction_Register";
+
+ConditionFunction_Register* condFunc_Register = 0;
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Constructor
+*/
+
+ConditionFunction_Register* ConditionFunction_Register_New(void)
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ConditionFunction_Register);
+ Type type = ConditionFunction_Register_Type;
+ Stg_Class_DeleteFunction* _delete = _ConditionFunction_Register_Delete;
+ Stg_Class_PrintFunction* _print = _ConditionFunction_Register_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ return _ConditionFunction_Register_New( CONDITIONFUNCTION_REGISTER_PASSARGS );
+}
+
+
+void ConditionFunction_Register_Init(ConditionFunction_Register* self)
+{
+ /* General info */
+ self->type = ConditionFunction_Register_Type;
+ self->_sizeOfSelf = sizeof(ConditionFunction_Register);
+ self->_deleteSelf = False;
+
+ /* Virtual info */
+ self->_delete = _ConditionFunction_Register_Delete;
+ self->_print = _ConditionFunction_Register_Print;
+ self->_copy = NULL;
+
+ _Stg_Class_Init((Stg_Class*)self);
+
+ /* Stg_Class info */
+ _ConditionFunction_Register_Init(self);
+}
+
+
+ConditionFunction_Register* _ConditionFunction_Register_New( CONDITIONFUNCTION_REGISTER_DEFARGS )
+{
+ ConditionFunction_Register* self;
+
+ /* Allocate memory */
+ self = (ConditionFunction_Register*)_Stg_Class_New( STG_CLASS_PASSARGS );
+
+ /* Virtual info */
+
+ /* ConditionFunction_Register info */
+ _ConditionFunction_Register_Init(self);
+
+ return self;
+}
+
+
+void _ConditionFunction_Register_Init(void* conditionFunction_Register)
+{
+ ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
+
+ self->count = 0;
+ self->_size = 8;
+ self->_delta = 8;
+ self->_cf = Memory_Alloc_Array( ConditionFunction*, self->_size, "ConditionFunction_Register->_cf" );
+ memset(self->_cf, 0, sizeof(ConditionFunction*)*self->_size);
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** General virtual functions
+*/
+
+void _ConditionFunction_Register_Delete(void* conditionFunction_Register)
+{
+ ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
+
+ if (self->_cf) Memory_Free(self->_cf);
+
+ /* Stg_Class_Delete parent class */
+ _Stg_Class_Delete(self);
+}
+
+
+void _ConditionFunction_Register_Print(void* conditionFunction_Register, Stream* stream)
+{
+ ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
+
+ /* Set the Journal for printing informations */
+ Stream* conditionFunction_RegisterStream = stream;
+
+ /* General info */
+ Journal_Printf( conditionFunction_RegisterStream, "ConditionFunction_Register (ptr): %p\n", self);
+
+ /* Virtual info */
+
+ /* ConditionFunction_Register info */
+ Journal_Printf( conditionFunction_RegisterStream, "\tcount: %u\n", self->count);
+ Journal_Printf( conditionFunction_RegisterStream, "\t_size: %lu\n", self->_size);
+ Journal_Printf( conditionFunction_RegisterStream, "\t_delta: %lu\n", self->_delta);
+ Journal_Printf( conditionFunction_RegisterStream, "\t_cf (ptr): %p\n", self->_cf);
+ if (self->_cf)
+ {
+ ConditionFunction_Index cf_I;
+
+ for (cf_I = 0; cf_I < self->count; cf_I++)
+ Journal_Printf( conditionFunction_RegisterStream, "\t\t_cf[%u]: %p\n", cf_I, self->_cf[cf_I]);
+ }
+
+ /* Parent class info */
+ _Stg_Class_Print( self, conditionFunction_RegisterStream );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Macros
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Build functions
+*/
+
+ConditionFunction_Index ConditionFunction_Register_Add(void* conditionFunction_Register, ConditionFunction* cf)
+{
+ ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
+ Variable_Index handle;
+
+ if (self->count >= self->_size)
+ {
+ SizeT currentSize = self->_size;
+
+ /* Note: why is realloc not used here? */
+ self->_size += self->_delta;
+
+ self->_cf = Memory_Realloc_Array( self->_cf, ConditionFunction*, self->_size );
+ memset( (Pointer)((ArithPointer)self->_cf + (sizeof(ConditionFunction*) * currentSize) ),
+ 0, sizeof(ConditionFunction*) * (self->_size - currentSize) );
+ }
+
+ handle = self->count++;
+ self->_cf[handle] = cf;
+
+ return handle;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Functions
+*/
+
+ConditionFunction_Index ConditionFunction_Register_GetIndex(void* conditionFunction_Register, Name name)
+{
+ ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
+ ConditionFunction_Index cf_I;
+
+ for (cf_I = 0; cf_I < self->count; cf_I++)
+ {
+ if (self->_cf[cf_I]->name && !strcmp(name, self->_cf[cf_I]->name))
+ return cf_I;
+ }
+
+ return (ConditionFunction_Index)-1;
+}
+
+
+void ConditionFunction_Register_PrintNameOfEachFunc( void* conditionFunction_Register, Stream* stream ) {
+ ConditionFunction_Register* self = (ConditionFunction_Register*)conditionFunction_Register;
+ ConditionFunction_Index cf_I;
+
+ for (cf_I = 0; cf_I < self->count; cf_I++)
+ {
+ Journal_Printf( stream, "\"%s\", ", self->_cf[cf_I]->name );
+ }
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/ConditionFunction_Register.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/ConditionFunction_Register.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,129 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+** Instantiates the ConditionFunction_Register such that there is only one set of DOF descriptions (for example, all the nodes have the same
+** DOF configuration).
+**
+** Assumptions:
+** All "adding" is done before the ConditionFunction_Register_Build(...), which will be done in the mesh's initialisation.
+**
+** Comments:
+** You "add" DOF descriptors by using the ConditionFunction_Register_Add( variable_Register, name, offset ), where the "name" is the
+** textual name for the DOF that will be used in the I/O of the DOF (e.g. for initial and boundary conditions), and "offset" is
+** the memory offset of the DOF in the construct that it will be used (e.g. node.vel[0]-node ).
+**
+** $Id: ConditionFunction_Register.h 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Base_Context_ConditionFunction_Register_h__
+#define __StGermain_Base_Context_ConditionFunction_Register_h__
+
+
+ extern const Type ConditionFunction_Register_Type;
+
+ /* Global default instantiation of the register, created in Init.c */
+ extern ConditionFunction_Register* condFunc_Register;
+
+ #define __ConditionFunction_Register \
+ /* General info */ \
+ __Stg_Class \
+ \
+ /* Virtual info */ \
+ \
+ /* Stg_Class info */ \
+ ConditionFunction_Index count; \
+ SizeT _size; \
+ SizeT _delta; \
+ ConditionFunction** _cf; \
+
+ struct _ConditionFunction_Register { __ConditionFunction_Register };
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructor
+ */
+
+ ConditionFunction_Register* ConditionFunction_Register_New(void);
+
+ void ConditionFunction_Register_Init(ConditionFunction_Register* self);
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define CONDITIONFUNCTION_REGISTER_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define CONDITIONFUNCTION_REGISTER_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ ConditionFunction_Register* _ConditionFunction_Register_New( CONDITIONFUNCTION_REGISTER_DEFARGS );
+
+ void _ConditionFunction_Register_Init(void* conditionFunction_Register);
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** General virtual functions
+ */
+
+ void _ConditionFunction_Register_Delete( void* conditionFunction_Register );
+
+ void _ConditionFunction_Register_Print( void* conditionFunction_Register, Stream* stream );
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Macros
+ */
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Build functions
+ */
+
+ ConditionFunction_Index ConditionFunction_Register_Add(void* conditionFunction_Register, ConditionFunction* cf);
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Functions
+ */
+
+ ConditionFunction_Index ConditionFunction_Register_GetIndex(void* conditionFunction_Register, Name name);
+
+ void ConditionFunction_Register_PrintNameOfEachFunc( void* conditionFunction_Register, Stream* stream );
+
+
+#endif /* __StGermain_Base_Context_ConditionFunction_Register_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Context.h
--- a/Base/Context/src/Context.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/Context.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,16 +39,28 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Context_h__
-#define __Base_Context_h__
+#ifndef __StGermain_Base_Context_h__
+#define __StGermain_Base_Context_h__
#include "units.h"
#include "types.h"
#include "shortcuts.h"
+ #include "Codelet.h"
+ #include "Variable.h"
+ #include "Variable_Register.h"
+ #include "VariableCondition.h"
+ #include "VariableCondition_Register.h"
+ #include "ConditionFunction.h"
+ #include "ConditionFunction_Register.h"
+ #include "CompositeVC.h"
+ #include "DynamicVC.h"
+ #include "VariableAllVC.h"
+ #include "SetVC.h"
+ #include "VariableDumpStream.h"
#include "ContextEntryPoint.h"
#include "AbstractContext.h"
#include "Init.h"
#include "Finalise.h"
#include "DictionaryCheck.h"
-#endif /* __Base_Context_h__ */
+#endif /* __StGermain_Base_Context_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/ContextEntryPoint.c
--- a/Base/Context/src/ContextEntryPoint.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/ContextEntryPoint.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,8 +51,18 @@ const Type ContextEntryPoint_Type = "Con
ContextEntryPoint* ContextEntryPoint_New( const Name name, unsigned int castType ) {
- return _ContextEntryPoint_New( sizeof(ContextEntryPoint), ContextEntryPoint_Type, _EntryPoint_Delete,
- _EntryPoint_Print, NULL, _ContextEntryPoint_GetRun, name, castType );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ContextEntryPoint);
+ Type type = ContextEntryPoint_Type;
+ Stg_Class_DeleteFunction* _delete = _EntryPoint_Delete;
+ Stg_Class_PrintFunction* _print = _EntryPoint_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ EntryPoint_GetRunFunction* _getRun = _ContextEntryPoint_GetRun;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _ContextEntryPoint_New( CONTEXTENTRYPOINT_PASSARGS );
}
void ContextEntryPoint_Init( void* contextEntryPoint, Name name, unsigned int castType ) {
@@ -76,22 +86,13 @@ void ContextEntryPoint_Init( void* conte
_ContextEntryPoint_Init( self );
}
-ContextEntryPoint* _ContextEntryPoint_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- EntryPoint_GetRunFunction* _getRun,
- Name name,
- unsigned int castType )
+ContextEntryPoint* _ContextEntryPoint_New( CONTEXTENTRYPOINT_DEFARGS )
{
ContextEntryPoint* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(ContextEntryPoint) );
- self = (ContextEntryPoint*)_EntryPoint_New( _sizeOfSelf, type, _delete, _print, _copy,
- _getRun, name, castType );
+ self = (ContextEntryPoint*)_EntryPoint_New( ENTRYPOINT_PASSARGS );
/* General info */
@@ -163,3 +164,5 @@ void _ContextEntryPoint_Run_Step( void*
#endif
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/ContextEntryPoint.h
--- a/Base/Context/src/ContextEntryPoint.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/ContextEntryPoint.h Tue Jan 12 14:38:16 2010 +1100
@@ -37,8 +37,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Context_ContextEntryPoint_h__
-#define __Base_Context_ContextEntryPoint_h__
+#ifndef __StGermain_Base_Context_ContextEntryPoint_h__
+#define __StGermain_Base_Context_ContextEntryPoint_h__
/* Templates for default entry point type */
typedef double (ContextEntryPoint_Dt_Cast) ( void* context );
@@ -69,15 +69,18 @@
void ContextEntryPoint_Init( void* contextEntryPoint, Name name, unsigned int castType );
/* Creation implementation */
- ContextEntryPoint* _ContextEntryPoint_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- EntryPoint_GetRunFunction* _getRun,
- Name name,
- unsigned int castType );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define CONTEXTENTRYPOINT_DEFARGS \
+ ENTRYPOINT_DEFARGS
+
+ #define CONTEXTENTRYPOINT_PASSARGS \
+ ENTRYPOINT_PASSARGS
+
+ ContextEntryPoint* _ContextEntryPoint_New( CONTEXTENTRYPOINT_DEFARGS );
/* Initialisation implementation */
void _ContextEntryPoint_Init( ContextEntryPoint* self );
@@ -92,4 +95,5 @@
/* Context entry point run... one void* arguement passed, one double arguement passed */
void _ContextEntryPoint_Run_Step( void* contextEntryPoint, void* data0, double data1 );
-#endif /* __Base_Context_ContextEntryPoint_h__ */
+#endif /* __StGermain_Base_Context_ContextEntryPoint_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/DictionaryCheck.c
--- a/Base/Context/src/DictionaryCheck.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/DictionaryCheck.c Tue Jan 12 14:38:16 2010 +1100
@@ -127,3 +127,5 @@ void CheckDictionaryKeys( Dictionary* di
}
Memory_Free(keyIndexArray);
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/DictionaryCheck.h
--- a/Base/Context/src/DictionaryCheck.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/DictionaryCheck.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,11 +38,11 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_BaseContext_DictionaryCheck_h__
-#define __Base_BaseContext_DictionaryCheck_h__
+#ifndef __StGermain_Base_Context_DictionaryCheck_h__
+#define __StGermain_Base_Context_DictionaryCheck_h__
- void BaseContext_DictionaryCheck( Dictionary* dictionary );
+ void Context_DictionaryCheck( Dictionary* dictionary );
void CheckDictionaryKeys(Dictionary* dictionary, const char* errorMessage);
-#endif /* __Base_BaseContext_DictionaryCheck_h__ */
+#endif /* __StGermain_Base_Context_DictionaryCheck_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/DynamicVC.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/DynamicVC.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,338 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: DynamicVC.c 3881 2006-10-26 03:14:19Z KathleenHumble $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+#include "Base/Automation/Automation.h"
+#include "Base/Extensibility/Extensibility.h"
+
+#include "types.h"
+#include "shortcuts.h"
+#include "Variable.h"
+#include "Variable_Register.h"
+#include "ConditionFunction.h"
+#include "ConditionFunction_Register.h"
+#include "VariableCondition.h"
+#include "DynamicVC.h"
+
+#include <string.h>
+#include <assert.h>
+
+const Type DynamicVC_Type = "DynamicVC";
+const Name defaultDynamicVCName = "defaultDynamicVCName";
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Constructor
+*/
+
+VariableCondition* DynamicVC_Factory(
+ AbstractContext* context,
+ Variable_Register* varReg,
+ ConditionFunction_Register* conFuncReg,
+ Dictionary* dict,
+ void* data )
+{
+ return (VariableCondition*)DynamicVC_New( defaultDynamicVCName, context, varReg, conFuncReg, dict );
+}
+
+DynamicVC* DynamicVC_New(
+ Name name,
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary )
+{
+ DynamicVC* self = _DynamicVC_DefaultNew( name );
+
+ self->isConstructed = True;
+ _VariableCondition_Init( self, context, variable_Register, conFunc_Register, dictionary );
+ _DynamicVC_Init( self );
+
+ return self;
+}
+
+DynamicVC* _DynamicVC_DefaultNew( Name name ) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(DynamicVC);
+ Type type = DynamicVC_Type;
+ Stg_Class_DeleteFunction* _delete = _DynamicVC_Delete;
+ Stg_Class_PrintFunction* _print = _DynamicVC_Print;
+ Stg_Class_CopyFunction* _copy = _DynamicVC_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = (Stg_Component_DefaultConstructorFunction*)_DynamicVC_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _VariableCondition_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _VariableCondition_Build;
+ Stg_Component_InitialiseFunction* _initialise = _VariableCondition_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _VariableCondition_Execute;
+ Stg_Component_DestroyFunction* _destroy = _VariableCondition_Destroy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+ VariableCondition_BuildSelfFunc* _buildSelf = NULL;
+ VariableCondition_PrintConciseFunc* _printConcise = _DynamicVC_PrintConcise;
+ VariableCondition_ReadDictionaryFunc* _readDictionary = _DynamicVC_ReadDictionary;
+ VariableCondition_GetSetFunc* _getSet = _DynamicVC_GetSet;
+ VariableCondition_GetVariableCountFunc* _getVariableCount = _DynamicVC_GetVariableCount;
+ VariableCondition_GetVariableIndexFunc* _getVariableIndex = _DynamicVC_GetVariableIndex;
+ VariableCondition_GetValueIndexFunc* _getValueIndex = _DynamicVC_GetValueIndex;
+ VariableCondition_GetValueCountFunc* _getValueCount = _DynamicVC_GetValueCount;
+ VariableCondition_GetValueFunc* _getValue = _DynamicVC_GetValue;
+ VariableCondition_ApplyFunc* _apply = DynamicVC_Apply;
+
+ return (DynamicVC*)_DynamicVC_New( DYNAMICVC_PASSARGS );
+}
+
+DynamicVC* _DynamicVC_New( DYNAMICVC_DEFARGS ) {
+ DynamicVC* self;
+
+ /* Allocate memory/General info */
+ assert( _sizeOfSelf >= sizeof(DynamicVC) );
+ self = (DynamicVC*)_VariableCondition_New( VARIABLECONDITION_PASSARGS );
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+
+ return self;
+}
+
+void _DynamicVC_Init( void* vc ) {
+ DynamicVC* self = (DynamicVC*)vc;
+
+ assert( self );
+ self->vcMap = IMap_New();
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** General virtual functions
+*/
+
+void _DynamicVC_AssignFromXML( void* vc, Stg_ComponentFactory* cf, void* data ) {
+}
+
+void _DynamicVC_Build( void* vc, void* data ) {
+}
+
+void _DynamicVC_Initialise( void* vc, void* data ) {
+}
+
+void _DynamicVC_Execute( void* vc, void* data ) {
+}
+
+void _DynamicVC_Destroy( void* vc, void* data ) {
+ DynamicVC* self = (DynamicVC*)vc;
+
+ NewClass_Delete( self->vcMap );
+
+ _VariableCondition_Destroy( self, data );
+}
+
+void _DynamicVC_ReadDictionary( void* vc, void* dict ) {
+}
+
+void _DynamicVC_Delete( void* vc ) {
+ DynamicVC* self = (DynamicVC*)vc;
+
+ /* Stg_Class_Delete parent */
+ _VariableCondition_Delete( self );
+}
+
+void _DynamicVC_Print( void* vc, Stream* stream ) {
+ _VariableCondition_Print( vc );
+}
+
+void* _DynamicVC_Copy( void* vc, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
+ return NULL;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Macros
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+IndexSet* _DynamicVC_GetSet( void* vc ) {
+ return NULL;
+}
+
+VariableCondition_VariableIndex _DynamicVC_GetVariableCount( void* vc, Index globalIndex ) {
+ return 0;
+}
+
+Variable_Index _DynamicVC_GetVariableIndex( void* vc, Index globalIndex, VariableCondition_VariableIndex varIndex ) {
+ return 0;
+}
+
+VariableCondition_ValueIndex _DynamicVC_GetValueIndex( void* vc,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex )
+{
+ return 0;
+}
+
+VariableCondition_ValueIndex _DynamicVC_GetValueCount( void* vc ) {
+ return 0;
+}
+
+VariableCondition_Value _DynamicVC_GetValue( void* vc, VariableCondition_ValueIndex valIndex ) {
+ VariableCondition_Value val;
+
+ val.type = VC_ValueType_Double;
+ val.as.typeDouble = 0.0;
+ return val;
+}
+
+void _DynamicVC_PrintConcise( void* vc, Stream* stream ) {
+}
+
+void DynamicVC_Apply( void* vc, void* ctx ) {
+ DynamicVC* self = (DynamicVC*)vc;
+ IMapIter* iter;
+ int ind, valInd, varInd;
+ VariableCondition_Value* val;
+ ConditionFunction* cf;
+ Stream *errorStrm = Journal_Register( Error_Type, self->type );
+
+ varInd = Variable_Register_GetIndex( self->variable_Register, self->var->name );
+ iter = IMapIter_New();
+ for( IMap_First( self->vcMap, iter );
+ Iter_IsValid( iter );
+ IMapIter_Next( iter ) )
+ {
+ ind = IMapIter_GetKey( iter );
+ valInd = IMapIter_GetValue( iter );
+ val = self->valueTbl + valInd;
+ switch( val->type ) {
+ case VC_ValueType_Double:
+ Journal_Firewall( self->var->dataTypeCounts[0] == 1, errorStrm,
+ "Error - in %s: while applying values for variable condition "
+ "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
+ "which has %d components. Specify a scalar Variable instead.\n",
+ __func__, self->name, ind, "double",
+ self->var->name, self->var->dataTypeCounts[0] );
+ Variable_SetValueDouble( self->var,
+ ind,
+ val->as.typeDouble );
+ break;
+
+ case VC_ValueType_DoubleArray:
+ Variable_SetValue( self->var,
+ ind,
+ val->as.typeArray.array );
+ break;
+
+ case VC_ValueType_CFIndex:
+ Journal_Firewall( val->as.typeCFIndex != (unsigned)-1, errorStrm,
+ "Error - in %s: trying to apply to index %d of variable \"%s\", which "
+ "is supposed to be a condition function, but the cond. func. wasn't "
+ "found in the c.f. register.\n", __func__, ind, self->var->name );
+ cf = self->conFunc_Register->_cf[val->as.typeCFIndex];
+ ConditionFunction_Apply( cf,
+ ind,
+ varInd,
+ ctx,
+ Variable_GetStructPtr( self->var, ind ) );
+ break;
+
+ default:
+ assert( 0 );
+ break;
+ }
+ }
+ NewClass_Delete( iter );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Build functions
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Functions
+*/
+
+void DynamicVC_SetVariable( void* vc, Variable* var ) {
+ DynamicVC* self = (DynamicVC*)vc;
+
+ assert( self );
+ self->var = var;
+}
+
+void DynamicVC_SetMaxEntries( void* vc, int maxEntries ) {
+ DynamicVC* self = (DynamicVC*)vc;
+
+ assert( self );
+ /*IMap_Clear( self->vcMap );*/
+ IMap_SetMaxSize( self->vcMap, maxEntries );
+}
+
+int DynamicVC_GetMaxEntries( void* vc ) {
+ DynamicVC* self = (DynamicVC*)vc;
+
+ return IMap_GetMaxSize( self->vcMap );
+}
+
+void DynamicVC_SetValues( void* vc, int nVals, VariableCondition_Value* vals ) {
+ DynamicVC* self = (DynamicVC*)vc;
+
+ assert( self );
+ self->valueCount = nVals;
+ self->valueTbl = MemRearray( self->valueTbl, VariableCondition_Value, nVals, DynamicVC_Type );
+ memcpy( self->valueTbl, vals, nVals * sizeof(VariableCondition_Value) );
+}
+
+void DynamicVC_Insert( void* vc, int index, int valIndex ) {
+ DynamicVC* self = (DynamicVC*)vc;
+
+ assert( self );
+ if( !IMap_Has( self->vcMap, index ) )
+ IMap_Insert( self->vcMap, index, valIndex );
+}
+
+void DynamicVC_Remove( void* vc, int index ) {
+ DynamicVC* self = (DynamicVC*)vc;
+
+ assert( self );
+ if( IMap_Has( self->vcMap, index ) )
+ IMap_Remove( self->vcMap, index );
+}
+
+Bool DynamicVC_Has( void* _self, int index ) {
+ DynamicVC* self = (DynamicVC*)_self;
+
+ assert( self );
+ return IMap_Has( self->vcMap, index );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/DynamicVC.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/DynamicVC.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,163 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: DynamicVC.h 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Base_Context_DynamicVC_h__
+#define __StGermain_Base_Context_DynamicVC_h__
+
+extern const Type DynamicVC_Type;
+
+#define __DynamicVC \
+ /* General info */ \
+ __VariableCondition \
+ \
+ /* Virtual info */ \
+ \
+ /* Stg_Class info */ \
+ Variable* var; \
+ IMap* vcMap;
+
+ struct DynamicVC { __DynamicVC };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructor
+ */
+
+ VariableCondition* DynamicVC_Factory(
+ AbstractContext* context,
+ Variable_Register* varReg,
+ ConditionFunction_Register* conFuncReg,
+ Dictionary* dict,
+ void* data );
+
+ DynamicVC* DynamicVC_New(
+ Name name,
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dict );
+
+ DynamicVC* _DynamicVC_DefaultNew( Name name );
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define DYNAMICVC_DEFARGS \
+ VARIABLECONDITION_DEFARGS
+
+ #define DYNAMICVC_PASSARGS \
+ VARIABLECONDITION_PASSARGS
+
+ DynamicVC* _DynamicVC_New( DYNAMICVC_DEFARGS );
+
+ void _DynamicVC_Init( void* vc );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** General virtual functions
+ */
+
+ void _DynamicVC_Delete( void* vc );
+ void _DynamicVC_Print( void* vc, Stream* stream );
+
+ /* Copy */
+ #define DynamicVC_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+ #define DynamicVC_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+
+ void* _DynamicVC_Copy( void* vc, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
+
+ void _DynamicVC_AssignFromXML( void* vc, Stg_ComponentFactory* cf, void* data );
+
+ void _DynamicVC_Build( void* vc, void* data );
+
+ void _DynamicVC_Initialise( void* vc, void* data );
+
+ void _DynamicVC_Execute( void* vc, void* data );
+
+ void _DynamicVC_Destroy( void* vc, void* data );
+
+ void _DynamicVC_ReadDictionary( void* vc, void* dict );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Macros
+ */
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _DynamicVC_ReadDictionary( void* vc, void* dict );
+
+ IndexSet* _DynamicVC_GetSet( void* vc );
+
+ VariableCondition_VariableIndex _DynamicVC_GetVariableCount( void* vc, Index globalIndex );
+
+ Variable_Index _DynamicVC_GetVariableIndex( void* vc,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex );
+
+ VariableCondition_ValueIndex _DynamicVC_GetValueIndex( void* vc,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex );
+
+ VariableCondition_ValueIndex _DynamicVC_GetValueCount( void* vc );
+
+ VariableCondition_Value _DynamicVC_GetValue( void* vc, VariableCondition_ValueIndex valIndex );
+
+ void _DynamicVC_PrintConcise( void* vc, Stream* stream );
+
+ void DynamicVC_Apply( void* vc, void* ctx );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Build functions
+ */
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Functions
+ */
+
+ void DynamicVC_SetVariable( void* vc, Variable* var );
+ void DynamicVC_SetMaxEntries( void* vc, int maxEntries );
+ int DynamicVC_GetMaxEntries( void* vc );
+ void DynamicVC_SetValues( void* vc, int nVals, VariableCondition_Value* vals );
+ void DynamicVC_Insert( void* vc, int index, int valIndex );
+ void DynamicVC_Remove( void* vc, int index );
+ Bool DynamicVC_Has( void* _self, int index );
+
+#endif /* __StGermain_Base_Context_DynamicVC_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/DynamicVC.meta
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/DynamicVC.meta Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">DynamicVC</param>
+<param name="Author">...</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StGermain</param>
+<param name="Location">./StGermain/Base/Context/src/</param>
+<param name="Project Web">http://www.stgermainproject.org/</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
+<param name="Parent">VariableCondition</param>
+<param name="Reference">...</param>
+<param name="Summary">...</param>
+
+<param name="Description">
+ DynamicVC provides a mechanism to set and remove variable conditions during run-time.
+ It is not intended for use through XML, but instead should be instantiated and
+ manipulated by other components internally.
+</param>
+
+<list name="Params">
+ n/a
+</list>
+
+<list name="Dependencies">
+ n/a
+ </list>
+
+<param name="Example">
+ n/a
+</param>
+
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Finalise.c
--- a/Base/Context/src/Finalise.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/Finalise.c Tue Jan 12 14:38:16 2010 +1100
@@ -36,6 +36,10 @@
#include "Base/Extensibility/Extensibility.h"
#include "types.h"
+#include "VariableCondition.h"
+#include "VariableCondition_Register.h"
+#include "ConditionFunction_Register.h"
+#include "CompositeVC.h"
#include "Finalise.h"
#include <stdio.h>
@@ -43,5 +47,10 @@ Bool BaseContext_Finalise( void ) {
Bool BaseContext_Finalise( void ) {
Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
+ Stg_Class_Delete( condFunc_Register );
+ Stg_Class_Delete( variableCondition_Register );
+
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Finalise.h
--- a/Base/Context/src/Finalise.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/Finalise.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,9 +38,9 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_BaseContext_Finalise_h__
-#define __Base_BaseContext_Finalise_h__
+#ifndef __StGermain_Base_Context_Finalise_h__
+#define __StGermain_Base_Context_Finalise_h__
- Bool BaseContext_Finalise( void );
+ Bool Context_Finalise( void );
-#endif /* __Base_BaseContext_Finalise_h__ */
+#endif /* __StGermain_Base_Context_Finalise_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Init.c
--- a/Base/Context/src/Init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/Init.c Tue Jan 12 14:38:16 2010 +1100
@@ -36,17 +36,63 @@
#include "Base/Extensibility/Extensibility.h"
#include "types.h"
-#include "Init.h"
+#include "Variable.h"
+#include "Variable_Register.h"
+#include "VariableCondition.h"
+#include "VariableCondition_Register.h"
+#include "ConditionFunction_Register.h"
+#include "ConditionFunction.h"
+#include "CompositeVC.h"
+#include "DynamicVC.h"
+#include "VariableAllVC.h"
+#include "SetVC.h"
+#include "VariableDumpStream.h"
#include "AbstractContext.h"
#include "ContextEntryPoint.h"
+#include "Init.h"
#include <stdio.h>
Bool BaseContext_Init( int* argc, char** argv[] ) {
+ Stream* typedStream;
+
Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
- RegisterParent( AbstractContext_Type, Stg_Component_Type );
+ condFunc_Register = ConditionFunction_Register_New();
+ variableCondition_Register = VariableCondition_Register_New();
+ VariableCondition_Register_Add( variableCondition_Register, SetVC_Type, SetVC_Factory );
+ VariableCondition_Register_Add( variableCondition_Register, CompositeVC_Type, CompositeVC_Factory );
+ VariableCondition_Register_Add( variableCondition_Register, VariableAllVC_Type, VariableAllVC_Factory );
+
+ typedStream = VariableDumpStream_New( VariableDumpStream_Type );
+ Stream_Enable( typedStream, True );
+ Stream_SetLevel( typedStream, 1 );
+ Stream_SetFile( typedStream, stJournal->stdOut );
+
+ Journal_RegisterTypedStream( typedStream );
+
+ /** Adding default constructors of various components to the Stg_ComponentRegister */
+ Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), Variable_Type, "0", (Stg_Component_DefaultConstructorFunction*)_Variable_DefaultNew );
+ Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), CompositeVC_Type, "0", (Stg_Component_DefaultConstructorFunction*)_CompositeVC_DefaultNew );
+ Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), SetVC_Type, "0", (Stg_Component_DefaultConstructorFunction*)_SetVC_DefaultNew );
+ Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), VariableAllVC_Type, "0", (Stg_Component_DefaultConstructorFunction*)_VariableAllVC_DefaultNew );
+ Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), DynamicVC_Type, "0", (Stg_Component_DefaultConstructorFunction*)_DynamicVC_DefaultNew );
+
+ /** Register Parents for All Classes */
+ RegisterParent( Variable_Type, Stg_Component_Type );
+ RegisterParent( VariableCondition_Register_Type, Stg_Class_Type );
+ RegisterParent( VariableDumpStream_Type, CStream_Type );
+ RegisterParent( Variable_Register_Type, Stg_Class_Type );
+ RegisterParent( VariableCondition_Type, Stg_Component_Type );
+ RegisterParent( ConditionFunction_Type, Stg_Class_Type );
+ RegisterParent( ConditionFunction_Register_Type, Stg_Class_Type );
+ RegisterParent( CompositeVC_Type, VariableCondition_Type );
+ RegisterParent( DynamicVC_Type, VariableCondition_Type );
+ RegisterParent( VariableAllVC_Type, VariableCondition_Type );
+ RegisterParent( AbstractContext_Type, Stg_Component_Type );
RegisterParent( ContextEntryPoint_Type, EntryPoint_Type );
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Init.h
--- a/Base/Context/src/Init.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/Init.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,9 +39,9 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_BaseContext_Init_h__
-#define __Base_BaseContext_Init_h__
+#ifndef __StGermain_Base_Context_Init_h__
+#define __StGermain_Base_Context_Init_h__
- Bool BaseContext_Init( int* argc, char** argv[] );
+ Bool Context_Init( int* argc, char** argv[] );
-#endif /* __Base_BaseContext_Init_h__ */
+#endif /* __StGermain_Base_Context_Init_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/SetVC.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/SetVC.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,443 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: SetVC.c 4153 2007-07-26 02:25:22Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+#include "Base/Automation/Automation.h"
+#include "Base/Extensibility/Extensibility.h"
+
+#include "types.h"
+#include "shortcuts.h"
+#include "Variable.h"
+#include "Variable_Register.h"
+#include "ConditionFunction.h"
+#include "ConditionFunction_Register.h"
+#include "VariableCondition.h"
+#include "SetVC.h"
+
+#include <string.h>
+#include <assert.h>
+
+
+const Type SetVC_Type = "SetVC";
+const Name defaultSetVCName = "defaultSetVCName";
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Constructor
+*/
+
+VariableCondition* SetVC_Factory(
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data )
+{
+ return (VariableCondition*)SetVC_New( defaultSetVCName, context, NULL, variable_Register, conFunc_Register, dictionary );
+}
+
+SetVC* SetVC_New(
+ Name name,
+ AbstractContext* context,
+ Name _dictionaryEntryName,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary )
+{
+ SetVC* self = _SetVC_DefaultNew( name );
+
+ self->isConstructed = True;
+ _VariableCondition_Init( self, context, variable_Register, conFunc_Register, dictionary );
+ _SetVC_Init( self, _dictionaryEntryName );
+
+ return self;
+}
+
+SetVC* _SetVC_DefaultNew( Name name ) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(SetVC);
+ Type type = SetVC_Type;
+ Stg_Class_DeleteFunction* _delete = _SetVC_Delete;
+ Stg_Class_PrintFunction* _print = _SetVC_Print;
+ Stg_Class_CopyFunction* _copy = _SetVC_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = (Stg_Component_DefaultConstructorFunction*)_SetVC_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _VariableCondition_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _VariableCondition_Build;
+ Stg_Component_InitialiseFunction* _initialise = _VariableCondition_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _VariableCondition_Execute;
+ Stg_Component_DestroyFunction* _destroy = _SetVC_Destroy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+ VariableCondition_BuildSelfFunc* _buildSelf = NULL;
+ VariableCondition_PrintConciseFunc* _printConcise = _SetVC_PrintConcise;
+ VariableCondition_ReadDictionaryFunc* _readDictionary = _SetVC_ReadDictionary;
+ VariableCondition_GetSetFunc* _getSet = _SetVC_GetSet;
+ VariableCondition_GetVariableCountFunc* _getVariableCount = _SetVC_GetVariableCount;
+ VariableCondition_GetVariableIndexFunc* _getVariableIndex = _SetVC_GetVariableIndex;
+ VariableCondition_GetValueIndexFunc* _getValueIndex = _SetVC_GetValueIndex;
+ VariableCondition_GetValueCountFunc* _getValueCount = _SetVC_GetValueCount;
+ VariableCondition_GetValueFunc* _getValue = _SetVC_GetValue;
+ VariableCondition_ApplyFunc* _apply = _VariableCondition_Apply;
+
+ return (SetVC*)_SetVC_New( SETVC_PASSARGS );
+}
+
+SetVC* _SetVC_New( SETVC_DEFARGS ) {
+ SetVC* self;
+
+ /* Allocate memory/General info */
+ assert( _sizeOfSelf >= sizeof(SetVC) );
+ self = (SetVC*)_VariableCondition_New( VARIABLECONDITION_PASSARGS );
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+
+ return self;
+}
+
+void _SetVC_Init( void* setVC, Name _dictionaryEntryName ) {
+ SetVC* self = (SetVC*)setVC;
+
+ self->_dictionaryEntryName = _dictionaryEntryName;
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** General virtual functions
+*/
+
+void _SetVC_ReadDictionary( void* setVC, void* dictionary ) {
+ SetVC* self = (SetVC*)setVC;
+ Dictionary_Entry_Value* vcDictVal;
+ Dictionary_Entry_Value _vcDictVal;
+ Dictionary_Entry_Value* varsVal;
+ SetVC_Entry_Index entry_I;
+
+
+ /* Find dictionary entry */
+ if (self->_dictionaryEntryName)
+ vcDictVal = Dictionary_Get( dictionary, self->_dictionaryEntryName );
+ else {
+ vcDictVal = &_vcDictVal;
+ Dictionary_Entry_Value_InitFromStruct( vcDictVal, dictionary );
+ }
+
+ if (vcDictVal) {
+ Dictionary_Entry_Value* setVal = Dictionary_Entry_Value_GetMember( vcDictVal, "indices" );
+ Index indexCnt = Dictionary_Entry_Value_AsUnsignedInt(
+ Dictionary_Entry_Value_GetMember( vcDictVal, "indexCount" ) );
+ Index i, cnt;
+
+ self->_vcset = IndexSet_New( indexCnt );
+ cnt = Dictionary_Entry_Value_GetCount( setVal );
+
+ for( i = 0; i < cnt; i++ )
+ IndexSet_Add( self->_vcset, Dictionary_Entry_Value_AsUnsignedInt(
+ Dictionary_Entry_Value_GetElement( setVal, i ) ) );
+
+ /* Obtain the variable entries */
+ varsVal = Dictionary_Entry_Value_GetMember(vcDictVal, "variables");
+ self->_entryCount = Dictionary_Entry_Value_GetCount( varsVal );
+ self->_entryTbl = Memory_Alloc_Array( SetVC_Entry, self->_entryCount, "SetVC->_entryTbl");
+
+ for (entry_I = 0; entry_I < self->_entryCount; entry_I++) {
+ char* valType;
+ Dictionary_Entry_Value* valueEntry;
+ Dictionary_Entry_Value* varDictListVal;
+
+ varDictListVal = Dictionary_Entry_Value_GetElement(varsVal, entry_I);
+ valueEntry = Dictionary_Entry_Value_GetMember(varDictListVal, "value");
+
+ self->_entryTbl[entry_I].varName = Dictionary_Entry_Value_AsString(
+ Dictionary_Entry_Value_GetMember(varDictListVal, "name"));
+
+ valType = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(varDictListVal, "type"));
+
+ if (!strcasecmp(valType, "func")) {
+ char* funcName = Dictionary_Entry_Value_AsString(valueEntry);
+
+ self->_entryTbl[entry_I].value.type = VC_ValueType_CFIndex;
+ self->_entryTbl[entry_I].value.as.typeCFIndex = ConditionFunction_Register_GetIndex(
+ self->conFunc_Register, funcName);
+ }
+ else if (!strcasecmp(valType, "array")) {
+ Dictionary_Entry_Value* valueElement;
+ Index i;
+
+ self->_entryTbl[entry_I].value.type = VC_ValueType_DoubleArray;
+ self->_entryTbl[entry_I].value.as.typeArray.size = Dictionary_Entry_Value_GetCount(valueEntry);
+ self->_entryTbl[entry_I].value.as.typeArray.array = Memory_Alloc_Array( double,
+ self->_entryTbl[entry_I].value.as.typeArray.size, "SetVC->_entryTbl[].value.as.typeArray.array" );
+
+ for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++) {
+ valueElement = Dictionary_Entry_Value_GetElement(valueEntry, i);
+ self->_entryTbl[entry_I].value.as.typeArray.array[i] =
+ Dictionary_Entry_Value_AsDouble(valueElement);
+ }
+ }
+ else if( !strcasecmp( valType, "double" ) || !strcasecmp( valType, "d" ) || !strcasecmp( valType, "float" ) || !strcasecmp( valType, "f" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
+ self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
+ }
+ else if( !strcasecmp( valType, "integer" ) || !strcasecmp( valType, "int" ) || !strcasecmp( valType, "i" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Int;
+ self->_entryTbl[entry_I].value.as.typeInt = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
+ }
+ else if( !strcasecmp( valType, "short" ) || !strcasecmp( valType, "s" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Short;
+ self->_entryTbl[entry_I].value.as.typeShort = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
+ }
+ else if( !strcasecmp( valType, "char" ) || !strcasecmp( valType, "c" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Char;
+ self->_entryTbl[entry_I].value.as.typeChar = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
+ }
+ else if( !strcasecmp( valType, "pointer" ) || !strcasecmp( valType, "ptr" ) || !strcasecmp( valType, "p" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Ptr;
+ self->_entryTbl[entry_I].value.as.typePtr = (void*) ((ArithPointer) Dictionary_Entry_Value_AsUnsignedInt( valueEntry ));
+ }
+ else {
+ /* Assume double */
+ Journal_DPrintf( Journal_Register( InfoStream_Type, "myStream" ),
+ "Type to variable on variable condition not given, assuming double\n" );
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
+ self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
+ }
+ }
+ }
+ else {
+ self->_entryCount = 0;
+ self->_entryTbl = NULL;
+ }
+}
+
+void _SetVC_Delete(void* setVC) {
+ SetVC* self = (SetVC*)setVC;
+
+ /* Stg_Class_Delete parent */
+ _VariableCondition_Delete(self);
+}
+
+void _SetVC_Destroy(void* setVC, void* data) {
+ SetVC* self = (SetVC*)setVC;
+
+ if (self->_entryTbl) Memory_Free( self->_entryTbl );
+
+ _VariableCondition_Destroy( self, data );
+}
+
+void _SetVC_Print(void* setVC, Stream* stream) {
+ SetVC* self = (SetVC*)setVC;
+ SetVC_Entry_Index entry_I;
+ Index i;
+
+ /* Set the Journal for printing informations */
+ Stream* info = stream;
+
+ /* General info */
+ Journal_Printf( info, "SetVC (ptr): %p\n", self);
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+ Journal_Printf( info, "\tdictionary (ptr): %p\n", self->dictionary);
+ Journal_Printf( info, "\t_dictionaryEntryName (ptr): %p\n", self->_dictionaryEntryName);
+ if (self->_dictionaryEntryName)
+ Journal_Printf( info, "\t\t_dictionaryEntryName: %s\n", self->_dictionaryEntryName);
+ Journal_Printf( info, "\t_entryCount: %u\n", self->_entryCount);
+ Journal_Printf( info, "\t_entryTbl (ptr): %p\n", self->_entryTbl);
+ if (self->_entryTbl)
+ for (entry_I = 0; entry_I < self->_entryCount; entry_I++)
+ {
+ Journal_Printf( info, "\t\t_entryTbl[%u]:\n", entry_I);
+ Journal_Printf( info, "\t\t\tvarName (ptr): %p\n", self->_entryTbl[entry_I].varName);
+ if (self->_entryTbl[entry_I].varName)
+ Journal_Printf( info, "\t\t\t\tvarName: %s\n", self->_entryTbl[entry_I].varName);
+ Journal_Printf( info, "\t\t\tvalue:\n");
+ switch (self->_entryTbl[entry_I].value.type)
+ {
+ case VC_ValueType_Double:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Double\n" );
+ Journal_Printf( info, "\t\t\t\tasDouble: %g\n", self->_entryTbl[entry_I].value.as.typeDouble );
+ break;
+
+ case VC_ValueType_Int:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Int\n" );
+ Journal_Printf( info, "\t\t\t\tasInt: %i\n", self->_entryTbl[entry_I].value.as.typeInt );
+ break;
+
+ case VC_ValueType_Short:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Short\n" );
+ Journal_Printf( info, "\t\t\t\tasShort: %i\n", self->_entryTbl[entry_I].value.as.typeShort );
+ break;
+
+ case VC_ValueType_Char:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Char\n");
+ Journal_Printf( info, "\t\t\t\tasChar: %c\n", self->_entryTbl[entry_I].value.as.typeChar );
+ break;
+
+ case VC_ValueType_Ptr:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Ptr\n");
+ Journal_Printf( info, "\t\t\t\tasPtr: %g\n", self->_entryTbl[entry_I].value.as.typePtr );
+ break;
+
+ case VC_ValueType_DoubleArray:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_DoubleArray\n");
+ Journal_Printf( info, "\t\t\t\tarraySize: %u\n", self->_entryTbl[entry_I].value.as.typeArray.size);
+ Journal_Printf( info, "\t\t\t\tasDoubleArray (ptr): %p\n",
+ self->_entryTbl[entry_I].value.as.typeArray.array);
+ if (self->_entryTbl[entry_I].value.as.typeArray.array)
+ for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++)
+ Journal_Printf( info, "\t\t\t\tasDoubleArray[%u]: %g\n", i,
+ self->_entryTbl[entry_I].value.as.typeArray.array[i]);
+ break;
+
+ case VC_ValueType_CFIndex:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_CFIndex\n");
+ Journal_Printf( info, "\t\t\t\tasCFIndex: %u\n", self->_entryTbl[entry_I].value.as.typeCFIndex);
+ break;
+ }
+ }
+
+ /* Print parent */
+ _VariableCondition_Print(self);
+}
+
+
+void* _SetVC_Copy( void* setVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
+ SetVC* self = (SetVC*)setVC;
+ SetVC* newSetVC;
+ PtrMap* map = ptrMap;
+ Bool ownMap = False;
+
+ if( !map ) {
+ map = PtrMap_New( 10 );
+ ownMap = True;
+ }
+
+ newSetVC = (SetVC*)_VariableCondition_Copy( self, dest, deep, nameExt, map );
+
+ newSetVC->_dictionaryEntryName = self->_dictionaryEntryName;
+ newSetVC->_entryCount = self->_entryCount;
+
+ if( deep ) {
+ newSetVC->_vcset = (IndexSet*)Stg_Class_Copy( self->_vcset, NULL, deep, nameExt, map );
+
+ if( (newSetVC->_entryTbl = PtrMap_Find( map, self->_entryTbl )) == NULL && self->_entryTbl ) {
+ newSetVC->_entryTbl = Memory_Alloc_Array( SetVC_Entry, newSetVC->_entryCount, "SetVC->_entryTbl");
+ memcpy( newSetVC->_entryTbl, self->_entryTbl, sizeof(SetVC_Entry) * newSetVC->_entryCount );
+ PtrMap_Append( map, newSetVC->_entryTbl, self->_entryTbl );
+ }
+ }
+ else {
+ newSetVC->_vcset = self->_vcset;
+ newSetVC->_entryTbl = self->_entryTbl;
+ }
+
+ if( ownMap ) {
+ Stg_Class_Delete( map );
+ }
+
+ return (void*)newSetVC;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Macros
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+IndexSet* _SetVC_GetSet( void* variableCondition ) {
+ SetVC* self = (SetVC*)variableCondition;
+
+ return (IndexSet*) IndexSet_Duplicate( self->_vcset );
+}
+
+
+VariableCondition_VariableIndex _SetVC_GetVariableCount( void* variableCondition, Index globalIndex ) {
+ SetVC* self = (SetVC*)variableCondition;
+
+ return self->_entryCount;
+}
+
+
+Variable_Index _SetVC_GetVariableIndex( void* variableCondition, Index globalIndex, VariableCondition_VariableIndex varIndex ) {
+ SetVC* self = (SetVC*)variableCondition;
+
+ return Variable_Register_GetIndex(self->variable_Register, self->_entryTbl[varIndex].varName);
+}
+
+
+VariableCondition_ValueIndex _SetVC_GetValueIndex( void* variableCondition, Index globalIndex, VariableCondition_VariableIndex varIndex ) {
+ return varIndex;
+}
+
+
+VariableCondition_ValueIndex _SetVC_GetValueCount( void* variableCondition ) {
+ SetVC* self = (SetVC*)variableCondition;
+
+ return self->_entryCount;
+}
+
+
+VariableCondition_Value _SetVC_GetValue( void* variableCondition, VariableCondition_ValueIndex valIndex ) {
+ SetVC* self = (SetVC*)variableCondition;
+
+ return self->_entryTbl[valIndex].value;
+}
+
+
+void _SetVC_PrintConcise( void* variableCondition, Stream* stream ) {
+ SetVC* self = (SetVC*)variableCondition;
+ IndexSet_Index set_I;
+
+ Journal_Printf( stream, "\ttype: %s, set: {", self->type );
+ for( set_I = 0; set_I < self->_set->size; set_I++ ) {
+ if( IndexSet_IsMember( self->_set, set_I ) ) {
+ Journal_Printf( stream, "%u ", set_I );
+ }
+ }
+ Journal_Printf( stream, "}\n" );
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Build functions
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Functions
+*/
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/SetVC.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/SetVC.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,155 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: SetVC.h 4153 2007-07-26 02:25:22Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Base_Context_SetVC_h__
+#define __StGermain_Base_Context_SetVC_h__
+
+ extern const Type SetVC_Type;
+
+ #define __SetVC_Entry \
+ Name varName; \
+ VariableCondition_Value value; \
+
+ struct _SetVC_Entry { __SetVC_Entry };
+
+ #define __SetVC \
+ /* General info */ \
+ __VariableCondition \
+ \
+ /* Virtual info */ \
+ \
+ /* Stg_Class info */ \
+ Name _dictionaryEntryName; \
+ SetVC_Entry_Index _entryCount; \
+ SetVC_Entry* _entryTbl; \
+ IndexSet* _vcset;
+
+ struct _SetVC { __SetVC };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructor
+ */
+
+ VariableCondition* SetVC_Factory(
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data );
+
+ SetVC* SetVC_New(
+ Name name,
+ AbstractContext* context,
+ Name _dictionaryEntryName,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary );
+
+ SetVC* _SetVC_DefaultNew( Name name );
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define SETVC_DEFARGS \
+ VARIABLECONDITION_DEFARGS
+
+ #define SETVC_PASSARGS \
+ VARIABLECONDITION_PASSARGS
+
+ SetVC* _SetVC_New( SETVC_DEFARGS );
+
+ void _SetVC_Init( void* setVC, Name _dictionaryEntryName );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** General virtual functions
+ */
+
+ void _SetVC_Delete( void* setVC );
+
+ void _SetVC_Print( void* setVC, Stream* stream );
+
+ void _SetVC_Destroy( void* setVC, void* data );
+
+ /* Copy */
+ #define SetVC_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+ #define SetVC_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+
+ void* _SetVC_Copy( void* setVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Macros
+ */
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _SetVC_ReadDictionary( void* setVC, void* dictionary );
+
+ IndexSet* _SetVC_GetSet( void* variableCondition );
+
+ VariableCondition_VariableIndex _SetVC_GetVariableCount( void* variableCondition, Index globalIndex );
+
+ Variable_Index _SetVC_GetVariableIndex(
+ void* variableCondition,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex);
+
+ VariableCondition_ValueIndex _SetVC_GetValueIndex(
+ void* variableCondition,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex);
+
+ VariableCondition_ValueIndex _SetVC_GetValueCount( void* variableCondition );
+
+ VariableCondition_Value _SetVC_GetValue( void* variableCondition, VariableCondition_ValueIndex valIndex );
+
+ void _SetVC_PrintConcise( void* variableCondition, Stream* stream );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Build functions
+ */
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Functions
+ */
+
+#endif /* __StGermain_Base_Context_SetVC_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/SetVC.meta
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/SetVC.meta Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">SetVC</param>
+ <param name="Author">...</param>
+ <param name="Organisation">VPAC</param>
+ <param name="Project">StGermain</param>
+ <param name="Location">./StGermain/Base/Context/src/</param>
+ <param name="Project Web">http://www.stgermainproject.org/</param>
+ <param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+ <param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
+ <param name="Parent">VariableCondition</param>
+ <param name="Reference">...</param>
+ <param name="Summary">...</param>
+
+ <param name="Description">
+ Selects a definite set of entries from a variable to have a condition
+ applied.
+ </param>
+
+ <list name="Params">
+ <struct>
+ <param name="Name">indexCount</param>
+ <param name="Type">Integer</param>
+ <param name="Default"></param>
+ <param name="Description">
+ The number of entries in the index set.
+ </param>
+ </struct>
+ <struct>
+ <param name="Name">indices</param>
+ <param name="Type">List</param>
+ <param name="Default"></param>
+ <param name="Description">
+ A list of integers representing the indices in the set to be applied to.
+ </param>
+ </struct>
+ <struct>
+ <param name="Name">variables</param>
+ <param name="Type">List</param>
+ <param name="Default"></param>
+ <param name="Description">
+ A list of variable structures describing a Variable object to have values set and
+ the values to apply. Each structure has three parameters: 'name' (the name of the
+ Variable object), 'type' (the type of the value, either double or func) and 'value'
+ (for a double this is a number and for a func this is the name of the condition
+ function).
+ </param>
+ </struct>
+ </list>
+
+ <list name="Dependencies">
+ n/a
+ </list>
+
+ <param name="Example">
+ No examples available.
+ </param>
+
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Variable.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/Variable.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,1145 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: Variable.c 4149 2007-06-29 06:59:13Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+#include "Base/Automation/Automation.h"
+#include "Base/Extensibility/Extensibility.h"
+
+#include "types.h"
+#include "shortcuts.h"
+#include "ContextEntryPoint.h"
+#include "AbstractContext.h"
+#include "Variable.h"
+#include "Variable_Register.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <math.h>
+
+/* Textual name of this class */
+const Type Variable_Type = "Variable";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+Variable* Variable_New(
+ Name name,
+ AbstractContext* context,
+ Index dataCount,
+ SizeT* dataOffsets,
+ Variable_DataType* dataTypes,
+ Index* dataTypeCounts,
+ Name* dataNames,
+ SizeT* structSizePtr,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Variable_Register* vr )
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Variable);
+ Type type = Variable_Type;
+ Stg_Class_DeleteFunction* _delete = _Variable_Delete;
+ Stg_Class_PrintFunction* _print = _Variable_Print;
+ Stg_Class_CopyFunction* _copy = _Variable_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = (Stg_Component_DefaultConstructorFunction*)_Variable_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _Variable_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _Variable_Build;
+ Stg_Component_InitialiseFunction* _initialise = _Variable_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _Variable_Execute;
+ Stg_Component_DestroyFunction* _destroy = _Variable_Destroy;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ Variable* self = _Variable_New( VARIABLE_PASSARGS );
+
+ self->isConstructed = True;
+ _Variable_Init( self, context, dataCount, dataOffsets, dataTypes, dataTypeCounts, dataNames, structSizePtr, arraySizePtr, arraySizeFunc, arrayPtrPtr, False, vr );
+
+ return self;
+}
+
+Variable* _Variable_DefaultNew( Name name ) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Variable);
+ Type type = Variable_Type;
+ Stg_Class_DeleteFunction* _delete = _Variable_Delete;
+ Stg_Class_PrintFunction* _print = _Variable_Print;
+ Stg_Class_CopyFunction* _copy = _Variable_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = (Stg_Component_DefaultConstructorFunction*)_Variable_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _Variable_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _Variable_Build;
+ Stg_Component_InitialiseFunction* _initialise = _Variable_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _Variable_Execute;
+ Stg_Component_DestroyFunction* _destroy = _Variable_Destroy;
+ Index dataCount = 0;
+ SizeT* dataOffsets = NULL;
+ Variable_DataType* dataTypes = NULL;
+ Index* dataTypeCounts = NULL;
+ Name* dataNames = NULL;
+ SizeT* structSizePtr = NULL;
+ Index* arraySizePtr = NULL;
+ Variable_ArraySizeFunc* arraySizeFunc = NULL;
+ void** arrayPtrPtr = NULL;
+ Variable_Register* vr = NULL;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ Variable* self = _Variable_New( VARIABLE_PASSARGS );
+
+ return self;
+}
+
+Variable* Variable_NewScalar(
+ Name name,
+ AbstractContext* context,
+ Variable_DataType dataType,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Variable_Register* vr )
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Variable);
+ Type type = Variable_Type;
+ Stg_Class_DeleteFunction* _delete = _Variable_Delete;
+ Stg_Class_PrintFunction* _print = _Variable_Print;
+ Stg_Class_CopyFunction* _copy = _Variable_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = (Stg_Component_DefaultConstructorFunction*)_Variable_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _Variable_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _Variable_Build;
+ Stg_Component_InitialiseFunction* _initialise = _Variable_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _Variable_Execute;
+ Stg_Component_DestroyFunction* _destroy = _Variable_Destroy;
+ Index dataCount = 1;
+ Name* dataNames = 0;
+ SizeT* structSizePtr = 0;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ Variable* self;
+ SizeT dataOffsets[] = { 0 };
+ Variable_DataType dataTypes[] = { 0 }; /* Init value later */
+ Index dataTypeCounts[] = { 1 };
+
+ dataTypes[0] = dataType;
+
+ self = _Variable_New( VARIABLE_PASSARGS );
+
+ self->isConstructed = True;
+ _Variable_Init( self, context, dataCount, dataOffsets, dataTypes, dataTypeCounts, dataNames, structSizePtr, arraySizePtr, arraySizeFunc, arrayPtrPtr, False, vr );
+
+ return self;
+}
+
+Variable* Variable_NewVector(
+ Name name,
+ AbstractContext* context,
+ Variable_DataType dataType,
+ Index dataTypeCount,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Variable_Register* vr,
+ ... /* vector component names */ )
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Variable);
+ Type type = Variable_Type;
+ Stg_Class_DeleteFunction* _delete = _Variable_Delete;
+ Stg_Class_PrintFunction* _print = _Variable_Print;
+ Stg_Class_CopyFunction* _copy = _Variable_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = (Stg_Component_DefaultConstructorFunction*)_Variable_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _Variable_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _Variable_Build;
+ Stg_Component_InitialiseFunction* _initialise = _Variable_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _Variable_Execute;
+ Stg_Component_DestroyFunction* _destroy = _Variable_Destroy;
+ Index dataCount = 1;
+ SizeT* structSizePtr = 0;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ Variable* self;
+ SizeT dataOffsets[] = { 0 };
+ Variable_DataType dataTypes[] = { 0 }; /* Init later... */
+ Index dataTypeCounts[] = { 0 }; /* Init later... */
+ Name* dataNames;
+ Index vector_I;
+ va_list ap;
+
+ dataTypes[0] = dataType;
+ dataTypeCounts[0] = dataTypeCount;
+
+ dataNames = Memory_Alloc_Array( Name, dataTypeCount, "dataNames" );
+
+ va_start( ap, vr );
+ for( vector_I = 0; vector_I < dataTypeCount; vector_I++ ) {
+ dataNames[vector_I] = va_arg( ap, Name );
+ }
+ va_end( ap );
+
+ self = _Variable_New( VARIABLE_PASSARGS );
+
+ self->isConstructed = True;
+ _Variable_Init( self, context, dataCount, dataOffsets, dataTypes, dataTypeCounts, dataNames, structSizePtr, arraySizePtr, arraySizeFunc, arrayPtrPtr, False, vr );
+
+ Memory_Free( dataNames );
+
+ return self;
+}
+
+Variable* Variable_NewVector2(
+ Name name,
+ AbstractContext* context,
+ Variable_DataType dataType,
+ Index dataTypeCount,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Variable_Register* vr,
+ char** dataNames )
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Variable);
+ Type type = Variable_Type;
+ Stg_Class_DeleteFunction* _delete = _Variable_Delete;
+ Stg_Class_PrintFunction* _print = _Variable_Print;
+ Stg_Class_CopyFunction* _copy = _Variable_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = (void*)_Variable_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _Variable_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _Variable_Build;
+ Stg_Component_InitialiseFunction* _initialise = _Variable_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _Variable_Execute;
+ Stg_Component_DestroyFunction* _destroy = _Variable_Destroy;
+ Index dataCount = 1;
+ SizeT* structSizePtr = 0;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ Variable* self;
+ SizeT dataOffsets[] = { 0 };
+ Variable_DataType dataTypes[] = { 0 };
+ Index dataTypeCounts[] = { 0 };
+
+ dataTypes[0] = dataType;
+ dataTypeCounts[0] = dataTypeCount;
+
+ self = _Variable_New( VARIABLE_PASSARGS );
+
+ self->isConstructed = True;
+ _Variable_Init( self, context, dataCount, dataOffsets, dataTypes, dataTypeCounts, dataNames, structSizePtr, arraySizePtr, arraySizeFunc, arrayPtrPtr, False, vr );
+
+ return self;
+}
+
+Variable* _Variable_New( VARIABLE_DEFARGS ) {
+ Variable* self;
+
+ /* Allocate memory */
+ assert( _sizeOfSelf >= sizeof(Variable) );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = NON_GLOBAL;
+
+ self = (Variable*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
+
+ /* General info */
+
+ /* Virtual info */
+ self->_build = _build;
+ self->_initialise = _initialise;
+
+ /* Variable info */
+
+ return self;
+}
+
+void _Variable_Init(
+ Variable* self,
+ AbstractContext* context,
+ Index dataCount,
+ SizeT* dataOffsets,
+ Variable_DataType* dataTypes,
+ Index* dataTypeCounts,
+ Name* dataNames,
+ SizeT* structSizePtr,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Bool allocateSelf,
+ Variable_Register* vr )
+{
+ /*Stream* errorStream = Journal_Register( Error_Type, self->type );*/
+
+ /* General and Virtual info should already be set */
+
+ /* Variable info */
+ self->context = context;
+ self->allocateSelf = allocateSelf;
+ self->offsetCount = dataCount;
+ self->structSizePtr = structSizePtr;
+ self->arraySizePtr = arraySizePtr;
+ self->arraySizeFunc = arraySizeFunc;
+ self->arrayPtrPtr = arrayPtrPtr;
+ self->parent = NULL;
+
+ /* Checks */
+ /*Journal_Firewall( (self->arraySizePtr || self->arraySizeFunc) ,
+ errorStream, "Error: in %s(), for Variable %s - either arraySizePtr or arraySizeFunc "
+ "passed in must be non-NULL.\n", __func__, self->name );*/
+
+ /* Use of this class has increased... can't assume the info arrays are on persistant memory... copy by default. They will
+ be deleted. */
+ Journal_Firewall( dataOffsets ? True : False, Journal_Register( Error_Type, Variable_Type ), "dataOffsets is null\n" );
+ self->offsets = Memory_Alloc_Array( SizeT, self->offsetCount, "Variable->offsets" );
+ memcpy( self->offsets, dataOffsets, sizeof(SizeT) * self->offsetCount );
+
+ Journal_Firewall( dataTypes ? True : False, Journal_Register( Error_Type, Variable_Type ), "dataTypes is null\n" );
+ self->dataTypes = Memory_Alloc_Array( Variable_DataType, self->offsetCount, "Variable->dataTypes" );
+ memcpy( self->dataTypes, dataTypes, sizeof(Variable_DataType) * self->offsetCount );
+
+ Journal_Firewall( dataTypeCounts ? True : False , Journal_Register( Error_Type, Variable_Type ), "dataTypeCounts is null\n" );
+ self->dataTypeCounts = Memory_Alloc_Array( Index, self->offsetCount, "Variable->dataTypeCounts" );
+ memcpy( self->dataTypeCounts, dataTypeCounts, sizeof(Index) * self->offsetCount );
+
+ /* These get set at the build phase (when we assume the variable's data memory has been allocated) */
+ self->structSize = 0;
+ self->arrayPtr = 0;
+ self->dataSizes = 0;
+
+ if ( dataNames && self->offsetCount == 1 && self->dataTypeCounts[0] > 1 ) {
+ /* Vector case */
+ self->subVariablesCount = self->dataTypeCounts[0];
+ }
+ else {
+ /* Scalar or Complex case */
+ self->subVariablesCount = self->offsetCount;
+ }
+ self->components = Memory_Alloc_Array( Variable*, self->subVariablesCount, "Variable->components" );
+ memset( self->components, 0, sizeof(Variable*) * self->subVariablesCount );
+
+ /* If the variable register is provided, add this and component variable(s) to the register */
+ if( vr ) {
+ self->vr = vr;
+ Variable_Register_Add( vr, self );
+
+ /* If we have component names, create the associated variables. Don't do if there is only one component. */
+ if( dataNames && self->offsetCount > 1 ) {
+ Index component_I;
+
+ for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
+ if( dataNames[component_I] ) {
+ SizeT componentOffsets[] = { 0 };
+ Variable_DataType componentTypes[] = { 0 };
+ Index componentTypeCounts[] = { 0 };
+
+ componentOffsets[0] = self->offsets[component_I];
+ componentTypes[0] = self->dataTypes[component_I];
+ componentTypeCounts[0] = self->dataTypeCounts[component_I];
+
+ /* Assumption: components are scalar or vector, but cannot be complex */
+ self->components[component_I] = Variable_New(
+ dataNames[component_I],
+ self->context,
+ 1,
+ componentOffsets,
+ componentTypes,
+ componentTypeCounts,
+ 0,
+ self->structSizePtr,
+ self->arraySizePtr,
+ self->arraySizeFunc,
+ self->arrayPtrPtr,
+ vr );
+ self->components[component_I]->parent = self;
+ }
+ }
+ }
+ /* Else if we have vector-component names, create the associated variables. Do only if non-complex and a vector. */
+ else if( dataNames && self->offsetCount == 1 && self->dataTypeCounts[0] > 1 ) {
+ Index vector_I;
+
+ for( vector_I = 0; vector_I < self->dataTypeCounts[0]; vector_I++ ) {
+ if( dataNames[vector_I] ) {
+ /* Unfortunately we cannot call any of our fancy macros here as the array is not resolved
+ * yet. As a consequence we have to manually work out the vector's indecis offsets. Ouch
+ * only from a code-maintenance point of view. */
+ SizeT componentOffsets[] = { 0 }; /* Init later... */
+ Variable_DataType componentTypes[] = { 0 }; /* Init later... */
+ Index componentTypeCounts[] = { 1 };
+
+ componentOffsets[0] =
+ (ArithPointer)self->offsets[0] +
+ ( self->dataTypes[0] == Variable_DataType_Char ? ( sizeof(char) * vector_I ) :
+ self->dataTypes[0] == Variable_DataType_Short ? ( sizeof(short) * vector_I ) :
+ self->dataTypes[0] == Variable_DataType_Int ? ( sizeof(int) * vector_I ) :
+ self->dataTypes[0] == Variable_DataType_Float ? ( sizeof(float) * vector_I ) :
+ self->dataTypes[0] == Variable_DataType_Double ? ( sizeof(double) * vector_I ) :
+ self->dataTypes[0] == Variable_DataType_Pointer ? ( sizeof(void*) * vector_I ) :
+ Journal_Firewall(
+ 0,
+ Journal_Register( Error_Type, Variable_Type ),
+ "Vector is of a non-builtin type\n" ) );
+ componentTypes[0] = self->dataTypes[0];
+
+ /* Assumption: vector-components are scalar, but cannot be complex */
+ self->components[vector_I] = Variable_New(
+ dataNames[vector_I],
+ self->context,
+ 1,
+ componentOffsets,
+ componentTypes,
+ componentTypeCounts,
+ 0,
+ self->structSizePtr,
+ self->arraySizePtr,
+ self->arraySizeFunc,
+ self->arrayPtrPtr,
+ vr );
+ self->components[vector_I]->parent = self;
+ }
+ }
+ }
+ }
+ else {
+ self->vr = NULL;
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _Variable_Delete( void* variable ) {
+ Variable* self = (Variable*)variable;
+
+ /* Stg_Class_Delete parent */
+ _Stg_Component_Delete( self );
+}
+
+
+void _Variable_Print( void* variable, Stream* stream ) {
+ Variable* self = (Variable*)variable;
+ Index component_I;
+
+ /* Print parent */
+ _Stg_Component_Print( self, stream );
+
+ /* General info */
+ Journal_Printf( stream, "Variable (ptr): (%p)\n", self );
+
+ /* Virtual info */
+
+ /* Variable info */
+ Journal_Printf( stream, "\toffsetCount: %u\n", self->offsetCount );
+
+ Journal_Printf( stream, "\toffsets (ptr): %p\n", self->offsets );
+ for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
+ Journal_Printf( stream, "\t\toffsets[%u]: %lu\n", component_I, self->offsets[component_I] );
+ }
+
+ Journal_Printf( stream, "\tdataTypes (ptr): %p\n", self->dataTypes );
+ for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
+ Journal_Printf( stream, "\t\tdataTypes[%u]: %lu\n", component_I, self->dataTypes[component_I] );
+ }
+
+ Journal_Printf( stream, "\tdataTypeCounts (ptr): %p\n", self->dataTypeCounts );
+ for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
+ Journal_Printf( stream, "\t\tdataTypeCounts[%u]: %lu\n", component_I, self->dataTypeCounts[component_I] );
+ }
+
+ Journal_Printf( stream, "\tdataSizes (ptr): %p\n", self->dataSizes );
+ for( component_I = 0; component_I < self->offsetCount && self->dataSizes; component_I++ ) {
+ Journal_Printf( stream, "\t\tdataSizes[%u]: %lu\n", component_I, self->dataSizes[component_I] );
+ }
+
+ Journal_Printf( stream, "\tcomponents (ptr): %p\n", self->components );
+ for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
+ Journal_Printf( stream, "\t\tcomponents[%u] (ptr): %p\n", component_I, self->components[component_I] );
+ if( self->components[component_I] ) {
+ Journal_Printf( stream, "\t\tcomponents[%u]: %s\n", component_I, self->components[component_I]->name );
+ }
+ }
+
+ Journal_Printf( stream, "\tstructSize: %lu\n", self->structSize );
+ Journal_Printf( stream, "\tstructSizePtr (ptr): %p\n", self->structSizePtr );
+
+ Journal_Printf( stream, "\tarrayPtr (ptr): %p\n", self->arrayPtr );
+ Journal_Printf( stream, "\tarrayPtrPtr (ptr): %p\n", self->arrayPtrPtr );
+
+ Journal_Printf( stream, "\tarraySize: %lu\n", _Variable_GetNewArraySize( self ) );
+ Journal_Printf( stream, "\tarraySizePtr (ptr): %p\n", self->arraySizePtr );
+ Journal_Printf( stream, "\tarraySizeFunc (ptr): %p\n", self->arraySizeFunc );
+
+ Journal_Printf( stream, "\tallocateSelf = %s\n", self->allocateSelf ? "True" : "False" );
+}
+
+
+void* _Variable_Copy( void* variable, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
+ Variable* self = (Variable*)variable;
+ Variable* newVariable;
+ PtrMap* map = ptrMap;
+
+ newVariable = (Variable*)_Stg_Component_Copy( self, dest, deep, nameExt, map );
+ PtrMap_Append( map, self, newVariable );
+
+ /* virtual methods */
+ newVariable->offsetCount = self->offsetCount;
+ newVariable->structSize = self->structSize;
+ newVariable->arraySizePtr = self->arraySizePtr;
+ newVariable->arraySizeFunc = self->arraySizeFunc;
+
+ newVariable->allocateSelf = self->allocateSelf; /* This may change depending on whether arrayPtr is found in map */
+ newVariable->subVariablesCount = self->subVariablesCount;
+
+ /* single valued members */
+
+ if( deep ) {
+ if( (newVariable->offsets = PtrMap_Find( map, self->offsets )) == NULL && self->offsets != NULL ) {
+ newVariable->offsets = Memory_Alloc_Array( SizeT, newVariable->offsetCount, "Variable->offsets" );
+ memcpy( newVariable->offsets, self->offsets, sizeof(SizeT) * newVariable->offsetCount );
+ PtrMap_Append( map, self->offsets, newVariable->offsets );
+ }
+
+ if( (newVariable->dataTypes = PtrMap_Find( map, self->dataTypes )) == NULL && self->offsets != NULL ) {
+ newVariable->dataTypes = Memory_Alloc_Array( Variable_DataType, newVariable->offsetCount, "Variable->dataTypes" );
+ memcpy( newVariable->dataTypes, self->dataTypes, sizeof(Variable_DataType) * newVariable->offsetCount );
+ PtrMap_Append( map, self->dataTypes, newVariable->dataTypes );
+ }
+
+ if( (newVariable->dataTypeCounts = PtrMap_Find( map, self->dataTypeCounts )) == NULL && self->dataTypeCounts != NULL ) {
+ newVariable->dataTypeCounts = Memory_Alloc_Array( Index, newVariable->offsetCount, "Variable->dataTypeCounts" );
+ memcpy( newVariable->dataTypeCounts, self->dataTypeCounts, sizeof(Index) * newVariable->offsetCount );
+ PtrMap_Append( map, self->dataTypeCounts, newVariable->dataTypeCounts );
+ }
+
+ if ( self->structSizePtr != NULL ) {
+ if( (newVariable->structSizePtr = PtrMap_Find( map, self->structSizePtr )) == NULL ) {
+ newVariable->structSizePtr = Memory_Alloc_Array(
+ SizeT,
+ 1,
+ "Variable->structSizePtr" );
+ memcpy( newVariable->structSizePtr, self->structSizePtr, sizeof(SizeT) );
+ PtrMap_Append( map, self->structSizePtr, newVariable->structSizePtr );
+ }
+ }
+ else {
+ newVariable->structSizePtr = NULL;
+ }
+
+ if ( self->arraySizePtr != NULL ) {
+ if( (newVariable->arraySizePtr = PtrMap_Find( map, self->arraySizePtr )) == NULL ) {
+ newVariable->arraySizePtr = Memory_Alloc_Array(
+ Index,
+ 1,
+ "Variable->arraySizePtr" );
+ memcpy( newVariable->arraySizePtr, self->arraySizePtr, sizeof(Index) );
+ PtrMap_Append( map, self->arraySizePtr, newVariable->arraySizePtr );
+ }
+ }
+ else {
+ newVariable->arraySizeFunc = NULL;
+ }
+ if ( self->arraySizeFunc != NULL ) {
+ if( (newVariable->arraySizeFunc = PtrMap_Find( map, self->arraySizeFunc )) == NULL ) {
+ newVariable->arraySizeFunc = Memory_Alloc_Array(
+ Variable_ArraySizeFunc,
+ 1,
+ "Variable->arraySizeFunc" );
+ memcpy( newVariable->arraySizeFunc, self->arraySizeFunc, sizeof(Index) );
+ PtrMap_Append( map, self->arraySizeFunc, newVariable->arraySizeFunc );
+ }
+ }
+ else {
+ newVariable->arraySizeFunc = NULL;
+ }
+
+ if( (newVariable->dataSizes = PtrMap_Find( map, self->dataSizes )) == NULL && self->dataSizes != NULL ) {
+ newVariable->dataSizes = Memory_Alloc_Array( SizeT, newVariable->offsetCount, "Variable->dataSizes" );
+ memcpy( newVariable->dataSizes, self->dataSizes, sizeof(SizeT) * newVariable->offsetCount );
+ PtrMap_Append( map, self->dataSizes, newVariable->dataSizes );
+ }
+
+ if( (newVariable->arrayPtrPtr = PtrMap_Find( map, self->arrayPtrPtr )) == NULL && self->arrayPtrPtr != NULL ) {
+ if( (newVariable->arrayPtr = PtrMap_Find( map, self->arrayPtr )) == NULL && self->arrayPtr != NULL ) {
+ Index memoryToAllocSize = _Variable_GetNewArraySize( self ) * self->structSize;
+ newVariable->arrayPtr = Memory_Alloc_Bytes(
+ memoryToAllocSize,
+ Variable_Type,
+ "SelfAllocedArray" );
+ memcpy( newVariable->arrayPtr, self->arrayPtr, memoryToAllocSize );
+ PtrMap_Append( map, self->arrayPtr, newVariable->arrayPtr );
+
+ newVariable->arrayPtrPtr = &(newVariable->arrayPtr);
+ newVariable->allocateSelf = True;
+ }
+ }
+ else {
+ newVariable->arrayPtr = *newVariable->arrayPtrPtr;
+ memcpy( newVariable->arrayPtr, self->arrayPtr, _Variable_GetNewArraySize(self) * self->structSize );
+ }
+
+ if( (newVariable->components = PtrMap_Find( map, self->components )) == NULL && self->components != NULL ) {
+ Index comp_I;
+
+ if( newVariable->offsetCount == 1 && newVariable->dataTypeCounts[0] > 1 ) {
+ /* Vector case */
+ newVariable->components = Memory_Alloc_Array(
+ Variable*,
+ newVariable->dataTypeCounts[0],
+ "Variable->components" );
+ memset( newVariable->components, 0, sizeof(Variable*) * newVariable->dataTypeCounts[0] );
+
+ for( comp_I = 0; comp_I < newVariable->dataTypeCounts[0]; comp_I++ ) {
+ newVariable->components[comp_I] = (Variable*)Stg_Class_Copy(
+ self->components[comp_I],
+ NULL,
+ deep,
+ nameExt,
+ map );
+ }
+ }
+ else {
+ /* Scalar or Complex case */
+ newVariable->components = Memory_Alloc_Array(
+ Variable*,
+ newVariable->offsetCount,
+ "Variable->components" );
+ memset( newVariable->components, 0, sizeof(Variable*) * newVariable->offsetCount );
+
+ for( comp_I = 0; comp_I < newVariable->offsetCount; comp_I++ ) {
+ if ( self->components[comp_I] ) {
+ newVariable->components[comp_I] = (Variable*)Stg_Class_Copy(
+ self->components[comp_I],
+ NULL,
+ deep,
+ nameExt,
+ map );
+ }
+ }
+ }
+
+ PtrMap_Append( map, self->components, newVariable->components );
+ }
+
+ if ( self->vr ) {
+ newVariable->vr = Stg_Class_Copy( self->vr, NULL, deep, nameExt, map );
+ }
+ }
+ else {
+ fprintf( stderr, "Warning: please don't shallow copy variables yet...or ever!\n" );
+ }
+
+ return (void*)newVariable;
+}
+
+
+void _Variable_Build( void* variable, void* data ) {
+ Variable* self = (Variable*)variable;
+ Index component_I;
+ Index subVariable_I;
+
+ if( self->parent ) {
+ /* We need to build the parent first, as it may initialise data structures needed
+ * by this Variable. BUT, the parent will call Build() on all it's sub-Variables
+ * including this one, so we need to avoid an infinite loop. */
+ self->isBuilt = True;
+ Stg_Component_Build( self->parent, NULL, False );
+ self->isBuilt = False;
+ }
+
+ /* Obtain the actual array size, and array pointer */
+ Journal_Firewall(
+ ( self->arraySizeFunc || self->arraySizePtr )? True : False,
+ Journal_Register( Error_Type, Variable_Type ),
+ "arraySizePtr && arraySizeFunc is null\n" );
+ self->arraySize = _Variable_GetNewArraySize( self );
+
+
+ /* Work out the actual data sizes from the data types */
+ if( self->dataSizes ) {
+ Memory_Free( self->dataSizes );
+ }
+ self->dataSizes = Memory_Alloc_Array( SizeT, self->offsetCount, "Variable->dataSizes" );
+ for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
+ switch ( self->dataTypes[component_I] ) {
+ case Variable_DataType_Variable:
+ Journal_Firewall(
+ self->dataTypes[component_I] != Variable_DataType_Variable,
+ Journal_Register( Error_Type, Variable_Type ),
+ "\"dataType[?] == Variable_DataType_Variables\" not yet implemented\n" );
+ break;
+ case Variable_DataType_Char:
+ self->dataSizes[component_I] = sizeof( char ) * self->dataTypeCounts[component_I];
+ break;
+ case Variable_DataType_Short:
+ self->dataSizes[component_I] = sizeof( short ) * self->dataTypeCounts[component_I];
+ break;
+ case Variable_DataType_Int:
+ self->dataSizes[component_I] = sizeof( int ) * self->dataTypeCounts[component_I];
+ break;
+ case Variable_DataType_Float:
+ self->dataSizes[component_I] = sizeof( float ) * self->dataTypeCounts[component_I];
+ break;
+ case Variable_DataType_Double:
+ self->dataSizes[component_I] = sizeof( double ) * self->dataTypeCounts[component_I];
+ break;
+ case Variable_DataType_Pointer:
+ self->dataSizes[component_I] = sizeof( void* ) * self->dataTypeCounts[component_I];
+ break;
+ default:
+ Journal_Firewall(
+ self->dataTypes[component_I] >= Variable_DataType_Size,
+ Journal_Register( Error_Type, Variable_Type ),
+ "\"dataType[?]\" is unrecognised\n" );
+ break;
+ }
+ }
+
+ /* Non-complex variables: Scalar & Vector can workout struct size for themselves.
+ * Now that we know all the data sizes, work out the actual struct size (which may need the data sizes) */
+ if( self->offsetCount == 1 && !self->structSizePtr ) {
+ /* Vector and Scalars which are not apart of a Vector can work out their own size */
+ if ( self->structSize == 0 ) {
+ self->structSize = self->dataSizes[0];
+ }
+
+ /* If this is a vector, set its sub variables to the same struct size */
+ if ( self->dataTypeCounts[0] > 1 ) {
+ for ( subVariable_I = 0; subVariable_I < self->dataTypeCounts[0]; ++subVariable_I ) {
+ if ( self->components[subVariable_I] ) {
+ self->components[subVariable_I]->structSize = self->structSize;
+ }
+ else
+ /* break here because if one subVariable isn't allocated - then the rest shouldn't be */
+ break;
+ }
+ }
+ }
+ else {
+ Journal_Firewall(
+ self->structSizePtr ? True: False,
+ Journal_Register( Error_Type, Variable_Type ),
+ "structSizePtr is null\n" );
+ self->structSize = *self->structSizePtr;
+ }
+
+ if (self->allocateSelf) {
+ Index memoryToAllocSize = _Variable_GetNewArraySize( self ) * self->structSize;
+ Index subVariable_I;
+
+ Journal_Firewall( self->offsetCount == 1,
+ Journal_Register( Error_Type, Variable_Type ),
+ "Variable '%s' has 'offsetCount = %u', which should be 1 for self allocation.\n",
+ self->name, self->offsetCount );
+
+ self->arrayPtr = Memory_Alloc_Bytes( memoryToAllocSize, Variable_Type, "SelfAllocedArray" );
+ memset( self->arrayPtr, 0, memoryToAllocSize );
+
+ /* If this is a vector then set arrayPtr to be the same for each element of the vector */
+ if ( self->dataTypeCounts[0] > 1 ) {
+ for ( subVariable_I = 0 ; subVariable_I < self->dataTypeCounts[0] ; subVariable_I++ ) {
+ if ( self->components[subVariable_I] ) {
+ self->components[ subVariable_I ]->arrayPtr = self->arrayPtr;
+ self->components[ subVariable_I ]->arrayPtrPtr = &self->arrayPtr;
+ }
+ else {
+ /* break here because if one subVariable isn't allocated - then the rest shouldn't be */
+ break;
+ }
+ }
+ }
+ }
+ else {
+ Journal_Firewall(
+ self->arrayPtrPtr ? True : False,
+ Journal_Register( Error_Type, Variable_Type ),
+ "Variable '%s' has NULL arrayPtrPtr\n", self->name );
+ self->arrayPtr = *self->arrayPtrPtr;
+ }
+
+ /* Lastly, build all components. It is reasonable if the user calls Build on "velocity", then
+ * "velocity-x" etc are automatically build also. */
+ for ( subVariable_I = 0; subVariable_I < self->subVariablesCount; subVariable_I++ ) {
+ if ( self->components[subVariable_I] ) {
+ /*Components now call Build on the parent, so if the parent is calling first,
+ * need to avoid infinite recursion. */
+ self->isBuilt = True;
+ Stg_Component_Build( self->components[subVariable_I], data, False );
+ self->isBuilt = False;
+ }
+ }
+}
+
+
+void _Variable_Initialise( void* variable, void* data ) {
+ Variable* self = (Variable*)variable;
+ Index subVariable_I;
+
+ for ( subVariable_I = 0; subVariable_I < self->subVariablesCount; subVariable_I++ ) {
+ if ( self->components[subVariable_I] ) {
+ Stg_Component_Initialise( self->components[subVariable_I], data, False );
+ }
+ }
+}
+
+
+void _Variable_Execute( void* variable, void* data ) {
+}
+
+void _Variable_AssignFromXML( void* variable, Stg_ComponentFactory* cf, void* data ) {
+ Variable* self = (Variable*) variable;
+ SizeT dataOffsets[] = { 0 };
+ Variable_DataType dataTypes[] = { 0 }; /* Init value later */
+ Index dataTypeCounts[] = { 1 };
+ Dictionary* componentDict = NULL;
+ Dictionary* thisComponentDict = NULL;
+ Name dataTypeName = NULL;
+ Name rankName = NULL;
+ Name countName = NULL;
+ unsigned int* count = NULL;
+ void* variableRegister = NULL;
+ void* pointerRegister = NULL;
+ Name* names = NULL;
+ Stream* error = Journal_Register( Error_Type, self->type );
+ AbstractContext* context;
+
+ assert( self );
+
+ context = Stg_ComponentFactory_ConstructByKey( cf, self->name, "Context", AbstractContext, False, data );
+ if( !context )
+ context = Stg_ComponentFactory_ConstructByName( cf, "context", AbstractContext, True, data );
+
+ componentDict = cf->componentDict;
+ assert( componentDict );
+ thisComponentDict = Dictionary_GetDictionary( componentDict, self->name );
+ assert( thisComponentDict );
+
+ /* Grab Registers */
+ variableRegister = context->variable_Register;
+ assert( variableRegister );
+ pointerRegister = context->pointer_Register;
+ assert( pointerRegister );
+
+ Stg_ComponentFactory_ConstructByKey( cf, self->name, "Dependency", Stg_Component, False, data );
+
+ /* Get Pointer to number of elements in array */
+ countName = Dictionary_GetString( thisComponentDict, "Count" );
+ count = Stg_ObjectList_Get( pointerRegister, countName );
+ //assert( count );
+
+ /* Get Type of Variable */
+ dataTypeName = Dictionary_GetString( thisComponentDict, "DataType" );
+ if ( !strcasecmp( dataTypeName, "Double" ) )
+ dataTypes[0] = Variable_DataType_Double;
+ else if ( !strcasecmp( dataTypeName, "Float" ) )
+ dataTypes[0] = Variable_DataType_Float;
+ else if ( !strcasecmp( dataTypeName, "Int" ) )
+ dataTypes[0] = Variable_DataType_Int;
+ else if ( !strcasecmp( dataTypeName, "Char" ) )
+ dataTypes[0] = Variable_DataType_Char;
+ else if ( !strcasecmp( dataTypeName, "Short" ) )
+ dataTypes[0] = Variable_DataType_Short;
+ else
+ Journal_Firewall( False, error, "Variable '%s' cannot understand data type '%s'\n", self->name, dataTypeName );
+
+ /* Get Rank of Variable - i.e. Scalar or Vector */
+ rankName = Dictionary_GetString( thisComponentDict, "Rank" );
+ if( !strcasecmp( rankName, "Scalar" ) ){
+ dataTypeCounts[0] = 1;
+ }
+ else if ( !strcasecmp( rankName, "Vector" ) ){
+ Dictionary_Entry_Value* list;
+ Index nameCount = 0;
+
+ /* Get Names from list */
+ if (( list = Dictionary_Get( thisComponentDict, "names" ) )) {
+ Index entry_I;
+
+ nameCount = Dictionary_Entry_Value_GetCount( list );
+ names = Memory_Alloc_Array( Name, nameCount, "Variable Names" );
+
+ for ( entry_I = 0 ; entry_I < nameCount ; entry_I++ )
+ names[ entry_I ] = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement(list, entry_I ) );
+ }
+ dataTypeCounts[0] = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, "VectorComponentCount", nameCount );
+
+ Journal_Firewall( nameCount >= dataTypeCounts[0], error, "Variable '%s' has too few names in list for %d vector components.\n", self->name, dataTypeCounts[0] );
+ }
+ else
+ Journal_Firewall( False, error, "Variable '%s' cannot understand rank '%s'\n", self->name, rankName );
+
+ _Variable_Init(
+ self,
+ context,
+ 1,
+ dataOffsets,
+ dataTypes,
+ dataTypeCounts,
+ names,
+ 0,
+ count,
+ NULL, /* Note: don't support arraySize being calculated from a Func Ptr through
+ Construct() Yet - PatrickSunter, 29 Jun 2007 */
+ (void**)&self->arrayPtr,
+ True,
+ variableRegister );
+
+ /* Clean Up */
+ if (names)
+ Memory_Free(names);
+}
+
+void _Variable_Destroy( void* variable, void* data ) {
+ Variable* self = (Variable*)variable;
+ int ii;
+
+ for( ii = 0 ; ii < self->subVariablesCount ; ii++ ) {
+ Stg_Component_Destroy( self->components[ii], data, False );
+ }
+
+ if ( self->dataSizes ) {
+ Memory_Free( self->dataSizes );
+ }
+ if (self->allocateSelf && self->arraySize != 0) {
+ Memory_Free( self->arrayPtr );
+ }
+
+ Memory_Free( self->dataTypeCounts );
+ Memory_Free( self->dataTypes );
+ Memory_Free( self->offsets );
+ Memory_Free( self->components );
+}
+
+Index _Variable_GetNewArraySize( Variable* self ) {
+ Index arraySize = 0;
+
+ /* By default, we will try the simple ptr approach. */
+ if ( NULL != self->arraySizePtr ) {
+ arraySize = (*self->arraySizePtr);
+ }
+ else {
+ /* If that was NULL, we expect the arraySizeFunc to be set */
+
+ /* Because of the way sub-variables are constructed, they will use their parent's
+ * arraySizePtr function (eg in the case of "vx", we want it to use the parent
+ * Velocity MeshVariable's function to calculate the
+ * size of the mesh.
+ */
+ if ( NULL != self->parent ) {
+ arraySize = (*self->arraySizeFunc)( self->parent );
+ }
+ else {
+ arraySize = (*self->arraySizeFunc)( self );
+ }
+ }
+
+ return arraySize;
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void Variable_SetValue( void* variable, Index array_I, void* value ) {
+ Variable* self = (Variable*)variable;
+ ArithPointer* vPtr;
+ Index component_I;
+
+ vPtr = value;
+ for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
+ memcpy( _Variable_GetPtr( self, array_I, component_I, 0 ), (void*)vPtr, self->dataSizes[component_I] );
+
+ vPtr += self->dataSizes[component_I];
+ }
+}
+
+
+void Variable_GetValue( void* variable, Index array_I, void* value ) {
+ Variable* self = (Variable*)variable;
+ ArithPointer* vPtr;
+ Index component_I;
+
+ vPtr = value;
+ for( component_I = 0; component_I < self->offsetCount; component_I++ ) {
+ memcpy( (void*)vPtr, _Variable_GetPtr( self, array_I, component_I, 0 ), self->dataSizes[component_I] );
+
+ vPtr += self->dataSizes[component_I];
+ }
+}
+
+void Variable_Update( void* variable ) {
+ Variable* self = (Variable*)variable;
+
+ /* array may have resized, assign local properties again */
+ self->arrayPtr = *self->arrayPtrPtr;
+ self->arraySize = _Variable_GetNewArraySize( self );
+
+ if( !( self->offsetCount == 1 && !self->structSizePtr ) ) {
+ /* For non-scalar or non-vector variables, the targets may have been extended. */
+ self->structSize = *self->structSizePtr;
+ }
+}
+
+void Variable_SetValueDoubleAll( void* variable, double value ) {
+ Variable* self = (Variable*) variable;
+ Index arraySize = self->arraySize;
+ Index array_I;
+
+ for ( array_I = 0 ; array_I < arraySize ; array_I++ )
+ Variable_SetValueDouble( self, array_I, value );
+}
+
+
+void Variable_SaveToFileAsDoubles( void* variable, char* filename ) {
+ Variable* self = (Variable*) variable;
+ Index arraySize = self->arraySize;
+ Index array_I;
+ double value;
+ FILE* outputFile;
+ Index comp_I;
+
+ outputFile = fopen( filename, "w" );
+
+ for ( array_I = 0 ; array_I < arraySize ; array_I++ ) {
+ if ( *self->dataTypeCounts > 1 ) {
+ for ( comp_I = 0; comp_I < *self->dataTypeCounts; comp_I++ ) {
+ value = Variable_GetValueAtDouble( self, array_I, comp_I );
+ fwrite( &value, sizeof(double), 1, outputFile );
+ }
+ }
+ else {
+ value = Variable_GetValueDouble( self, array_I );
+ fwrite( &value, sizeof(double), 1, outputFile );
+ }
+
+ }
+
+ fclose( outputFile );
+}
+
+
+void Variable_ReadFromFileAsDoubles( void* variable, char* filename ) {
+ Variable* self = (Variable*) variable;
+ Index arraySize = self->arraySize;
+ Index array_I;
+ double value;
+ FILE* inputFile;
+ Index comp_I;
+
+ inputFile = fopen( filename, "r" );
+
+ for ( array_I = 0 ; array_I < arraySize ; array_I++ ) {
+ if ( *self->dataTypeCounts > 1 ) {
+ for ( comp_I = 0; comp_I < *self->dataTypeCounts; comp_I++ ) {
+ fread( &value, sizeof(double), 1, inputFile );
+ Variable_SetValueAtDouble( self, array_I, comp_I, value );
+ }
+ }
+ else {
+ fread( &value, sizeof(double), 1, inputFile );
+ Variable_SetValueDouble( self, array_I, value );
+ }
+ }
+
+ fclose( inputFile );
+}
+
+
+/** Returns \f$ \frac{|| variable - comparison ||} { || variable ||} \f$,
+ * where \f$ ||x|| \f$ indicates the Euclidean Norm which is the square root of the sum of the squares for each component in x
+ * i.e. \f$ ||x|| = \sqrt{\sum_i x_i^2} \f$ */
+double Variable_ValueCompare( void* variable, void* _comparison ) {
+ Variable* self = (Variable*) variable;
+ Variable* comparison = (Variable*) _comparison;
+ Index arraySize = self->arraySize;
+ Index dataTypeCounts = *self->dataTypeCounts;
+ Index array_I;
+ Index component_I;
+ double differenceValue;
+ double selfValue;
+ double normDifference = 0.0;
+ double normVariable = 0.0;
+ Stream* error = Journal_Register( Error_Type, self->type );
+
+ /* Simple Error Checking */
+ Journal_Firewall( arraySize == comparison->arraySize, error,
+ "In func %s: Array sizes different for variables '%s' and '%s'\n", __func__, self->name, comparison->name );
+ Journal_Firewall( dataTypeCounts == *comparison->dataTypeCounts, error,
+ "In func %s: Data Type Counts different for variables '%s' and '%s'\n", __func__, self->name,comparison->name);
+
+ for ( component_I = 0 ; component_I < self->offsetCount ; component_I++ ) {
+ Journal_Firewall( self->dataTypes[component_I] == Variable_DataType_Double, error,
+ "In func %s: Stg_Component %d of variable '%s' has different type to Variable_DataType_Double.\n",
+ __func__, component_I, self->name );
+ Journal_Firewall( comparison->dataTypes[component_I] == Variable_DataType_Double, error,
+ "In func %s: Stg_Component %d of variable '%s' has different type to Variable_DataType_Double.\n",
+ __func__, component_I, comparison->name );
+ }
+
+ /* Calculate Euclidean Norms */
+ for ( array_I = 0 ; array_I < arraySize ; array_I++ ) {
+ for ( component_I = 0 ; component_I < dataTypeCounts ; component_I++ ) {
+ selfValue = Variable_GetValueAtDouble( self, array_I, component_I );
+ differenceValue = selfValue - Variable_GetValueAtDouble( comparison, array_I, component_I );
+
+ normDifference += differenceValue * differenceValue;
+ normVariable += selfValue * selfValue;
+ }
+ }
+
+ normDifference = sqrt( normDifference );
+ normVariable = sqrt( normVariable );
+
+ return normDifference/normVariable;
+}
+
+/** Checks whether || variable - comparison || / || variable || < tolerance */
+Bool Variable_ValueCompareWithinTolerance( void* variable, void* comparison, double tolerance ) {
+ return ( Variable_ValueCompare( variable, comparison ) < tolerance );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Variable.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/Variable.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,1202 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/** \file
+** <b>Role:</b>
+** A Variable associates a textual name to a field(s) in an array of structures.
+**
+** <b>Assumptions:</b>
+** None
+**
+** <b>Comments:</b>
+** None
+**
+** <b>Description</b>
+** Variable is used to group a field of a structure inside an array so that functions and algorithms can be solely
+** applied to this member. This allows more dynamic library routines possible.
+**
+** For example in an array of coordinates {x, y, z} a Variable can be created to represent "x".
+**
+** Note that Variables can be applied to any piece of contiguous memory.
+**
+** $Id: Variable.h 4149 2007-06-29 06:59:13Z PatrickSunter $
+**
+**/
+
+#ifndef __StGermain_Base_Context_Variable_h__
+#define __StGermain_Base_Context_Variable_h__
+
+ /** Textual name for Variable class. */
+ extern const Type Variable_Type;
+
+ typedef enum {
+ Variable_DataType_Variable,
+ Variable_DataType_Char,
+ Variable_DataType_Short,
+ Variable_DataType_Int,
+ Variable_DataType_Float,
+ Variable_DataType_Double,
+ Variable_DataType_Pointer,
+ Variable_DataType_Size /* Marker for derivatives to enum */
+ } Variable_DataType;
+
+ typedef Index (Variable_ArraySizeFunc) ( void* self );
+
+ /* See Variable */
+
+ #define __Variable \
+ /* General info */ \
+ __Stg_Component \
+ \
+ AbstractContext* context; \
+ /* Virtual info */ \
+ \
+ /* Variable info */ \
+ Index offsetCount; /**< Number of fields in this variable. */ \
+ SizeT* offsets; /**< The offset in bytes these fields are in the struct.*/ \
+ Variable_DataType* dataTypes; /**< A list of original data types. */ \
+ Index* dataTypeCounts; /**< A list of the number of data. */ \
+ SizeT* structSizePtr; /**< A pointer to the size of the structure. */ \
+ void** arrayPtrPtr; /**< A pointer to a pointer to the 1D array data. */ \
+ Index* arraySizePtr; /**< A ptr to the size/count of the 1D array data. Note that if this is NULL, the arraySizeFunc will be used */ \
+ Variable_ArraySizeFunc* arraySizeFunc; /**< A func ptr to the size/count of the 1D array data. */ \
+ \
+ SizeT* dataSizes; /**< The size in bytes of each field in this variable. */ \
+ SizeT structSize; /**< The size of the structure. */ \
+ void* arrayPtr; /**< A pointer to the 1D array of structures. */ \
+ Index arraySize; /**< The size/count of the 1D array of structures. */ \
+ Index subVariablesCount; /**< The number of subvariables. Necessary since determined by whether user passes in names or not at init time. */ \
+ Variable** components; /**< For each component of this variable that we made a variable for, the pointer to the variable. */ \
+ Bool allocateSelf; \
+ Variable_Register* vr; \
+ \
+ Variable* parent;
+
+ struct _Variable { __Variable };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ /** Creates a new Variable. A Variable holds the run-time information of a complex data type created by the programmer.
+ * Essentially it associates a textual name to a variable in the program that the user can use to access or modify.
+ *
+ * For example, if the program has an array of doubles that stores temperature, a Variable can be created with the name
+ * "temperature", which will know how to access any item of this array. This name can then be added to a list of variables
+ * to dump, where the code doing so has at compile-time has no idea about the existance of this variable.
+ *
+ * This constructor is the most complex, allowing the captured data to be a composition of items in a struct, of which
+ * itself may be in an array. Each item can be named, causing the construction of a new variable for each, but only if the
+ * register is made available and the name is not 0. If the register is made available, then this variable is also added
+ * to the register. In the case where there is only one item, but it is a vector, the name list must reperesent the name
+ * each each vector item (as opposed to items of the complex type).
+ * If structSizePtr is 0 and dataCount is 1, it will attempt to work out the size from the dataType
+ * (otherwise it will assert). The casting allows the Variable to be seen in a different type to its actual representation
+ * (e.g. as an arry of floats instead of doubles). If dataCastTypes == 0, then no casting is done for any component. The
+ * size of the struct, the size of the array and the pointer to the array are provided as pointers to this information, of
+ * which will get resolved/dereferenced at the build phase. */
+ Variable* Variable_New(
+ Name name,
+ AbstractContext* context,
+ Index dataCount,
+ SizeT* dataOffsets,
+ Variable_DataType* dataTypes,
+ Index* dataTypeCounts,
+ Name* dataNames,
+ SizeT* structSizePtr,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Variable_Register* vr );
+
+ Variable* _Variable_DefaultNew( Name name );
+
+ /** Creates a new Variable. A Variable holds the run-time information of a complex data type created by the programmer.
+ * Essentially it associates a textual name to a variable in the program that the user can use to access or modify.
+ *
+ * See Variable_New for more info.
+ *
+ * This constructor is a shortcut to create a Variable of a scalar in an array. The stride/struct size is the size
+ * of the dataType. There is no casting. */
+ Variable* Variable_NewScalar(
+ Name name,
+ AbstractContext* context,
+ Variable_DataType dataType,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Variable_Register* vr );
+
+ /** Creates a new Variable. A Variable holds the run-time information of a complex data type created by the programmer.
+ * Essentially it associates a textual name to a variable in the program that the user can use to access or modify.
+ *
+ * See Variable_New for more info.
+ *
+ * This constructor is a shortcut to create a Variable of a vector in an array. The names of the vector components are
+ * optional and are specified via the variable arguement list at the end. A 0 value signifies no name for the associated
+ * vector component. The stride/struct size is the size of the dataType. There is no casting.*/
+ Variable* Variable_NewVector(
+ Name name,
+ AbstractContext* context,
+ Variable_DataType dataType,
+ Index dataTypeCount,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Variable_Register* vr,
+ ... /* vector component names */ );
+
+ Variable* Variable_NewVector2(
+ Name name,
+ AbstractContext* context,
+ Variable_DataType dataType,
+ Index dataTypeCount,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Variable_Register* vr,
+ char** dataNames );
+
+ /** Constructor interface. */
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define VARIABLE_DEFARGS \
+ STG_COMPONENT_DEFARGS, \
+ Index dataCount, \
+ SizeT* dataOffsets, \
+ Variable_DataType* dataTypes, \
+ Index* dataTypeCounts, \
+ Name* dataNames, \
+ SizeT* structSizePtr, \
+ Index* arraySizePtr, \
+ Variable_ArraySizeFunc* arraySizeFunc, \
+ void** arrayPtrPtr, \
+ Variable_Register* vr
+
+ #define VARIABLE_PASSARGS \
+ STG_COMPONENT_PASSARGS, \
+ dataCount, \
+ dataOffsets, \
+ dataTypes, \
+ dataTypeCounts, \
+ dataNames, \
+ structSizePtr, \
+ arraySizePtr, \
+ arraySizeFunc, \
+ arrayPtrPtr, \
+ vr
+
+ Variable* _Variable_New( VARIABLE_DEFARGS );
+
+ /** Init interface. */
+ void _Variable_Init(
+ Variable* self,
+ AbstractContext* context,
+ Index dataCount,
+ SizeT* dataOffsets,
+ Variable_DataType* dataTypes,
+ Index* dataTypeCounts,
+ Name* dataNames,
+ SizeT* structSizePtr,
+ Index* arraySizePtr,
+ Variable_ArraySizeFunc* arraySizeFunc,
+ void** arrayPtrPtr,
+ Bool allocateSelf,
+ Variable_Register* vr );
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ /** Stg_Class_Delete Variable implementation */
+ void _Variable_Delete( void* variable );
+
+ /** Print Variable implementation */
+ void _Variable_Print( void* variable, Stream* stream );
+
+ /** Copy implementation */
+ #define Variable_Copy( self ) \
+ (Variable*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+ #define Variable_DeepCopy( self ) \
+ (Variable*)Stg_Class_Copy( self, NULL, True, NULL, NULL )
+
+ void* _Variable_Copy( void* variable, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
+
+ /** Build implementation */
+ void _Variable_Build( void* variable, void* data );
+
+ /** Initialisation implementation */
+ void _Variable_Initialise( void* variable, void* data );
+
+ /** Execution implementation */
+ void _Variable_Execute( void* variable, void* data );
+
+ void _Variable_AssignFromXML( void* variable, Stg_ComponentFactory* cf, void* data );
+
+ void _Variable_Destroy( void* variable, void* data );
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions: Fundamental address calculators
+ */
+
+ /** Implementation of "get" the structure in an array, that the requested data member is in. Private (Do not directly
+ * use!)
+ * NB:- the array_I needs to be cast to an ArithPointer below - see __Variable_GetPtr() for reason. */
+ #define __Variable_GetStructPtr( self, array_I ) \
+ ( ( (self)->offsetCount < 2 ) ? \
+ ( (void*)( (ArithPointer)(self)->arrayPtr + (ArithPointer)(array_I) * (ArithPointer)( (self)->structSize) + (ArithPointer)( (self)->offsets[0] ) )) : \
+ ( (void*)((ArithPointer)(self)->arrayPtr + (ArithPointer)(array_I) * (ArithPointer)((self)->structSize)) ) )
+ #ifdef CAUTContextUS
+ /** Implementation of "get" the structure in an array that the requested data member is in if CAUTContextUS is defined.
+ * It ensures that array_I is within its bounds. Private (Do not directly use!) */
+ #define _Variable_GetStructPtr( self, array_I ) \
+ ( ((array_I) < (self)->arraySize) ? \
+ __Variable_GetStructPtr( (self), (array_I) ) : \
+ /*TODO : call J_Firewall, then return NULL. */ \
+ (void*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable %s, in macro _Variable_GetStructPtr: requested array index %d " \
+ "out of range (array size is %d). Exiting.\n", (self)->name, array_I, \
+ (self)->arraySize ), NULL) )
+ #else
+ /** Implementation of "get" the structure in an array, that the requested data member is in if CAUTContextUS is NOT
+ * defined. It DOES NOT ensure that array_I is within its bounds. Private (Do not directly use!) */
+ #define _Variable_GetStructPtr __Variable_GetStructPtr
+ #endif
+
+
+/* BUG!: ( (void*)((ArithPointer)_Variable_GetStructPtr( (self), (array_I) ) + (self)->offsets[component_I]) ) */
+
+ /** Implementation of "get" the requested data member in a structure in an array. Private (Do not directly use!)
+ NB - we cast the array_I to an ArithPointer since its usually passed in as an Index (unsigned int), which on
+ some architectures such as the SGI Altix is of a different size to the ArithPointer (unsigned long) */
+ #define __Variable_GetPtr( self, array_I, component_I, vector_I ) \
+ ( (void*)((ArithPointer)(self)->arrayPtr + (ArithPointer)(array_I) * (self)->structSize + (self)->offsets[component_I]) )
+ #ifdef CAUTContextUS
+ /** Implementation of "get" the requested data member in a structure in an array if CAUTContextUS is defined.
+ * It ensures that component_I and array_I are within its bounds. Private (Do not directly use!) */
+ #define _Variable_GetPtr( self, array_I, component_I, vector_I ) \
+ ( ((component_I) < (self)->offsetCount) ? \
+ __Variable_GetPtr( (self), (array_I), (component_I), (vector_I) ) :\
+ (void*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Offset array_I out of range\n" ), NULL) )
+ #else
+ /** Implementation of "get" the requested data member in a structure in an array if CAUTContextUS is NOT
+ * defined. It DOES NOT ensure that component_I and array_I are within its bounds. Private (Do not directly
+ * use!) */
+ #define _Variable_GetPtr __Variable_GetPtr
+ #endif
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public Member functions: Assuming this is a Variable of a "char" inbuilt type
+ */
+
+ /** Assuming this is a Variable of a "char" inbuilt type, return a pointer to that char (type casted to char*). Private
+ * (Do not directly use!). */
+ #define _Variable_GetPtrChar( self, array_I ) \
+ ( (char*)_Variable_GetStructPtr( (self), (array_I) ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a "char" inbuilt type, return a pointer to that char (type casted to char*).
+ * It ensures the Variable is of a "char" and is not complex. */
+ #define Variable_GetPtrChar( self, array_I ) \
+ ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Char) ? \
+ _Variable_GetPtrChar( (self), (array_I) ) : \
+ (char*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of a char or is complex, but this macro assumes so.\n" ), NULL) )
+ #else
+ /** Assuming this is a Variable of a "char" inbuilt type, return a pointer to that char (type casted to char*).
+ * It DOES NOT ensure the Variable is of a "char" and is not complex. */
+ #define Variable_GetPtrChar _Variable_GetPtrChar
+ #endif
+
+
+ /** Assuming this is a Variable of a vector "char" inbuilt type, return that char. Private (Do not directly use!). */
+ #define _Variable_GetValueAtChar( self, array_I, vector_I ) \
+ ( Variable_GetPtrChar( (self), (array_I) )[(vector_I)] )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a vector "char" inbuilt type, return that char. It ensures that vector_I is
+ * within range. */
+ #define Variable_GetValueAtChar( self, array_I, vector_I ) \
+ ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
+ _Variable_GetValueAtChar( (self), (array_I), (vector_I) ) : \
+ (char)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Index into vector of inbuild type is out of range.\n" ) )
+ #else
+ /** Assuming this is a Variable of a vector "char" inbuilt type, return that char. It DOES NOT ensure that
+ * vector_I is within range. */
+ #define Variable_GetValueAtChar _Variable_GetValueAtChar
+ #endif
+
+ /** Assuming this is a Variable of a vector "char" inbuilt type, return a pointer to that char. */
+ #define Variable_GetPtrAtChar( self, array_I, vector_I ) \
+ ( &_Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
+
+
+ /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as a short */
+ #define Variable_GetValueAtCharAsShort( self, array_I, vector_I ) \
+ ( (short)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as an int */
+ #define Variable_GetValueAtCharAsInt( self, array_I, vector_I ) \
+ ( (int)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as a float */
+ #define Variable_GetValueAtCharAsFloat( self, array_I, vector_I ) \
+ ( (float)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as a double */
+ #define Variable_GetValueAtCharAsDouble( self, array_I, vector_I ) \
+ ( (double)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "char" inbuilt type, return that char as a pointer (void*) */
+ #define Variable_GetValueAtCharAsPointer( self, array_I, vector_I ) \
+ ( (void*)( (int)Variable_GetValueAtChar( (self), (array_I), (vector_I) ) ) )
+
+ /** Assuming this is a Variable of a vector "char" inbuilt type, set that char to a new value (internally type casted to char) */
+ #define Variable_SetValueAtChar( self, array_I, vector_I, value ) \
+ ( *Variable_GetPtrAtChar( (self), (array_I), (vector_I) ) = (char)(value) )
+
+
+ /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char */
+ #define Variable_GetValueChar( self, array_I ) \
+ ( Variable_GetValueAtChar( (self), (array_I), 0 ) )
+
+ /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as a short */
+ #define Variable_GetValueCharAsShort( self, array_I ) \
+ ( (short)Variable_GetValueChar( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as an int */
+ #define Variable_GetValueCharAsInt( self, array_I ) \
+ ( (int)Variable_GetValueChar( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as a float */
+ #define Variable_GetValueCharAsFloat( self, array_I ) \
+ ( (float)Variable_GetValueChar( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as a double */
+ #define Variable_GetValueCharAsDouble( self, array_I ) \
+ ( (double)Variable_GetValueChar( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "char" inbuilt type, return that char as a pointer (void*) */
+ #define Variable_GetValueCharAsPointer( self, array_I ) \
+ ( (void*)( (int)Variable_GetValueChar( (self), (array_I) ) ) )
+
+ /** Assuming this is a Variable of a scalar "char" inbuilt type, set that char to a new value (internally type casted to
+ * char) */
+ #define Variable_SetValueChar( self, array_I, value ) \
+ ( *Variable_GetPtrChar( (self), (array_I) ) = (char)(value) )
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public Member functions: Assuming this is a Variable of a "short" inbuilt type
+ */
+
+ /** Assuming this is a Variable of a "short" inbuilt type, return a pointer to that short (type casted to short*). Private
+ * (Do not directly use!). */
+ #define _Variable_GetPtrShort( self, array_I ) \
+ ( (short*)_Variable_GetStructPtr( (self), (array_I) ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a "short" inbuilt type, return a pointer to that short (type casted to short*).
+ * It ensures the Variable is of a "short" and is not complex. */
+ #define Variable_GetPtrShort( self, array_I ) \
+ ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Short) ? \
+ _Variable_GetPtrShort( (self), (array_I) ) : \
+ (short*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of a short or is complex, but this macro assumes so.\n" ), NULL) )
+ #else
+ /** Assuming this is a Variable of a "short" inbuilt type, return a pointer to that short (type casted to short*).
+ * It DOES NOT ensure the Variable is of a "short" and is not complex. */
+ #define Variable_GetPtrShort _Variable_GetPtrShort
+ #endif
+
+
+ /** Assuming this is a Variable of a vector "short" inbuilt type, return that short. Private (Do not directly use!). */
+ #define _Variable_GetValueAtShort( self, array_I, vector_I ) \
+ ( Variable_GetPtrShort( (self), (array_I) )[(vector_I)] )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a vector "short" inbuilt type, return that short. It ensures that vector_I is
+ * within range. */
+ #define Variable_GetValueAtShort( self, array_I, vector_I ) \
+ ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
+ _Variable_GetValueAtShort( (self), (array_I), (vector_I) ) : \
+ (short)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Index into vector of inbuild type is out of range.\n" ) )
+ #else
+ /** Assuming this is a Variable of a vector "short" inbuilt type, return that short. It DOES NOT ensure that
+ * vector_I is within range. */
+ #define Variable_GetValueAtShort _Variable_GetValueAtShort
+ #endif
+
+ /** Assuming this is a Variable of a vector "short" inbuilt type, return a pointer to that short. */
+ #define Variable_GetPtrAtShort( self, array_I, vector_I ) \
+ ( &_Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
+
+
+ /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as a char */
+ #define Variable_GetValueAtShortAsChar( self, array_I, vector_I ) \
+ ( (char)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as an int */
+ #define Variable_GetValueAtShortAsInt( self, array_I, vector_I ) \
+ ( (int)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as a float */
+ #define Variable_GetValueAtShortAsFloat( self, array_I, vector_I ) \
+ ( (float)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as a double */
+ #define Variable_GetValueAtShortAsDouble( self, array_I, vector_I ) \
+ ( (double)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "short" inbuilt type, return that short as a pointer (void*) */
+ #define Variable_GetValueAtShortAsPointer( self, array_I, vector_I ) \
+ ( (void*)( (int)Variable_GetValueAtShort( (self), (array_I), (vector_I) ) ) )
+
+ /** Assuming this is a Variable of a vector "short" inbuilt type, set that short to a new value (internally type casted to
+ * short)*/
+ #define Variable_SetValueAtShort( self, array_I, vector_I, value ) \
+ ( *Variable_GetPtrAtShort( self, array_I, vector_I ) = (short)(value) )
+
+
+ /** Assuming this is a Variable of a "short" inbuilt type, return that short */
+ #define Variable_GetValueShort( self, array_I ) \
+ ( Variable_GetValueAtShort( (self), (array_I), 0 ) )
+
+ /** Assuming this is a Variable of a "short" inbuilt type, return that short as a char */
+ #define Variable_GetValueShortAsChar( self, array_I ) \
+ ( (char)Variable_GetValueShort( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a "short" inbuilt type, return that short as an int */
+ #define Variable_GetValueShortAsInt( self, array_I ) \
+ ( (int)Variable_GetValueShort( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a "short" inbuilt type, return that short as a float */
+ #define Variable_GetValueShortAsFloat( self, array_I ) \
+ ( (float)Variable_GetValueShort( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a "short" inbuilt type, return that short as a double */
+ #define Variable_GetValueShortAsDouble( self, array_I ) \
+ ( (double)Variable_GetValueShort( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a "short" inbuilt type, return that short as a pointer (void*) */
+ #define Variable_GetValueShortAsPointer( self, array_I ) \
+ ( (void*)( (int)Variable_GetValueShort( (self), (array_I) ) ) )
+
+ /** Assuming this is a Variable of a "short" inbuilt type, set that short to a new value (internally type casted to
+ * short)*/
+ #define Variable_SetValueShort( self, array_I, value ) \
+ ( *Variable_GetPtrShort( self, array_I ) = (short)(value) )
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public Member functions: Assuming this is a Variable of a "int" inbuilt type
+ */
+
+ /** Assuming this is a Variable of a "int" inbuilt type, return a pointer to that int (type casted to int*). Private
+ * (Do not directly use!). */
+ #define _Variable_GetPtrInt( self, array_I ) \
+ ( (int*)_Variable_GetStructPtr( (self), (array_I) ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a "int" inbuilt type, return a pointer to that int (type casted to int*).
+ * It ensures the Variable is of a "int" and is not complex. */
+ #define Variable_GetPtrInt( self, array_I ) \
+ ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Int) ? \
+ _Variable_GetPtrInt( (self), (array_I) ) : \
+ (int*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of a int or is complex, but this macro assumes so.\n" ),NULL) )
+ #else
+ /** Assuming this is a Variable of a "int" inbuilt type, return a pointer to that int (type casted to int*).
+ * It DOES NOT ensure the Variable is of a "int" and is not complex. */
+ #define Variable_GetPtrInt _Variable_GetPtrInt
+ #endif
+
+
+ /** Assuming this is a Variable of a vector "int" inbuilt type, return that int. Private (Do not directly use!). */
+ #define _Variable_GetValueAtInt( self, array_I, vector_I ) \
+ ( Variable_GetPtrInt( (self), (array_I) )[(vector_I)] )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a vector "int" inbuilt type, return that int. It ensures that vector_I is
+ * within range. */
+ #define Variable_GetValueAtInt( self, array_I, vector_I ) \
+ ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
+ _Variable_GetValueAtInt( (self), (array_I), (vector_I) ) : \
+ (int)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Index into vector of inbuild type is out of range.\n" ) )
+ #else
+ /** Assuming this is a Variable of a vector "int" inbuilt type, return that int. It DOES NOT ensure that
+ * vector_I is within range. */
+ #define Variable_GetValueAtInt _Variable_GetValueAtInt
+ #endif
+
+ /** Assuming this is a Variable of a vector "int" inbuilt type, return a pointer to that int. */
+ #define Variable_GetPtrAtInt( self, array_I, vector_I ) \
+ ( &_Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
+
+
+ /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a char */
+ #define Variable_GetValueAtIntAsChar( self, array_I, vector_I ) \
+ ( (char)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a short */
+ #define Variable_GetValueAtIntAsShort( self, array_I, vector_I ) \
+ ( (short)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a float */
+ #define Variable_GetValueAtIntAsFloat( self, array_I, vector_I ) \
+ ( (float)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a double */
+ #define Variable_GetValueAtIntAsDouble( self, array_I, vector_I ) \
+ ( (double)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "int" inbuilt type, return that int as a pointer (void*) */
+ #define Variable_GetValueAtIntAsPointer( self, array_I, vector_I ) \
+ ( (void*)Variable_GetValueAtInt( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "int" inbuilt type, set that int to a new value (internally type casted to int) */
+ #define Variable_SetValueAtInt( self, array_I, vector_I, value ) \
+ ( *Variable_GetPtrAtInt( (self), (array_I), (vector_I) ) = (int)(value) )
+
+
+ /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int */
+ #define Variable_GetValueInt( self, array_I ) \
+ ( Variable_GetValueAtInt( (self), (array_I), 0 ) )
+
+ /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a char */
+ #define Variable_GetValueIntAsChar( self, array_I ) \
+ ( (char)Variable_GetValueInt( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a short */
+ #define Variable_GetValueIntAsShort( self, array_I ) \
+ ( (short)Variable_GetValueInt( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a float */
+ #define Variable_GetValueIntAsFloat( self, array_I ) \
+ ( (float)Variable_GetValueInt( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a double */
+ #define Variable_GetValueIntAsDouble( self, array_I ) \
+ ( (double)Variable_GetValueInt( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "int" inbuilt type, return that int as a pointer (void*) */
+ #define Variable_GetValueIntAsPointer( self, array_I ) \
+ ( (void*)Variable_GetValueInt( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "int" inbuilt type, set that int to a new value (internally type casted to int) */
+ #define Variable_SetValueInt( self, array_I, value ) \
+ ( *Variable_GetPtrInt( (self), (array_I) ) = (int)(value) )
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public Member functions: Assuming this is a Variable of a "float" inbuilt type
+ */
+
+ /** Assuming this is a Variable of a "float" inbuilt type, return a pointer to that float (type casted to float*). Private
+ * (Do not directly use!). */
+ #define _Variable_GetPtrFloat( self, array_I ) \
+ ( (float*)_Variable_GetStructPtr( (self), (array_I) ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a "float" inbuilt type, return a pointer to that float (type casted to float*).
+ * It ensures the Variable is of a "float" and is not complex. */
+ #define Variable_GetPtrFloat( self, array_I ) \
+ ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Float) ? \
+ _Variable_GetPtrFloat( (self), (array_I) ) : \
+ (float*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of a float or is complex, but this macro assumes so.\n" ), NULL) )
+ #else
+ /** Assuming this is a Variable of a "float" inbuilt type, return a pointer to that float (type casted to float*).
+ * It DOES NOT ensure the Variable is of a "float" and is not complex. */
+ #define Variable_GetPtrFloat _Variable_GetPtrFloat
+ #endif
+
+
+ /** Assuming this is a Variable of a vector "float" inbuilt type, return that float. Private (Do not directly use!). */
+ #define _Variable_GetValueAtFloat( self, array_I, vector_I ) \
+ ( Variable_GetPtrFloat( (self), (array_I) )[(vector_I)] )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a vector "float" inbuilt type, return that float. It ensures that vector_I is
+ * within range. */
+ #define Variable_GetValueAtFloat( self, array_I, vector_I ) \
+ ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
+ _Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) : \
+ (float)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Index into vector of inbuild type is out of range.\n" ) )
+ #else
+ /** Assuming this is a Variable of a vector "float" inbuilt type, return that float. It DOES NOT ensure that
+ * vector_I is within range. */
+ #define Variable_GetValueAtFloat _Variable_GetValueAtFloat
+ #endif
+
+ /** Assuming this is a Variable of a vector "float" inbuilt type, return a pointer to that float. */
+ #define Variable_GetPtrAtFloat( self, array_I, vector_I ) \
+ ( &_Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
+
+
+ /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as a char */
+ #define Variable_GetValueAtFloatAsChar( self, array_I, vector_I ) \
+ ( (char)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as a short */
+ #define Variable_GetValueAtFloatAsShort( self, array_I, vector_I ) \
+ ( (short)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as an int */
+ #define Variable_GetValueAtFloatAsInt( self, array_I, vector_I ) \
+ ( (int)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as a double */
+ #define Variable_GetValueAtFloatAsDouble( self, array_I, vector_I ) \
+ ( (double)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "float" inbuilt type, return that float as a pointer (void*) */
+ #define Variable_GetValueAtFloatAsPointer( self, array_I, vector_I ) \
+ ( (void*)( (int)Variable_GetValueAtFloat( (self), (array_I), (vector_I) ) ) )
+
+ /** Assuming this is a Variable of a vector "float" inbuilt type, set that float to a new value (internally type casted to
+ * float) */
+ #define Variable_SetValueAtFloat( self, array_I, vector_I, value ) \
+ ( *Variable_GetPtrAtFloat( (self), (array_I), (vector_I) ) = (float)(value) )
+
+
+ /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float */
+ #define Variable_GetValueFloat( self, array_I ) \
+ ( Variable_GetValueAtFloat( (self), (array_I), 0 ) )
+
+ /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as a char */
+ #define Variable_GetValueFloatAsChar( self, array_I ) \
+ ( (char)Variable_GetValueFloat( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as a short */
+ #define Variable_GetValueFloatAsShort( self, array_I ) \
+ ( (short)Variable_GetValueFloat( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as an int */
+ #define Variable_GetValueFloatAsInt( self, array_I ) \
+ ( (int)Variable_GetValueFloat( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as a double */
+ #define Variable_GetValueFloatAsDouble( self, array_I ) \
+ ( (double)Variable_GetValueFloat( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "float" inbuilt type, return that float as a pointer (void*) */
+ #define Variable_GetValueFloatAsPointer( self, array_I ) \
+ ( (void*)( (int)Variable_GetValueFloat( (self), (array_I) ) ) )
+
+ /** Assuming this is a Variable of a scalar "float" inbuilt type, set that float to a new value (internally type casted to
+ * float) */
+ #define Variable_SetValueFloat( self, array_I, value ) \
+ ( *Variable_GetPtrFloat( (self), (array_I) ) = (float)(value) )
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public Member functions: Assuming this is a Variable of a "double" inbuilt type
+ */
+
+ /** Assuming this is a Variable of a "double" inbuilt type, return a pointer to that double (type casted to double*).
+ * Private (Do not directly use!). */
+ #define _Variable_GetPtrDouble( self, array_I ) \
+ ( (double*)_Variable_GetStructPtr( (self), (array_I) ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a "double" inbuilt type, return a pointer to that double (type casted to
+ * double*). It ensures the Variable is of a "double" and is not complex. */
+ #define Variable_GetPtrDouble( self, array_I ) \
+ ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Double) ? \
+ _Variable_GetPtrDouble( (self), (array_I) ) : \
+ (double*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of a double or is complex, but this macro assumes so.\n" ), NULL) )
+ #else
+ /** Assuming this is a Variable of a "double" inbuilt type, return a pointer to that double (type casted to
+ * double*). It DOES NOT ensure the Variable is of a "double" and is not complex. */
+ #define Variable_GetPtrDouble _Variable_GetPtrDouble
+ #endif
+
+
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return that double. Private (Do not directly use!). */
+ #define _Variable_GetValueAtDouble( self, array_I, vector_I ) \
+ ( (Variable_GetPtrDouble( (self), (array_I) ))[(vector_I)] )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return that double. It ensures that vector_I is
+ * within range. */
+ #define Variable_GetValueAtDouble( self, array_I, vector_I ) \
+ ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
+ _Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) : \
+ (double)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Index into vector of inbuild type is out of range.\n" ) )
+ #else
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return that double. It DOES NOT ensure that
+ * vector_I is within range. */
+ #define Variable_GetValueAtDouble _Variable_GetValueAtDouble
+ #endif
+
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return a pointer to that double. */
+ #define Variable_GetPtrAtDouble( self, array_I, vector_I ) \
+ ( &_Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
+
+
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a char */
+ #define Variable_GetValueAtDoubleAsChar( self, array_I, vector_I ) \
+ ( (char)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a short */
+ #define Variable_GetValueAtDoubleAsShort( self, array_I, vector_I ) \
+ ( (short)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a int */
+ #define Variable_GetValueAtDoubleAsInt( self, array_I, vector_I ) \
+ ( (int)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a float */
+ #define Variable_GetValueAtDoubleAsFloat( self, array_I, vector_I ) \
+ ( (float)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a double */
+ #define Variable_GetValueAtDoubleAsDouble( self, array_I, vector_I ) \
+ ( (double)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "double" inbuilt type, return that double as a pointer (void*) */
+ #define Variable_GetValueAtDoubleAsPointer( self, array_I, vector_I ) \
+ ( (void*)( (int)Variable_GetValueAtDouble( (self), (array_I), (vector_I) ) ) )
+
+ /** Assuming this is a Variable of a vector "double" inbuilt type, set that double to a new value (internally type casted to
+ * double) */
+ #define Variable_SetValueAtDouble( self, array_I, vector_I, value ) \
+ ( *Variable_GetPtrAtDouble( (self), (array_I), (vector_I) ) = (double)(value) )
+
+
+ /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double */
+ #define Variable_GetValueDouble( self, array_I ) \
+ ( Variable_GetValueAtDouble( (self), (array_I), 0 ) )
+
+ /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a char */
+ #define Variable_GetValueDoubleAsChar( self, array_I ) \
+ ( (char)Variable_GetValueDouble( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a short */
+ #define Variable_GetValueDoubleAsShort( self, array_I ) \
+ ( (short)Variable_GetValueDouble( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a int */
+ #define Variable_GetValueDoubleAsInt( self, array_I ) \
+ ( (int)Variable_GetValueDouble( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a float */
+ #define Variable_GetValueDoubleAsFloat( self, array_I ) \
+ ( (float)Variable_GetValueDouble( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a double */
+ #define Variable_GetValueDoubleAsDouble( self, array_I ) \
+ ( (double)Variable_GetValueDouble( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "double" inbuilt type, return that double as a pointer (void*) */
+ #define Variable_GetValueDoubleAsPointer( self, array_I ) \
+ ( (void*)( (int)Variable_GetValueDouble( (self), (array_I) ) ) )
+
+ /** Assuming this is a Variable of a scalar "double" inbuilt type, set that double to a new value (internally type casted to
+ * double) */
+ #define Variable_SetValueDouble( self, array_I, value ) \
+ ( *Variable_GetPtrDouble( (self), (array_I) ) = (double)(value) )
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public Member functions: Assuming this is a Variable of a "pointer" inbuilt type
+ */
+
+ /** Assuming this is a Variable of a "pointer" inbuilt type, return a pointer to that pointer (type casted to void**).
+ * Private. (Do not directly use!). */
+ #define _Variable_GetPtrPointer( self, array_I ) \
+ ( (void**)_Variable_GetStructPtr( (self), (array_I) ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a "pointer" inbuilt type, return a pointer to that pointer (type casted to
+ * void**). It ensures the Variable is of a "pointer" and is not complex. */
+ #define Variable_GetPtrPointer( self, array_I ) \
+ ( ((self)->offsetCount == 1 && (self)->dataTypes[0] == Variable_DataType_Pointer) ? \
+ _Variable_GetPtrPointer( (self), (array_I) ) : \
+ (void**)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of a pointer or is complex, but this macro assumes so.\n" ), NULL) )
+ #else
+ /** Assuming this is a Variable of a "pointer" inbuilt type, return a pointer to that pointer (type casted to
+ * void**). It DOES NOT ensure the Variable is of a "pointer" and is not complex. */
+ #define Variable_GetPtrPointer _Variable_GetPtrPointer
+ #endif
+
+
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer. Private (Do not directly use!). */
+ #define _Variable_GetValueAtPointer( self, array_I, vector_I ) \
+ ( Variable_GetPtrPointer( (self), (array_I) )[(vector_I)] )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer. It ensures that vector_I is
+ * within range. */
+ #define Variable_GetValueAtPointer( self, array_I, vector_I ) \
+ ( ((vector_I) < (self)->dataTypeCounts[0]) ? \
+ _Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) : \
+ (void*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Index into vector of inbuild type is out of range.\n" ), NULL) )
+ #else
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer. It DOES NOT ensure that
+ * vector_I is within range. */
+ #define Variable_GetValueAtPointer _Variable_GetValueAtPointer
+ #endif
+
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, return a pointer to that pointer. */
+ #define Variable_GetPtrAtPointer( self, array_I, vector_I ) \
+ ( &_Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
+
+
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as a char pointer (char*) */
+ #define Variable_GetValueAtPointerAsCharPointer( self, array_I, vector_I ) \
+ ( (char*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as a short pointer (short*) */
+ #define Variable_GetValueAtPointerAsShortPointer( self, array_I, vector_I ) \
+ ( (short*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as an int pointer (int*) */
+ #define Variable_GetValueAtPointerAsIntPointer( self, array_I, vector_I ) \
+ ( (int*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as a float pointer (float*) */
+ #define Variable_GetValueAtPointerAsFloatPointer( self, array_I, vector_I ) \
+ ( (float*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, return that pointer as a double pointer (double*) */
+ #define Variable_GetValueAtPointerAsDoublePointer( self, array_I, vector_I ) \
+ ( (double*)Variable_GetValueAtPointer( (self), (array_I), (vector_I) ) )
+
+ /** Assuming this is a Variable of a vector "pointer" inbuilt type, set that pointer to a new value (internally type casted to
+ * void*) */
+ #define Variable_SetValueAtPointer( self, array_I, vector_I, value ) \
+ ( *Variable_GetPtrAtPointer( (self), (array_I), (vector_I) ) = (void*)(value) )
+
+
+ /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer (void*) */
+ #define Variable_GetValuePointer( self, array_I ) \
+ ( Variable_GetValueAtPointer( (self), (array_I), 0 ) )
+
+ /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as a char pointer (char*) */
+ #define Variable_GetValuePointerAsCharPointer( self, array_I ) \
+ ( (char*)Variable_GetValuePointer( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as a short pointer (short*) */
+ #define Variable_GetValuePointerAsShortPointer( self, array_I ) \
+ ( (short*)Variable_GetValuePointer( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as an int pointer (int*) */
+ #define Variable_GetValuePointerAsIntPointer( self, array_I ) \
+ ( (int*)Variable_GetValuePointer( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as a float pointer (float*) */
+ #define Variable_GetValuePointerAsFloatPointer( self, array_I ) \
+ ( (float*)Variable_GetValuePointer( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "pointer" inbuilt type, return that pointer as a double pointer (double*) */
+ #define Variable_GetValuePointerAsDoublePointer( self, array_I ) \
+ ( (double*)Variable_GetValuePointer( (self), (array_I) ) )
+
+ /** Assuming this is a Variable of a scalar "pointer" inbuilt type, set that pointer to a new value (internally type casted to
+ * void*) */
+ #define Variable_SetValuePointer( self, array_I, value ) \
+ ( *Variable_GetPtrPointer( (self), (array_I) ) = (void*)(value) )
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public Member functions: Assuming this is a Variable of any inbuilt type
+ */
+
+ /** Assuming this is a Variable of any inbuilt type, return a char (type casted to char). Private. (Do not directly
+ * use!). Resolution order: char, short, int, float, double, pointer. */
+ #define _Variable_GetValueAsChar( self, array_I ) \
+ ( ((self)->dataTypes[0] == Variable_DataType_Char) ? Variable_GetValueChar( (self), (array_I) ) : \
+ ((self)->dataTypes[0] == Variable_DataType_Short) ? Variable_GetValueShortAsChar( (self), (array_I) ) : \
+ ((self)->dataTypes[0] == Variable_DataType_Int) ? Variable_GetValueIntAsChar( (self), (array_I) ) : \
+ ((self)->dataTypes[0] == Variable_DataType_Float) ? Variable_GetValueFloatAsChar( (self), (array_I) ) : \
+ ((self)->dataTypes[0] == Variable_DataType_Double) ? Variable_GetValueDoubleAsChar( (self), (array_I) ) : \
+ (char)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of any inbuilt type, return a char (type casted to char). It ensures the Variable
+ * is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsChar( self, array_I ) \
+ ( ((self)->offsetCount == 1) ? \
+ _Variable_GetValueAsChar( (self), (array_I) ) : \
+ (char)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is complex, but this macro assumes not so.\n" ) )
+ #else
+ /** Assuming this is a Variable of any inbuilt type, return a char (type casted to char). It DOES NOT ensure the
+ * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsChar _Variable_GetValueAsChar
+ #endif
+
+ /** Assuming this is a Variable of any inbuilt type, return a short (type casted to short). Private. (Do not directly
+ * use!). Resolution order: char, short, int, float, double, pointer. */
+ #define _Variable_GetValueAsShort( self, array_I ) \
+ ( ((self)->dataTypes[0] == Variable_DataType_Char) ? Variable_GetValueCharAsShort( (self), (array_I) ) : \
+ ((self)->dataTypes[0] == Variable_DataType_Short) ? Variable_GetValueShort( (self), (array_I) ) : \
+ ((self)->dataTypes[0] == Variable_DataType_Int) ? Variable_GetValueIntAsShort( (self), (array_I) ) : \
+ ((self)->dataTypes[0] == Variable_DataType_Float) ? Variable_GetValueFloatAsShort( (self), (array_I) ) : \
+ ((self)->dataTypes[0] == Variable_DataType_Double) ? Variable_GetValueDoubleAsShort( (self), (array_I) ) : \
+ (short)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of any inbuilt type, return a short (type casted to short). It ensures the Variable
+ * is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsShort( self, array_I ) \
+ ( ((self)->offsetCount == 1) ? \
+ _Variable_GetValueAsShort( (self), (array_I) ) : \
+ (short)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is complex, but this macro assumes not so.\n" ) )
+ #else
+ /** Assuming this is a Variable of any inbuilt type, return a short (type casted to short). It DOES NOT ensure the
+ * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsShort _Variable_GetValueAsShort
+ #endif
+
+ /** Assuming this is a Variable of any inbuilt type, return a int (type casted to int). Private. (Do not directly
+ * use!). Resolution order: char, short, int, float, double, pointer. */
+ #define _Variable_GetValueAsInt( self, array_I ) \
+ ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_GetValueCharAsInt( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Short ? Variable_GetValueShortAsInt( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Int ? Variable_GetValueInt( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Float ? Variable_GetValueFloatAsInt( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Double ? Variable_GetValueDoubleAsInt( (self), (array_I) ) : \
+ (int)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of any inbuilt type, return a int (type casted to int). It ensures the Variable
+ * is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsInt( self, array_I ) \
+ ( (self)->offsetCount == 1 ? \
+ _Variable_GetValueAsInt( (self), (array_I) ) : \
+ (int)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is complex, but this macro assumes not so.\n" ) )
+ #else
+ /** Assuming this is a Variable of any inbuilt type, return a int (type casted to int). It DOES NOT ensure the
+ * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsInt _Variable_GetValueAsInt
+ #endif
+
+ /** Assuming this is a Variable of any inbuilt type, return a float (type casted to float). Private. (Do not directly
+ * use!). Resolution order: char, short, int, float, double, pointer.*/
+ #define _Variable_GetValueAsFloat( self, array_I ) \
+ ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_GetValueCharAsFloat( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Short ? Variable_GetValueShortAsFloat( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Int ? Variable_GetValueIntAsFloat( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Float ? Variable_GetValueFloat( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Double ? Variable_GetValueDoubleAsFloat( (self), (array_I) ) : \
+ (float)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of any inbuilt type, return a float (type casted to float). It ensures the Variable
+ * is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsFloat( self, array_I ) \
+ ( (self)->offsetCount == 1 ? \
+ _Variable_GetValueAsFloat( (self), (array_I) ) : \
+ (float)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is complex, but this macro assumes not so.\n" ) )
+ #else
+ /** Assuming this is a Variable of any inbuilt type, return a float (type casted to float). It DOES NOT ensure the
+ * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsFloat _Variable_GetValueAsFloat
+ #endif
+
+ /** Assuming this is a Variable of any inbuilt type, return a double (type casted to double). Private. (Do not directly
+ * use!). Resolution order: char, short, int, float, double, pointer. */
+ #define _Variable_GetValueAsDouble( self, array_I ) \
+ ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_GetValueCharAsDouble( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Short ? Variable_GetValueShortAsDouble( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Int ? Variable_GetValueIntAsDouble( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Float ? Variable_GetValueFloatAsDouble( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Double ? Variable_GetValueDouble( (self), (array_I) ) : \
+ (double)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of any inbuilt type, but this macro assumes so.\n" ) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of any inbuilt type, return a double (type casted to double). It ensures the
+ * Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsDouble( self, array_I ) \
+ ( (self)->offsetCount == 1 ? \
+ _Variable_GetValueAsDouble( (self), (array_I) ) : \
+ (double)Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is complex, but this macro assumes not so.\n" ) )
+ #else
+ /** Assuming this is a Variable of any inbuilt type, return a double (type casted to double). It DOES NOT ensure
+ * the Variable is not complex. Resolution order: char, short, int, float, double, pointer. */
+ #define Variable_GetValueAsDouble _Variable_GetValueAsDouble
+ #endif
+
+ /** Assuming this is a Variable of any inbuilt type, return a pointer (type casted to void*). Private. (Do not directly
+ * use!). Resolution order: pointer, short, int, float, double, pointer. */
+ #define _Variable_GetValueAsPointer( self, array_I ) \
+ ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_GetValueCharAsPointer( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Short ? Variable_GetValueShortAsPointer( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Int ? Variable_GetValueIntAsPointer( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Float ? Variable_GetValueFloatAsPointer( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Double ? Variable_GetValueDoubleAsPointer( (self), (array_I) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Pointer ? Variable_GetValuePointer( (self), (array_I) ) : \
+ (Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of any inbuilt type, but this macro assumes so.\n" ), NULL) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of any inbuilt type, return a pointer (type casted to void*). It ensures the Variable
+ * is not complex. Resolution order: pointer, short, int, float, double, pointer. */
+ #define Variable_GetValueAsPointer( self, array_I ) \
+ ( (self)->offsetCount == 1 ? \
+ _Variable_GetValueAsPointer( (self), (array_I) ) : \
+ (void*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is complex, but this macro assumes not so.\n" ), NULL) )
+ #else
+ /** Assuming this is a Variable of any inbuilt type, return a pointer (type casted to void*). It DOES NOT ensure the
+ * Variable is not complex. Resolution order: pointer, short, int, float, double, pointer. */
+ #define Variable_GetValueAsPointer _Variable_GetValueAsPointer
+ #endif
+
+
+ /** Assuming this is a Variable of any inbuilt type, set the value. Private. (Do not directly use!). Resolution order:
+ * pointer, short, int, float, double, pointer. */
+ #define _Variable_SetValueFromInbuilt( self, array_I, value ) \
+ ( (self)->dataTypes[0] == Variable_DataType_Char ? Variable_SetValueChar( (self), (array_I), (value) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Short ? Variable_SetValueShort( (self), (array_I), (value) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Int ? Variable_SetValueInt( (self), (array_I), (value) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Float ? Variable_SetValueFloat( (self), (array_I), (value) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Double ? Variable_SetValueDouble( (self), (array_I), (value) ) : \
+ (self)->dataTypes[0] == Variable_DataType_Pointer ? Variable_SetValuePointer( (self), (array_I), (value) ) : \
+ (Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is not of any inbuilt type, but this macro assumes so.\n" ), NULL) )
+ #ifdef CAUTContextUS
+ /** Assuming this is a Variable of any inbuilt type, set the value. It ensures the Variable is not complex.
+ * Resolution order: pointer, short, int, float, double, pointer. */
+ #define Variable_SetValueFromInbuilt( self, array_I, value ) \
+ ( (self)->offsetCount == 1 ? \
+ _Variable_SetValueFromInbuilt( (self), (array_I), (value) ) : \
+ (void*)(Journal_Firewall( \
+ 0, \
+ Journal_Register( Error_Type, Variable_Type ), \
+ "Variable is complex, but this macro assumes not so.\n" ), NULL) )
+ #else
+ /** Assuming this is a Variable of any inbuilt type, set the value. It DOES NOT ensure the Variable is not complex.
+ * Resolution order: pointer, short, int, float, double, pointer. */
+ #define Variable_SetValueFromInbuilt _Variable_SetValuefromInBuilt
+ #endif
+
+ /** Finds the new size of the array - replaces the limited ptr way of doing this. */
+ Index _Variable_GetNewArraySize( Variable* self );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public Member functions: for any Variable
+ */
+
+ /** "Get" the requested data from the Variable that may be in an array. The returned value is a void*. If the Variable is
+ * of a basic type, then the pointer to the scalar or the vector itself with the structure (if relevant) is returned. If
+ * the Variable is of a complex type (i.e. it has more than one data component), then the pointer to the structure the
+ * variable repesents is returned. */
+ #define Variable_GetStructPtr _Variable_GetStructPtr
+
+ /** Generic Variable "set". Works for any Variable. For complex Variables, the value must be the array of bytes of all the
+ * data members concatenated (i.e. in marshalled form, not the structured form). Inherently slow operation. */
+ void Variable_SetValue( void* variable, Index array_I, void* value );
+
+ /** Generic Variable "get". Works for any Variable. For complex Variables, the value must be the array of already allocated
+ * bytes of all the data members concatenated (i.e. in marshalled form, not the structured form). Inherently slow
+ * operation. */
+ void Variable_GetValue( void* variable, Index array_I, void* value );
+
+ /** Updates the local members in variable from pointers
+ * Used then the data is resized or extened.
+ * If the data is an array which the array length is changed, this function expects the length */
+ void Variable_Update( void* variable );
+
+ /** Sets value to all entries in array of variable */
+ void Variable_SetValueDoubleAll( void* variable, double value ) ;
+
+ void Variable_SaveToFileAsDoubles( void* variable, char* filename );
+
+ void Variable_ReadFromFileAsDoubles( void* variable, char* filename );
+
+ /** Returns || variable - comparison || / || variable ||,
+ * where ||x|| indicates the Euclidean Norm which is the square root of the sum of the squares for each component in x
+ * i.e. ||x|| = \sqrt{\sum_i x_i^2}*/
+ double Variable_ValueCompare( void* variable, void* _comparison );
+ /** Checks whether || variable - comparison || / || variable || < tolerance */
+ Bool Variable_ValueCompareWithinTolerance( void* variable, void* comparison, double tolerance );
+
+#endif /* __StGermain_Base_Context_Variable__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Variable.meta
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/Variable.meta Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,122 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">Variable</param>
+<param name="Author">Steve Quenette</param>
+<param name="Organisation">VPAC</param>
+<param name="Project">StGermain</param>
+<param name="Location">./StGermain/Base/Context/src/</param>
+<param name="Project Web">http://www.stgermainproject.org/</param>
+<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+<param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
+<param name="Parent">Stg_Component</param>
+<param name="Reference"></param>
+<param name="Summary">Associates a textual label with a piece of data in memory, which can then be referred to via the Variable Register.</param>
+<param name="Description">
+
+<p>Variable makes an association between a defined, textual name and a chunk of data in memory. This data could take the form of a basic type (such as an int or double), or an element of an array, or an entire array or struct. Variable may also index a regular series of non-contiguous locations in memory. This capability to define arbitrary data within a datastructure makes it very powerful.</p>
+
+<p>For example, a Variable can refer to a series of ints in an array with an offset of 1 and a stride of 3. This terminology will be familiar to those who are accustomed with MPI. Once a Variable is defined, it is stored in the Variable Register. Like other Registers of StGermain, it can be accessed by any other Component.
+</p>
+
+<p>The benefit of using Variable is that it provides access to data without the need for the original source code or linking to the header file. Practically everything you need to use the data is supplied by Variable: the memory location, a name for the data, its type and its size.</p>
+
+<p>When specified throught the XML system, the Variable will actually allocate the memory of the underlying memory variable itself. When used in the C API, the Variable must be passed the underlying memory chunk (but the memory chunk itself need not yet be allocated until just before the Variable undergoes its build phase).</p>
+
+<p>The XML implementation of Variable doesn't allow the specification of complex data types or arrays. For arrays, components such as MeshVariable should be used</p>
+
+</param>
+
+
+<list name="Params">
+ <struct>
+ <param name="Name">DataType</param>
+ <param name="Type">String</param>
+ <param name="Default">[Double,Float,Int,Char,Short], None - not specifying causes an error</param>
+ <param name="Description">Specifies the fundamental data type of the variable.</param>
+ </struct>
+ <struct>
+ <param name="Name">Rank</param>
+ <param name="Type">String</param>
+ <param name="Default">[Scalar,Vector], None - not specifying causes an error</param>
+ <param name="Description">Specifies whether the variable is of a vector not. If it is of a vector, VectorComponentCount and names is used to specify the number of vector subcomponents and the name of the variables to create for each component.</param>
+ </struct>
+ <struct>
+ <param name="Name">VectorComponentCount</param>
+ <param name="Type">UnsignedInt</param>
+ <param name="Default">0</param>
+ <param name="Description">The count of subcomponents inside this Variable that are also to become variables.</param>
+ </struct>
+ <struct>
+ <param name="Name">names</param>
+ <param name="Type">list</param>
+ <param name="Default">(empty)</param>
+ <param name="Description">The list of textual names for the subcomponents if this variable. A good example is a Variable named velocity which has the subcomponents vx, vy, vz.</param>
+ </struct>
+</list>
+
+
+<list name="Dependencies">
+</list>
+
+
+<param name="Example"><![CDATA[
+<p>Examples:
+XML version / MDF (Model Description File):
+Unlike the C usage, MDF automatically handles memory allocation.
+</p>
+<p>
+<struct name="velocity">
+ <param name="Type">Variable</param>
+ <param name="Rank">Vector</param>
+ <param name="DataType">Double</param>
+ <param name="VectorComponentCount">3</param>
+ <list name="names">
+ <param>vx</param>
+ <param>vy</param>
+ <param>vz</param>
+ </list>
+</struct>
+</p>
+<p>
+This example create an entry in the variable register of the name "velocity",
+which is a vector of 3 double components. Also, 3 more entries into the variable
+ register will be made, targetting the 3 vector components of "velocity",
+ named "vx", "vy", "vz".
+</p>
+
+<p>C version:
+Using Variable in C is different to the XML implementation because you need to
+ do own memory handling.
+This example is based on the sourcecode in
+~/code/StGermain/Base/Context/tests/testVariable.c </p>
+<p>
+/* Construct phase */
+double* velocity;
+Variable_NewVector("velocity",
+ Variable_DataType_Double,
+ 3,
+ &aSize[1],
+ (void**)&velocity,
+ vr,
+ "vx",
+ "vy",
+ "vz");
+
+/* Build phase*/
+velocity = malloc(...);
+component_Build(v);
+
+A general form of the C version:
+Variable_NewVector(name,
+ type,
+ length,
+ array size,
+ data array,
+ variable register,
+ [optional: list of names of array items]);
+</p>]]>
+</param>
+
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableAllVC.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableAllVC.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,467 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: VariableAllVC.c 2509 2005-01-10 23:39:07Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+#include "Base/Automation/Automation.h"
+
+#include "types.h"
+#include "shortcuts.h"
+#include "Variable.h"
+#include "Variable_Register.h"
+#include "VariableCondition.h"
+#include "VariableAllVC.h"
+
+#include <string.h>
+#include <assert.h>
+
+
+const Type VariableAllVC_Type = "VariableAllVC";
+const Name defaultVariableAllVCName = "defaultVariableAllVCName";
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Constructor
+*/
+
+VariableCondition* VariableAllVC_Factory(
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data )
+{
+ return (VariableCondition*)VariableAllVC_New( defaultVariableAllVCName, context, NULL, variable_Register, conFunc_Register, dictionary, data );
+}
+
+
+VariableAllVC* VariableAllVC_New(
+ Name name,
+ AbstractContext* context,
+ Name _dictionaryEntryName,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data )
+{
+ VariableAllVC* self = _VariableAllVC_DefaultNew( name );
+
+ self->isConstructed = True;
+ _VariableCondition_Init( self, context, variable_Register, conFunc_Register, dictionary );
+ _VariableAllVC_Init( self, _dictionaryEntryName, data );
+
+ return self;
+}
+
+VariableAllVC* _VariableAllVC_DefaultNew( Name name ) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(VariableAllVC);
+ Type type = VariableAllVC_Type;
+ Stg_Class_DeleteFunction* _delete = _VariableAllVC_Delete;
+ Stg_Class_PrintFunction* _print = _VariableAllVC_Print;
+ Stg_Class_CopyFunction* _copy = _VariableAllVC_Copy;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = (Stg_Component_DefaultConstructorFunction*)_VariableAllVC_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _VariableCondition_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _VariableAllVC_Build;
+ Stg_Component_InitialiseFunction* _initialise = _VariableCondition_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _VariableCondition_Execute;
+ Stg_Component_DestroyFunction* _destroy = _VariableAllVC_Destroy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+ VariableCondition_BuildSelfFunc* _buildSelf = _VariableAllVC_BuildSelf;
+ VariableCondition_PrintConciseFunc* _printConcise = _VariableAllVC_PrintConcise;
+ VariableCondition_ReadDictionaryFunc* _readDictionary = _VariableAllVC_ReadDictionary;
+ VariableCondition_GetSetFunc* _getSet = _VariableAllVC_GetSet;
+ VariableCondition_GetVariableCountFunc* _getVariableCount = _VariableAllVC_GetVariableCount;
+ VariableCondition_GetVariableIndexFunc* _getVariableIndex = _VariableAllVC_GetVariableIndex;
+ VariableCondition_GetValueIndexFunc* _getValueIndex = _VariableAllVC_GetValueIndex;
+ VariableCondition_GetValueCountFunc* _getValueCount = _VariableAllVC_GetValueCount;
+ VariableCondition_GetValueFunc* _getValue = _VariableAllVC_GetValue;
+ VariableCondition_ApplyFunc* _apply = _VariableCondition_Apply;
+
+ return (VariableAllVC*)_VariableAllVC_New( VARIABLEALLVC_PASSARGS );
+}
+
+VariableAllVC* _VariableAllVC_New( VARIABLEALLVC_DEFARGS ) {
+ VariableAllVC* self;
+
+ /* Allocate memory/General info */
+ assert( _sizeOfSelf >= sizeof(VariableAllVC) );
+ self = (VariableAllVC*)_VariableCondition_New( VARIABLECONDITION_PASSARGS );
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+
+ return self;
+}
+
+void _VariableAllVC_Init(
+ void* allElementsVC,
+ Name _dictionaryEntryName,
+ void* data )
+{
+ VariableAllVC* self = (VariableAllVC*)allElementsVC;
+
+ self->isConstructed = True;
+ self->_dictionaryEntryName = _dictionaryEntryName;
+ self->data = data;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** General virtual functions
+*/
+
+void _VariableAllVC_ReadDictionary( void* variableCondition, void* dictionary ) {
+ VariableAllVC* self = (VariableAllVC*)variableCondition;
+ Dictionary_Entry_Value* vcDictVal;
+ Dictionary_Entry_Value _vcDictVal;
+ Dictionary_Entry_Value* varsVal;
+ VariableAllVC_Entry_Index entry_I;
+
+ /* Find dictionary entry */
+ if (self->_dictionaryEntryName)
+ vcDictVal = Dictionary_Get( dictionary, self->_dictionaryEntryName );
+ else
+ {
+ vcDictVal = &_vcDictVal;
+ Dictionary_Entry_Value_InitFromStruct( vcDictVal, dictionary );
+ }
+
+ if (vcDictVal)
+ {
+ /* Obtain the variable entries */
+ self->_entryCount = Dictionary_Entry_Value_GetCount(Dictionary_Entry_Value_GetMember(vcDictVal, "variables"));
+ self->_entryTbl = Memory_Alloc_Array( VariableAllVC_Entry, self->_entryCount, "VariableAllVC->_entryTbl" );
+ varsVal = Dictionary_Entry_Value_GetMember(vcDictVal, "variables");
+
+ for (entry_I = 0; entry_I < self->_entryCount; entry_I++)
+ {
+ char* valType;
+ Dictionary_Entry_Value* valueEntry;
+ Dictionary_Entry_Value* varDictListVal;
+
+ varDictListVal = Dictionary_Entry_Value_GetElement(varsVal, entry_I);
+ valueEntry = Dictionary_Entry_Value_GetMember(varDictListVal, "value");
+
+ self->_entryTbl[entry_I].varName = Dictionary_Entry_Value_AsString(
+ Dictionary_Entry_Value_GetMember(varDictListVal, "name"));
+
+ valType = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember(varDictListVal, "type"));
+ if (!strcasecmp(valType, "func"))
+ {
+ char* funcName = Dictionary_Entry_Value_AsString(valueEntry);
+
+ self->_entryTbl[entry_I].value.type = VC_ValueType_CFIndex;
+ self->_entryTbl[entry_I].value.as.typeCFIndex = ConditionFunction_Register_GetIndex(
+ self->conFunc_Register, funcName);
+ }
+ else if (!strcasecmp(valType, "array"))
+ {
+ Dictionary_Entry_Value* valueElement;
+ Index i;
+
+ self->_entryTbl[entry_I].value.type = VC_ValueType_DoubleArray;
+ self->_entryTbl[entry_I].value.as.typeArray.size = Dictionary_Entry_Value_GetCount(valueEntry);
+ self->_entryTbl[entry_I].value.as.typeArray.array = Memory_Alloc_Array( double,
+ self->_entryTbl[entry_I].value.as.typeArray.size,"VariableAllVC->_entryTbl[].value.as.typeArray.array" );
+
+ for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++)
+ {
+ valueElement = Dictionary_Entry_Value_GetElement(valueEntry, i);
+ self->_entryTbl[entry_I].value.as.typeArray.array[i] =
+ Dictionary_Entry_Value_AsDouble(valueElement);
+ }
+ }
+ else if( !strcasecmp( valType, "double" ) || !strcasecmp( valType, "d" ) || !strcasecmp( valType, "float" ) || !strcasecmp( valType, "f" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
+ self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
+ }
+ else if( !strcasecmp( valType, "integer" ) || !strcasecmp( valType, "int" ) || !strcasecmp( valType, "i" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Int;
+ self->_entryTbl[entry_I].value.as.typeInt = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
+ }
+ else if( !strcasecmp( valType, "short" ) || !strcasecmp( valType, "s" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Short;
+ self->_entryTbl[entry_I].value.as.typeShort = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
+ }
+ else if( !strcasecmp( valType, "char" ) || !strcasecmp( valType, "c" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Char;
+ self->_entryTbl[entry_I].value.as.typeChar = Dictionary_Entry_Value_AsUnsignedInt( valueEntry );
+ }
+ else if( !strcasecmp( valType, "pointer" ) || !strcasecmp( valType, "ptr" ) || !strcasecmp( valType, "p" ) ) {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Ptr;
+ self->_entryTbl[entry_I].value.as.typePtr = (void*) ( (ArithPointer) Dictionary_Entry_Value_AsUnsignedInt( valueEntry ));
+ }
+ else {
+ /* Assume double */
+ Journal_DPrintf( Journal_Register( InfoStream_Type, "myStream" ), "Type to variable on variable condition not given, assuming double\n" );
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
+ self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
+ }
+ }
+ }
+ else
+ {
+ self->_entryCount = 0;
+ self->_entryTbl = NULL;
+ }
+}
+
+
+void _VariableAllVC_Delete( void* allElementsVC ) {
+ VariableAllVC* self = (VariableAllVC*)allElementsVC;
+
+ /* Stg_Class_Delete parent */
+ _VariableCondition_Delete( self );
+}
+
+void _VariableAllVC_Destroy( void* allElementsVC, void* data ) {
+ VariableAllVC* self = (VariableAllVC*)allElementsVC;
+
+ if (self->_entryTbl) Memory_Free(self->_entryTbl);
+
+ _VariableCondition_Destroy( self, data );
+}
+
+void _VariableAllVC_Print( void* allElementsVC, Stream* stream ) {
+ VariableAllVC* self = (VariableAllVC*)allElementsVC;
+ VariableAllVC_Entry_Index entry_I;
+ Index i;
+
+ /* Set the Journal for printing informations */
+ Stream* info = stream;
+
+ /* General info */
+ Journal_Printf( info, "VariableAllVC (ptr): %p\n", self);
+
+ /* Print parent */
+ _VariableCondition_Print(self);
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+ Journal_Printf( info, "\tdictionary (ptr): %p\n", self->dictionary);
+ Journal_Printf( info, "\t_dictionaryEntryName (ptr): %p\n", self->_dictionaryEntryName);
+ if (self->_dictionaryEntryName)
+ Journal_Printf( info, "\t\t_dictionaryEntryName: %s\n", self->_dictionaryEntryName);
+ Journal_Printf( info, "\t_entryCount: %u\n", self->_entryCount);
+ Journal_Printf( info, "\t_entryTbl (ptr): %p\n", self->_entryTbl);
+ if( self->_entryTbl ) {
+ for (entry_I = 0; entry_I < self->_entryCount; entry_I++)
+ {
+ Journal_Printf( info, "\t\t_entryTbl[%u]:\n", entry_I);
+ Journal_Printf( info, "\t\t\tvarName (ptr): %p\n", self->_entryTbl[entry_I].varName);
+ if (self->_entryTbl[entry_I].varName)
+ Journal_Printf( info, "\t\t\t\tvarName: %s\n", self->_entryTbl[entry_I].varName);
+ Journal_Printf( info, "\t\t\tvalue:\n");
+ switch (self->_entryTbl[entry_I].value.type)
+ {
+ case VC_ValueType_Double:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Double\n" );
+ Journal_Printf( info, "\t\t\t\tasDouble: %g\n", self->_entryTbl[entry_I].value.as.typeDouble );
+ break;
+
+ case VC_ValueType_Int:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Int\n" );
+ Journal_Printf( info, "\t\t\t\tasInt: %i\n", self->_entryTbl[entry_I].value.as.typeInt );
+ break;
+
+ case VC_ValueType_Short:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Short\n" );
+ Journal_Printf( info, "\t\t\t\tasShort: %i\n", self->_entryTbl[entry_I].value.as.typeShort );
+ break;
+
+ case VC_ValueType_Char:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Char\n");
+ Journal_Printf( info, "\t\t\t\tasChar: %c\n", self->_entryTbl[entry_I].value.as.typeChar );
+ break;
+
+ case VC_ValueType_Ptr:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Ptr\n");
+ Journal_Printf( info, "\t\t\t\tasPtr: %g\n", self->_entryTbl[entry_I].value.as.typePtr );
+ break;
+
+ case VC_ValueType_DoubleArray:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_DoubleArray\n");
+ Journal_Printf( info, "\t\t\t\tarraySize: %u\n", self->_entryTbl[entry_I].value.as.typeArray.size);
+ Journal_Printf( info, "\t\t\t\tasDoubleArray (ptr): %p\n",
+ self->_entryTbl[entry_I].value.as.typeArray.array);
+ if (self->_entryTbl[entry_I].value.as.typeArray.array)
+ for (i = 0; i < self->_entryTbl[entry_I].value.as.typeArray.size; i++)
+ Journal_Printf( info, "\t\t\t\tasDoubleArray[%u]: %g\n", i,
+ self->_entryTbl[entry_I].value.as.typeArray.array[i]);
+ break;
+
+ case VC_ValueType_CFIndex:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_CFIndex\n");
+ Journal_Printf( info, "\t\t\t\tasCFIndex: %u\n", self->_entryTbl[entry_I].value.as.typeCFIndex);
+ break;
+ }
+ }
+ }
+}
+
+
+void* _VariableAllVC_Copy( void* allElementsVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
+ VariableAllVC* self = (VariableAllVC*)allElementsVC;
+ VariableAllVC* newVariableAllVC;
+ PtrMap* map = ptrMap;
+ Bool ownMap = False;
+
+ if( !map ) {
+ map = PtrMap_New( 10 );
+ ownMap = True;
+ }
+
+ newVariableAllVC = (VariableAllVC*)_VariableCondition_Copy( self, dest, deep, nameExt, map );
+
+ newVariableAllVC->_dictionaryEntryName = self->_dictionaryEntryName;
+ newVariableAllVC->_entryCount = self->_entryCount;
+
+ if( deep ) {
+ newVariableAllVC->data = Stg_Class_Copy( self->data, NULL, deep, nameExt, map );
+
+ if( (newVariableAllVC->_entryTbl = PtrMap_Find( map, self->_entryTbl )) == NULL && self->_entryTbl ) {
+ newVariableAllVC->_entryTbl = Memory_Alloc_Array( VariableAllVC_Entry, newVariableAllVC->_entryCount, "VariableAllVC->_entryTbl");
+ memcpy( newVariableAllVC->_entryTbl, self->_entryTbl, sizeof(VariableAllVC_Entry) * newVariableAllVC->_entryCount );
+ PtrMap_Append( map, newVariableAllVC->_entryTbl, self->_entryTbl );
+ }
+ }
+ else {
+ newVariableAllVC->data = self->data;
+ newVariableAllVC->_entryTbl = self->_entryTbl;
+ }
+
+ if( ownMap ) {
+ Stg_Class_Delete( map );
+ }
+
+ return (void*)newVariableAllVC;
+}
+
+
+void _VariableAllVC_Build( void* allElementsVC, void* data ) {
+ VariableAllVC* self = (VariableAllVC*)allElementsVC;
+
+ _VariableAllVC_BuildSelf( self, data );
+
+ _VariableCondition_Build( self, data );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Macros
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _VariableAllVC_BuildSelf( void* allElementsVC, void* data ) {
+ VariableAllVC* self = (VariableAllVC*)allElementsVC;
+
+ if( self->data ) {
+ Stg_Component_Build( self->data, data, False );
+ }
+}
+
+
+IndexSet* _VariableAllVC_GetSet( void* variableCondition ) {
+ VariableAllVC* self = (VariableAllVC*)variableCondition;
+ Variable* var = self->variable_Register->_variable[0];
+ IndexSet* set = IndexSet_New( var->arraySize );
+
+ IndexSet_AddAll( set );
+
+ return set;
+}
+
+
+VariableCondition_VariableIndex _VariableAllVC_GetVariableCount( void* variableCondition, Index globalIndex ) {
+ VariableAllVC* self = (VariableAllVC*)variableCondition;
+
+ return self->_entryCount;
+}
+
+
+Variable_Index _VariableAllVC_GetVariableIndex(
+ void* variableCondition,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex)
+{
+ VariableAllVC* self = (VariableAllVC*)variableCondition;
+
+ return Variable_Register_GetIndex(self->variable_Register, self->_entryTbl[varIndex].varName);
+}
+
+
+VariableCondition_ValueIndex _VariableAllVC_GetValueIndex(
+ void* variableCondition,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex)
+{
+ return varIndex;
+}
+
+
+VariableCondition_ValueIndex _VariableAllVC_GetValueCount( void* variableCondition ) {
+ VariableAllVC* self = (VariableAllVC*)variableCondition;
+
+ return self->_entryCount;
+}
+
+
+VariableCondition_Value _VariableAllVC_GetValue( void* variableCondition, VariableCondition_ValueIndex valIndex ) {
+ VariableAllVC* self = (VariableAllVC*)variableCondition;
+
+ return self->_entryTbl[valIndex].value;
+}
+
+void _VariableAllVC_PrintConcise( void* variableCondition, Stream* stream ) {
+ VariableAllVC* self = (VariableAllVC*)variableCondition;
+
+ Journal_Printf( stream, "\ttype: %s, set: all\n", self->type );
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Build functions
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Functions
+*/
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableAllVC.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableAllVC.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,163 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: VariableAllVC.h 2509 2005-01-10 23:39:07Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Base_Context_VariableAllVC_h__
+#define __StGermain_Base_Context_VariableAllVC_h__
+
+
+ extern const Type VariableAllVC_Type;
+
+
+ #define __VariableAllVC_Entry \
+ Name varName; \
+ VariableCondition_Value value; \
+
+ struct _VariableAllVC_Entry { __VariableAllVC_Entry };
+
+
+ #define __VariableAllVC \
+ /* General info */ \
+ __VariableCondition \
+ \
+ /* Virtual info */ \
+ \
+ /* Stg_Class info */ \
+ Name _dictionaryEntryName; \
+ VariableAllVC_Entry_Index _entryCount; \
+ VariableAllVC_Entry* _entryTbl; \
+ void* data;
+
+ struct _VariableAllVC { __VariableAllVC };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructor
+ */
+
+ VariableCondition* VariableAllVC_Factory(
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* data );
+
+ VariableAllVC* VariableAllVC_New(
+ Name name,
+ AbstractContext* context,
+ Name _dictionaryEntryName,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary,
+ void* mesh );
+
+ VariableAllVC* _VariableAllVC_DefaultNew( Name name );
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define VARIABLEALLVC_DEFARGS \
+ VARIABLECONDITION_DEFARGS
+
+ #define VARIABLEALLVC_PASSARGS \
+ VARIABLECONDITION_PASSARGS
+
+ VariableAllVC* _VariableAllVC_New( VARIABLEALLVC_DEFARGS );
+
+ void _VariableAllVC_Init( void* allElementsVC, Name _dictionaryEntryName, void* mesh );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** General virtual functions
+ */
+
+ void _VariableAllVC_Delete( void* allElementsVC );
+
+ void _VariableAllVC_Print( void* allElementsVC, Stream* stream );
+
+ void _VariableAllVC_Destroy( void* allElementsVC, void* data );
+
+ /* Copy */
+ #define VariableAllVC_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+ #define VariableAllVC_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+
+ void* _VariableAllVC_Copy( void* allElementsVC, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
+
+ void _VariableAllVC_Build( void* allElementsVC, void* data );
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Macros
+ */
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _VariableAllVC_BuildSelf( void* allElementsVC, void* data );
+
+ void _VariableAllVC_ReadDictionary( void* variableCondition, void* dictionary );
+
+ IndexSet* _VariableAllVC_GetSet( void* variableCondition );
+
+ VariableCondition_VariableIndex _VariableAllVC_GetVariableCount( void* variableCondition, Index globalIndex );
+
+ Variable_Index _VariableAllVC_GetVariableIndex( void* variableCondition, Index globalIndex, VariableCondition_VariableIndex varIndex );
+
+ VariableCondition_ValueIndex _VariableAllVC_GetValueIndex( void* variableCondition, Index globalIndex, VariableCondition_VariableIndex varIndex );
+
+ VariableCondition_ValueIndex _VariableAllVC_GetValueCount( void* variableCondition );
+
+ VariableCondition_Value _VariableAllVC_GetValue( void* variableCondition, VariableCondition_ValueIndex valIndex );
+
+ void _VariableAllVC_PrintConcise( void* variableCondition, Stream* stream );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Build functions
+ */
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Functions
+ */
+
+
+#endif /* __StGermain_Base_Context_VariableAllVC_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableAllVC.meta
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableAllVC.meta Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">VariableAllVC</param>
+ <param name="Author">...</param>
+ <param name="Organisation">VPAC</param>
+ <param name="Project">StGermain</param>
+ <param name="Location">./StGermain/Base/Context/src/</param>
+ <param name="Project Web">http://www.stgermainproject.org/</param>
+ <param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+ <param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
+ <param name="Parent">VariableCondition</param>
+ <param name="Reference">...</param>
+ <param name="Summary">...</param>
+
+ <param name="Description">
+ Selects all available entries in a Variable object to have a value
+ applied.
+ </param>
+
+ <list name="Params">
+ <struct>
+ <param name="Name">variables</param>
+ <param name="Type">List</param>
+ <param name="Default"></param>
+ <param name="Description">
+ A list of variable structures describing a Variable object to have values set and
+ the values to apply. Each structure has three parameters: 'name' (the name of the
+ Variable object), 'type' (the type of the value, either double or func) and 'value'
+ (for a double this is a number and for a func this is the name of the condition
+ function).
+ </param>
+ </struct>
+ </list>
+
+ <list name="Dependencies">
+ n/a
+ </list>
+
+ <param name="Example">
+ n/a
+ </param>
+
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableCondition.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableCondition.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,741 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: VariableCondition.c 4297 2008-08-19 16:54:05Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+#include "Base/Automation/Automation.h"
+
+#include "types.h"
+#include "Variable.h"
+#include "Variable_Register.h"
+#include "ConditionFunction.h"
+#include "ConditionFunction_Register.h"
+#include "VariableCondition.h"
+
+#include <string.h>
+#include <assert.h>
+
+/** Textual name of this class */
+const Type VariableCondition_Type = "VariableCondition";
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Constructor
+*/
+
+VariableCondition* _VariableCondition_New( VARIABLECONDITION_DEFARGS ) {
+ VariableCondition* self;
+
+ /* Allocate memory/General info */
+ assert( _sizeOfSelf >= sizeof(VariableCondition) );
+ self = (VariableCondition*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
+
+ /* Virtual info */
+ self->_buildSelf = _buildSelf;
+ self->_printConcise = _printConcise;
+ self->_readDictionary = _readDictionary;
+ self->_getSet = _getSet;
+ self->_getVariableCount = _getVariableCount;
+ self->_getVariableIndex = _getVariableIndex;
+ self->_getValueIndex = _getValueIndex;
+ self->_getValueCount = _getValueCount;
+ self->_getValue = _getValue;
+ self->_apply = _apply;
+
+ /* Stg_Class info */
+
+ return self;
+}
+
+
+void _VariableCondition_Init(
+ void* variableCondition,
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary )
+{
+ VariableCondition* self = (VariableCondition*)variableCondition;
+
+ self->context = context;
+ self->variable_Register = variable_Register;
+ self->conFunc_Register = conFunc_Register;
+ self->dictionary = dictionary;
+ self->_set = NULL;
+ self->indexCount = 0;
+ self->indexTbl = NULL;
+ self->vcVarCountTbl = NULL;
+ self->vcTbl = NULL;
+ self->valueCount = 0;
+ self->valueTbl = NULL;
+ self->mapping = NULL;
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** General virtual functions
+*/
+
+void _VariableCondition_Delete(void* variableCondition) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+
+ /* Stg_Class_Delete parent */
+ _Stg_Component_Delete( self );
+}
+
+
+void _VariableCondition_Print(void* variableCondition) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ VariableCondition_VariableIndex vcVar_I;
+ VariableCondition_ValueIndex val_I;
+ Index i;
+
+ /* Set the Journal for printing informations */
+ Stream* variableConditionStream = Journal_Register( InfoStream_Type, "VariableConditionStream");
+
+ /* General info */
+ Journal_Printf( variableConditionStream, "VariableCondition (ptr): %p\n", self);
+
+ /* Print parent */
+ _Stg_Component_Print( self, variableConditionStream );
+
+ /* Virtual info */
+ Journal_Printf( variableConditionStream, "\t_getSet (func ptr): %p\n", self->_getSet);
+ Journal_Printf( variableConditionStream, "\t_getVariableCount (func ptr): %p\n", self->_getVariableCount);
+ Journal_Printf( variableConditionStream, "\t_getVariableIndex (func ptr): %p\n", self->_getVariableIndex);
+ Journal_Printf( variableConditionStream, "\t_getValueIndex (func ptr): %p\n", self->_getValueIndex);
+ Journal_Printf( variableConditionStream, "\t_getValueCount (func ptr): %p\n", self->_getValueCount);
+ Journal_Printf( variableConditionStream, "\t_getValue (func ptr): %p\n", self->_getValue);
+
+ /* Stg_Class info */
+ Journal_Printf( variableConditionStream, "\tvariable_Register (ptr): %p\n", self->variable_Register);
+ Journal_Printf( variableConditionStream, "\tconFunc_Register (ptr): %p\n", self->conFunc_Register);
+ Journal_Printf( variableConditionStream, "\t_set (ptr): %p\n", self->_set);
+ Journal_Printf( variableConditionStream, "\tindexCount: %u\n", self->indexCount);
+ Journal_Printf( variableConditionStream, "\tindexTbl (ptr): %p\n", self->indexTbl);
+
+ if (self->indexTbl)
+ for (i = 0; i < self->indexCount; i++)
+ Journal_Printf( variableConditionStream, "\t\tindexTbl[%u]: %u\n", i, self->indexTbl[i]);
+ Journal_Printf( variableConditionStream, "\tvcVarCountTbl (ptr): %p\n", self->vcVarCountTbl);
+ if (self->vcVarCountTbl)
+ for (i = 0; i < self->indexCount; i++)
+ Journal_Printf( variableConditionStream, "\t\tvcVarCountTbl[%u]: %u\n", i, self->vcVarCountTbl[i]);
+ Journal_Printf( variableConditionStream, "\tvcTbl (ptr): %p\n", self->vcTbl);
+ if (self->vcTbl)
+ for (i = 0; i < self->indexCount; i++)
+ for (vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++)
+ {
+ Journal_Printf( variableConditionStream, "\t\tvcTbl[%u][%u]:\n", i, vcVar_I);
+ Journal_Printf( variableConditionStream, "\t\t\tvarIndex: %u\n", self->vcTbl[i][vcVar_I].varIndex);
+ Journal_Printf( variableConditionStream, "\t\t\tvalIndex: %u\n", self->vcTbl[i][vcVar_I].valIndex);
+ }
+ Journal_Printf( variableConditionStream, "\tvalueCount: %u\n", self->valueCount);
+ Journal_Printf( variableConditionStream, "\tvalueTbl (ptr): %p\n", self->valueTbl);
+ if( self->valueTbl ) {
+ for (val_I = 0; val_I < self->valueCount; val_I++)
+ {
+ Journal_Printf( variableConditionStream, "\t\tvalueTbl[%u]:\n", val_I);
+ switch (self->valueTbl[val_I].type)
+ {
+ case VC_ValueType_Double:
+ Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Double\n" );
+ Journal_Printf( variableConditionStream, "\t\t\tasDouble: %g\n", self->valueTbl[val_I].as.typeDouble );
+ break;
+
+ case VC_ValueType_Int:
+ Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Int\n" );
+ Journal_Printf( variableConditionStream, "\t\t\tasInt: %i\n", self->valueTbl[val_I].as.typeInt );
+ break;
+
+ case VC_ValueType_Short:
+ Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Short\n" );
+ Journal_Printf( variableConditionStream, "\t\t\tasShort: %i\n", self->valueTbl[val_I].as.typeShort );
+ break;
+
+ case VC_ValueType_Char:
+ Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Char\n");
+ Journal_Printf( variableConditionStream, "\t\t\tasChar: %c\n", self->valueTbl[val_I].as.typeChar );
+ break;
+
+ case VC_ValueType_Ptr:
+ Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_Ptr\n");
+ Journal_Printf( variableConditionStream, "\t\t\tasPtr: %g\n", self->valueTbl[val_I].as.typePtr );
+ break;
+
+ case VC_ValueType_DoubleArray:
+ Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_DoubleArray\n");
+ Journal_Printf( variableConditionStream, "\t\t\tarraySize: %u\n", self->valueTbl[val_I].as.typeArray.size);
+ Journal_Printf( variableConditionStream, "\t\t\tasDoubleArray (ptr): %p\n", self->valueTbl[val_I].as.typeArray.array);
+ if (self->valueTbl[val_I].as.typeArray.array)
+ for (i = 0; i < self->valueTbl[val_I].as.typeArray.size; i++)
+ Journal_Printf( variableConditionStream, "\t\t\t\tasDoubleArray[%u]: %g\n", i,
+ self->valueTbl[val_I].as.typeArray.array[i]);
+ break;
+
+ case VC_ValueType_CFIndex:
+ Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_CFIndex\n");
+ Journal_Printf( variableConditionStream, "\t\t\tasCFIndex: %u\n", self->valueTbl[val_I].as.typeCFIndex);
+ break;
+ }
+ }
+ }
+}
+
+
+void* _VariableCondition_Copy( void* variableCondition, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ VariableCondition* newVariableCondition;
+ PtrMap* map = ptrMap;
+ Bool ownMap = False;
+
+ if( !map ) {
+ map = PtrMap_New( 10 );
+ ownMap = True;
+ }
+
+ newVariableCondition = (VariableCondition*)_Stg_Component_Copy( self, dest, deep, nameExt, map );
+
+ /* Virtual methods */
+ newVariableCondition->_buildSelf = self->_buildSelf;
+ newVariableCondition->_printConcise = self->_printConcise;
+ newVariableCondition->_readDictionary = self->_readDictionary;
+ newVariableCondition->_getSet = self->_getSet;
+ newVariableCondition->_getVariableCount = self->_getVariableCount;
+ newVariableCondition->_getVariableIndex = self->_getVariableIndex;
+ newVariableCondition->_getValueIndex = self->_getValueIndex;
+ newVariableCondition->_getValueCount = self->_getValueCount;
+ newVariableCondition->_getValue = self->_getValue;
+
+ newVariableCondition->variable_Register = self->variable_Register;
+ newVariableCondition->conFunc_Register = self->conFunc_Register;
+ newVariableCondition->dictionary = self->dictionary;
+ newVariableCondition->indexCount = self->indexCount;
+ newVariableCondition->valueCount = self->valueCount;
+
+ if( deep ) {
+ newVariableCondition->_set = (IndexSet*)Stg_Class_Copy( self->_set, NULL, deep, nameExt, map );
+
+ if( (newVariableCondition->indexTbl = PtrMap_Find( map, self->indexTbl )) == NULL && self->indexTbl ) {
+ newVariableCondition->indexTbl = (Index*)Memory_Alloc_Array( Index, newVariableCondition->indexCount, "VariableCondition->indexTbl" );
+ memcpy( newVariableCondition->indexTbl, self->indexTbl, sizeof(Index) * newVariableCondition->indexCount );
+ PtrMap_Append( map, newVariableCondition->indexTbl, self->indexTbl );
+ }
+
+ if( (newVariableCondition->vcVarCountTbl = PtrMap_Find( map, self->vcVarCountTbl )) == NULL && self->vcVarCountTbl ) {
+ newVariableCondition->vcVarCountTbl = Memory_Alloc_Array( VariableCondition_VariableIndex, newVariableCondition->indexCount, "VC->vcVarCountTbl" );
+ memcpy( newVariableCondition->vcVarCountTbl, self->vcVarCountTbl, sizeof(VariableCondition_VariableIndex) * newVariableCondition->indexCount );
+ PtrMap_Append( map, newVariableCondition->vcVarCountTbl, self->vcVarCountTbl );
+ }
+
+ if( (newVariableCondition->vcTbl = PtrMap_Find( map, self->vcTbl )) == NULL && self->vcTbl ) {
+ Index idx_I;
+
+ newVariableCondition->vcTbl = Memory_Alloc_2DComplex( VariableCondition_Tuple, newVariableCondition->indexCount, newVariableCondition->vcVarCountTbl, "VC->vcTbl" );
+ for( idx_I = 0; idx_I < newVariableCondition->indexCount; idx_I++ ) {
+ memcpy( newVariableCondition->vcTbl[idx_I], self->vcTbl[idx_I], sizeof(VariableCondition_Tuple) * newVariableCondition->vcVarCountTbl[idx_I] );
+ }
+ PtrMap_Append( map, newVariableCondition->vcTbl, self->vcTbl );
+ }
+
+ if( (newVariableCondition->valueTbl = PtrMap_Find( map, self->valueTbl )) == NULL && self->valueTbl ) {
+ newVariableCondition->valueTbl = Memory_Alloc_Array( VariableCondition_Value, newVariableCondition->valueCount, "VC->valueTbl" );
+ memcpy( newVariableCondition->valueTbl, self->valueTbl, sizeof(VariableCondition_Value) * newVariableCondition->indexCount );
+ PtrMap_Append( map, newVariableCondition->valueTbl, self->valueTbl );
+ }
+ }
+ else {
+ newVariableCondition->_set = self->_set;
+ newVariableCondition->indexTbl = self->indexTbl;
+ newVariableCondition->vcVarCountTbl = self->vcVarCountTbl;
+ newVariableCondition->vcTbl = self->vcTbl;
+ newVariableCondition->valueTbl = self->valueTbl;
+ }
+
+ if( ownMap ) {
+ Stg_Class_Delete( map );
+ }
+
+ return (void*)newVariableCondition;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Macros
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Build functions
+*/
+
+void _VariableCondition_AssignFromXML( void* variableCondition, Stg_ComponentFactory* cf, void* data ) {
+}
+
+void _VariableCondition_Build( void* variableCondition, void* data ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ VariableCondition_ValueIndex val_I;
+ Index i;
+
+ /* Read the dictionary */
+ self->_readDictionary( self, self->dictionary );
+
+ /* Obtain the set */
+ self->_set = self->_getSet(self);
+ if (self->_set)
+ IndexSet_GetMembers(self->_set, &self->indexCount, &self->indexTbl);
+ else {
+ self->indexCount = 0;
+ self->indexTbl = NULL;
+ }
+
+ /* Only build the index related tables if there are active BCs */
+ if ( self->indexCount ) {
+ /* Build the variable to condition table */
+ self->vcVarCountTbl = Memory_Alloc_Array( VariableCondition_VariableIndex, self->indexCount, "VC->vcVarCountTbl" );
+
+ for (i = 0; i < self->indexCount; i++) {
+ /* For the index, get the number of "variables" that have been assigned conditions */
+ self->vcVarCountTbl[i] = self->_getVariableCount(self, self->indexTbl[i]);
+ }
+
+ self->vcTbl = Memory_Alloc_2DComplex( VariableCondition_Tuple, self->indexCount, self->vcVarCountTbl, "VC->vcTbl" );
+ for ( i = 0; i < self->indexCount; i++ ) {
+ VariableCondition_VariableIndex vcVar_I;
+
+ for ( vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++ ) {
+ Variable* var;
+
+ /* For the index's variable, get the variable i.d. and value i.d. */
+ self->vcTbl[i][vcVar_I].varIndex = self->_getVariableIndex(self, self->indexTbl[i], vcVar_I);
+ self->vcTbl[i][vcVar_I].valIndex = self->_getValueIndex(self, self->indexTbl[i], vcVar_I);
+
+ /* Force the building of the variable (to be safe) */
+ var = self->variable_Register->_variable[self->vcTbl[i][vcVar_I].varIndex];
+ Stg_Component_Build( var, data, False );
+ }
+ }
+ }
+
+ self->valueCount = self->_getValueCount(self);
+ self->valueTbl = Memory_Alloc_Array( VariableCondition_Value, self->valueCount, "VC->valueTbl" );
+ for (val_I = 0; val_I < self->valueCount; val_I++)
+ self->valueTbl[val_I] = self->_getValue(self, val_I);
+
+ /* Build mapping. */
+ self->mapping = UIntMap_New();
+ for( i = 0; i < self->indexCount; i++ )
+ UIntMap_Insert( self->mapping, self->indexTbl[i], i );
+}
+
+void _VariableCondition_Initialise( void* variableCondition, void* data ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ Index i;
+
+ for( i = 0; i < self->indexCount; i++ ) {
+ VariableCondition_VariableIndex vcVar_I;
+
+ for( vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++ ) {
+ Variable* var;
+
+ /* Force the building of the variable (to be safe) */
+ var = self->variable_Register->_variable[self->vcTbl[i][vcVar_I].varIndex];
+ Stg_Component_Initialise( var, data, False );
+ }
+ }
+}
+
+void _VariableCondition_Execute( void* variableCondition, void* data ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+
+ VariableCondition_Apply( self, data );
+}
+
+void _VariableCondition_Destroy( void* variableCondition, void* data ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+
+ if (self->mapping) Stg_Class_Delete(self->mapping);
+ if (self->_set) Stg_Class_Delete(self->_set);
+ if (self->indexTbl) Memory_Free(self->indexTbl);
+ if (self->vcVarCountTbl) Memory_Free(self->vcVarCountTbl);
+ if (self->vcTbl) Memory_Free(self->vcTbl);
+ if (self->valueTbl) Memory_Free(self->valueTbl);
+}
+
+void _VariableCondition_Apply( void* variableCondition, void* context ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ Index i;
+
+ for (i = 0; i < self->indexCount; i++)
+ VariableCondition_ApplyToIndex(variableCondition, self->indexTbl[i], context);
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Functions
+*/
+
+void VariableCondition_Apply( void* variableCondition, void* context ) {
+ assert( variableCondition );
+ ((VariableCondition*)variableCondition)->_apply( variableCondition, context );
+}
+
+
+void VariableCondition_ApplyToVariable( void* variableCondition, VariableCondition_VariableIndex varIndex, void* context ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ Index i;
+
+ for (i = 0; i < self->indexCount; i++)
+ VariableCondition_ApplyToIndexVariable(variableCondition, self->indexTbl[i], varIndex, context);
+}
+
+
+void VariableCondition_ApplyToIndex( void* variableCondition, Index localIndex, void* context ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ Variable* var;
+ Variable_Index varIndex;
+ VariableCondition_ValueIndex val_I;
+ ConditionFunction* cf;
+ Index index, i;
+ Stream* errorStr = Journal_Register( Error_Type, self->type );
+
+ /* Ensure that the index provided (localIndex) has a condition attached to it */
+ insist( UIntMap_Map( self->mapping, localIndex, &index ), == True );
+
+ /* For each variable that has a condition at this index */
+ for (i = 0; i < self->vcVarCountTbl[index]; i++)
+ {
+ varIndex = self->vcTbl[index][i].varIndex;
+ assert( varIndex != (unsigned)-1 );
+
+ var = self->variable_Register->_variable[varIndex];
+
+ val_I = self->vcTbl[index][i].valIndex;
+ assert( val_I != (unsigned)-1 );
+
+ switch (self->valueTbl[val_I].type)
+ {
+ case VC_ValueType_Double:
+ Journal_Firewall( var->dataTypeCounts[0] == 1, errorStr,
+ "Error - in %s: while applying values for variable condition "
+ "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
+ "which has %d components. Specify a scalar Variable instead.\n",
+ __func__, self->name, self->indexTbl[index], "double",
+ var->name, var->dataTypeCounts[0] );
+ Variable_SetValueDouble(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[val_I].as.typeDouble );
+ break;
+
+ case VC_ValueType_DoubleArray:
+ Variable_SetValue(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[val_I].as.typeArray.array );
+ break;
+
+ case VC_ValueType_CFIndex:
+ Journal_Firewall( self->valueTbl[val_I].as.typeCFIndex != (unsigned)-1, errorStr,
+ "Error - in %s: trying to apply to index %d of variable \"%s\", which "
+ "is supposed to be a condition function, but the cond. func. wasn't "
+ "found in the c.f. register.\n", __func__, localIndex, var->name );
+ cf = self->conFunc_Register->_cf[self->valueTbl[val_I].as.typeCFIndex];
+ ConditionFunction_Apply(
+ cf,
+ localIndex,
+ varIndex,
+ context,
+ Variable_GetStructPtr( var, self->indexTbl[index] ) );
+ break;
+
+ case VC_ValueType_Int:
+ Journal_Firewall( var->dataTypeCounts[0] == 1, errorStr,
+ "Error - in %s: while applying values for variable condition "
+ "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
+ "which has %d components. Specify a scalar Variable instead.\n",
+ __func__, self->name, self->indexTbl[index], "int",
+ var->name, var->dataTypeCounts[0] );
+ Variable_SetValueInt(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[val_I].as.typeInt );
+ break;
+
+ case VC_ValueType_Short:
+ Journal_Firewall( var->dataTypeCounts[0] == 1, errorStr,
+ "Error - in %s: while applying values for variable condition "
+ "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
+ "which has %d components. Specify a scalar Variable instead.\n",
+ __func__, self->name, self->indexTbl[index], "short",
+ var->name, var->dataTypeCounts[0] );
+ Variable_SetValueShort(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[val_I].as.typeShort );
+ break;
+
+ case VC_ValueType_Char:
+ Journal_Firewall( var->dataTypeCounts[0] == 1, errorStr,
+ "Error - in %s: while applying values for variable condition "
+ "\"%s\", to index %d - asked to apply a scalar %s to Variable \"%s\" "
+ "which has %d components. Specify a scalar Variable instead.\n",
+ __func__, self->name, self->indexTbl[index], "char",
+ var->name, var->dataTypeCounts[0] );
+ Variable_SetValueChar(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[val_I].as.typeChar );
+ break;
+
+ case VC_ValueType_Ptr:
+ Variable_SetValuePointer(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[val_I].as.typePtr );
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+ }
+}
+
+
+void VariableCondition_ApplyToIndexVariable(
+ void* variableCondition,
+ Index localIndex,
+ VariableCondition_VariableIndex varIndex,
+ void* context )
+{
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ Variable_Index globalVarIndex;
+ Variable* var;
+ ConditionFunction* cf;
+ Index index;
+
+/*
+ * NOTE: This algorithm here is RIDICULOUSLY slow. I've added a mapping
+ * to the class, that should help.
+
+ for (index = 0; index < self->indexCount; index++)
+ if (self->indexTbl[index] == localIndex)
+ break;
+*/
+
+ if(!UIntMap_Map( self->mapping, localIndex, &index ))
+ return;
+
+ globalVarIndex = self->vcTbl[index][varIndex].varIndex;
+ var = self->variable_Register->_variable[globalVarIndex];
+
+ switch (self->valueTbl[self->vcTbl[index][varIndex].valIndex].type)
+ {
+ case VC_ValueType_Double:
+ Variable_SetValueDouble(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeDouble );
+ break;
+
+ case VC_ValueType_CFIndex:
+ cf = self->conFunc_Register->_cf[self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeCFIndex];
+ ConditionFunction_Apply(
+ cf,
+ localIndex,
+ globalVarIndex,
+ context,
+ Variable_GetStructPtr( var, self->indexTbl[index]) );
+ break;
+
+ case VC_ValueType_DoubleArray:
+ Variable_SetValue(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeArray.array );
+ break;
+
+ case VC_ValueType_Int:
+ Variable_SetValueInt(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeInt );
+ break;
+
+ case VC_ValueType_Short:
+ Variable_SetValueShort(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeShort );
+ break;
+
+ case VC_ValueType_Char:
+ Variable_SetValueChar(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typeChar );
+ break;
+
+ case VC_ValueType_Ptr:
+ Variable_SetValuePointer(
+ var,
+ self->indexTbl[index],
+ self->valueTbl[self->vcTbl[index][varIndex].valIndex].as.typePtr );
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+}
+
+
+Bool VariableCondition_IsCondition( void* variableCondition, Index localIndex, Variable_Index inputVarIndex ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ VariableCondition_VariableIndex vcVar_I;
+ Index i;
+ Variable_Index varIndexToTryMatch = 0;
+ Variable_Index subVarIndexToTryMatch = 0;
+ Variable* variableToTryMatch = NULL;
+ Variable* subVariableToTryMatch = NULL;
+ Variable_Index subVariable_I = 0;
+
+ /* if the set isn't initialised, this is a NULL BC : False */
+ if ( !self->_set ) {
+ return False;
+ }
+
+ /* first check if the index they've given us is actually in the list this VC applies to */
+ /* quick check, since we have the set available */
+ if ( localIndex >= self->_set->size ) {
+ Stream* warning = Journal_Register( ErrorStream_Type, self->type );
+ Journal_Printf( warning, "Error- In %s: Tried to check an index %d larger than the size of "
+ "the set (%d).\n", __func__, localIndex, self->_set->size );
+ assert(0);
+ return False;
+ }
+
+ if(!UIntMap_Map( self->mapping, localIndex, &i ))
+ return False;
+/*
+ if ( !IndexSet_IsMember( self->_set, localIndex ) ) {
+ return False;
+ }
+ for (i = 0; i < self->indexCount; i++)
+ if (self->indexTbl[i] == localIndex)
+ break;
+
+ if (i == self->indexCount)
+ return False;
+*/
+
+ /* now check if the Variable they've given us is actually in the list to apply at the given index */
+ for (vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++) {
+ varIndexToTryMatch = self->vcTbl[i][vcVar_I].varIndex;
+ variableToTryMatch = self->variable_Register->_variable[varIndexToTryMatch];
+
+ if ( varIndexToTryMatch == inputVarIndex) {
+ return True;
+ }
+ else if ( variableToTryMatch->subVariablesCount >= 1 ) {
+ /* 2nd chance draw is that if this Var has sub-components, we should test if the input argument is
+ * actually one of those - in which case we should consider it has a condition applied to it. */
+
+ for ( subVariable_I = 0; subVariable_I < variableToTryMatch->subVariablesCount; subVariable_I++ ) {
+ /* TODO: next few lines bit slow! Maybe need to cache subvar indices on variable */
+ subVariableToTryMatch = variableToTryMatch->components[subVariable_I];
+ if ( subVariableToTryMatch == NULL ) continue;
+
+ subVarIndexToTryMatch = Variable_Register_GetIndex( self->variable_Register,
+ subVariableToTryMatch->name );
+
+ if ( subVarIndexToTryMatch == inputVarIndex) {
+ return True;
+ }
+ }
+ }
+ }
+
+ return False;
+}
+
+
+VariableCondition_ValueIndex VariableCondition_GetValueIndex (void* variableCondition, Index localIndex, Variable_Index varIndex )
+{
+ VariableCondition* self = (VariableCondition*)variableCondition;
+ VariableCondition_VariableIndex vcVar_I;
+ Index i;
+
+ /* if the set isn't initialised, this is a NULL BC : False */
+ if ( !self->_set ) {
+ return False;
+ }
+
+ /* first check if the index they've given us is actually in the list this VC applies to */
+ /* quick check, since we have the set available */
+ if ( localIndex >= self->_set->size ) {
+ Stream* warning = Journal_Register( ErrorStream_Type, self->type );
+ Journal_Printf( warning, "Error- In %s: Tried to check an index %d larger than the size of "
+ "the set (%d).\n", __func__, localIndex, self->_set->size );
+ assert(0);
+ return False;
+ }
+ if ( !IndexSet_IsMember( self->_set, localIndex ) ) {
+ return (VariableCondition_ValueIndex)-1;
+ }
+ for (i = 0; i < self->indexCount; i++)
+ if (self->indexTbl[i] == localIndex)
+ break;
+
+ if (i == self->indexCount)
+ return (VariableCondition_ValueIndex)-1;
+
+ /* now check if the Variable they've given us is actually in the list to apply at the given index */
+ for (vcVar_I = 0; vcVar_I < self->vcVarCountTbl[i]; vcVar_I++)
+ if (self->vcTbl[i][vcVar_I].varIndex == varIndex)
+ return self->vcTbl[i][vcVar_I].valIndex;
+
+ return (VariableCondition_ValueIndex)-1;
+}
+
+
+void VariableCondition_PrintConcise( void* variableCondition, Stream* stream ) {
+ VariableCondition* self = (VariableCondition*)variableCondition;
+
+ self->_printConcise( self, stream );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableCondition.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableCondition.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,254 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+** Abstract class for specifying (1 or more) conditions that apply to (1 or more) variables in an array.
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: VariableCondition.h 4297 2008-08-19 16:54:05Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Base_Context_VariableCondition_h__
+#define __StGermain_Base_Context_VariableCondition_h__
+
+ /** Textual name of this class */
+ extern const Type VariableCondition_Type;
+
+ typedef void (VariableCondition_BuildSelfFunc) ( void* variableCondition, void* data );
+ typedef void (VariableCondition_PrintConciseFunc) ( void* variableCondition, Stream* stream );
+ typedef void (VariableCondition_ReadDictionaryFunc) ( void* variableCondition, void* dictionary );
+ typedef IndexSet* (VariableCondition_GetSetFunc) ( void* variableCondition );
+ typedef VariableCondition_VariableIndex (VariableCondition_GetVariableCountFunc) ( void* variableCondition, Index index );
+ typedef Variable_Index (VariableCondition_GetVariableIndexFunc) ( void* variableCondition, Index index, VariableCondition_VariableIndex condVar_I );
+ typedef VariableCondition_ValueIndex (VariableCondition_GetValueIndexFunc) ( void* variableCondition, Index index, VariableCondition_VariableIndex condVar_I );
+ typedef VariableCondition_ValueIndex (VariableCondition_GetValueCountFunc) ( void* variableCondition );
+ typedef VariableCondition_Value (VariableCondition_GetValueFunc) ( void* variableCondition, VariableCondition_ValueIndex valIndex );
+ typedef void (VariableCondition_ApplyFunc)( void *vc, void* ctx );
+
+ typedef struct {
+ Index size;
+ double* array;
+ } VariableCondition_Value_Array;
+
+ typedef union {
+ double typeDouble;
+ int typeInt;
+ short typeShort;
+ char typeChar;
+ void* typePtr;
+ VariableCondition_Value_Array typeArray;
+ ConditionFunction_Index typeCFIndex;
+ } VariableCondition_Value_AsType;
+
+ #define __VariableCondition_Value \
+ VariableCondition_ValueType type; \
+ VariableCondition_Value_AsType as;
+ struct _VariableCondition_Value { __VariableCondition_Value };
+
+
+ #define __VariableCondition_Tuple \
+ /** The variable index into VariableCondition::variable_Register identifying a variable */ \
+ Variable_Index varIndex; \
+ /** The value index into VariableCondition::valueTbl identifying a value to apply to the variable */ \
+ VariableCondition_ValueIndex valIndex; \
+
+ /** Used to relate which Condition is applied to a Variable */
+ struct _VariableCondition_Tuple { __VariableCondition_Tuple };
+
+ #define __VariableCondition \
+ /* General info */ \
+ __Stg_Component \
+ \
+ AbstractContext* context; \
+ /* Virtual info */ \
+ VariableCondition_BuildSelfFunc* _buildSelf; \
+ VariableCondition_PrintConciseFunc* _printConcise; \
+ VariableCondition_ReadDictionaryFunc* _readDictionary; \
+ VariableCondition_GetSetFunc* _getSet; \
+ VariableCondition_GetVariableCountFunc* _getVariableCount; \
+ VariableCondition_GetVariableIndexFunc* _getVariableIndex; \
+ VariableCondition_GetValueIndexFunc* _getValueIndex; \
+ VariableCondition_GetValueCountFunc* _getValueCount; \
+ VariableCondition_GetValueFunc* _getValue; \
+ VariableCondition_ApplyFunc* _apply; \
+ \
+ /* Stg_Class info */ \
+ /** Register of Variables that may be operated on. */ \
+ Variable_Register* variable_Register; \
+ /** Register of Condition functions that may be applied. */ \
+ ConditionFunction_Register* conFunc_Register; \
+ Dictionary* dictionary; \
+ \
+ /** Set specifying which indexes in the client structure are being controlled by this VC. */ \
+ IndexSet* _set; \
+ /** the number of indexes this VC applies to. */ \
+ Index indexCount; \
+ /** Array, of size indexCount, containing the indexes this VC applies to. */ \
+ Index* indexTbl; \
+ /** Array containing the number of variables at each index that are controlled by this VC */ \
+ VariableCondition_VariableIndex* vcVarCountTbl; \
+ /** 2d Array, which for each index this VC controls, stores the VariableCondition_Tuple that relates
+ what condition is being applied to which Variable */ \
+ VariableCondition_Tuple** vcTbl; \
+ /** Number of values in the valueTbl which will be applied somewhere using this VC */ \
+ VariableCondition_ValueIndex valueCount; \
+ /** Array of values which are available to apply (which index/var pairs they apply to is determined
+ by VariableCondition::vcTbl). */ \
+ VariableCondition_Value* valueTbl; \
+ \
+ UIntMap* mapping; \
+ Stg_ComponentFactory* cf;
+
+ /** Abstract class for specifying (1 or more) conditions that apply to (1 or more) variables in an array -
+ see VariableCondition.h for details */
+ struct _VariableCondition { __VariableCondition };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructor
+ */
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define VARIABLECONDITION_DEFARGS \
+ STG_COMPONENT_DEFARGS, \
+ VariableCondition_BuildSelfFunc* _buildSelf, \
+ VariableCondition_PrintConciseFunc* _printConcise, \
+ VariableCondition_ReadDictionaryFunc* _readDictionary, \
+ VariableCondition_GetSetFunc* _getSet, \
+ VariableCondition_GetVariableCountFunc _getVariableCount, \
+ VariableCondition_GetVariableIndexFunc* _getVariableIndex, \
+ VariableCondition_GetValueIndexFunc* _getValueIndex, \
+ VariableCondition_GetValueCountFunc* _getValueCount, \
+ VariableCondition_GetValueFunc* _getValue, \
+ VariableCondition_ApplyFunc* _apply
+
+ #define VARIABLECONDITION_PASSARGS \
+ STG_COMPONENT_PASSARGS, \
+ _buildSelf, \
+ _printConcise, \
+ _readDictionary, \
+ _getSet, \
+ _getVariableCount, \
+ _getVariableIndex, \
+ _getValueIndex, \
+ _getValueCount, \
+ _getValue, \
+ _apply
+
+ VariableCondition* _VariableCondition_New( VARIABLECONDITION_DEFARGS );
+
+ void _VariableCondition_Init(
+ void* variableCondition,
+ AbstractContext* context,
+ Variable_Register* variable_Register,
+ ConditionFunction_Register* conFunc_Register,
+ Dictionary* dictionary );
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** General virtual functions
+ */
+
+ void _VariableCondition_Delete( void* variableCondition );
+
+ void _VariableCondition_Print( void* variableCondition );
+
+ /* Copy */
+ #define VariableCondition_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+ #define VariableCondition_Copy( self ) \
+ (VariableCondition*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+
+ void* _VariableCondition_Copy( void* variableCondition, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Macros
+ */
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _VariableCondition_Apply( void* variableCondition, void* context );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Build functions
+ */
+ void _VariableCondition_AssignFromXML( void* variableCondition, Stg_ComponentFactory* cf, void* d );
+ void _VariableCondition_Build( void* variableCondition, void* data );
+ void _VariableCondition_Initialise( void* variableCondition, void* data );
+ void _VariableCondition_Execute( void* variableCondition, void* data );
+ void _VariableCondition_Destroy( void* variableCondition, void* data );
+
+ #define VariableCondition_BuildSelf( self, data ) \
+ if( (self)->_buildSelf ) \
+ (self)->_buildSelf( self, data )
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Functions
+ */
+
+ void VariableCondition_Apply( void* variableCondition, void* context );
+
+ void VariableCondition_ApplyToVariable(
+ void* variableCondition,
+ VariableCondition_VariableIndex varIndex,
+ void* context );
+
+ void VariableCondition_ApplyToIndex( void* variableCondition, Index globalIndex, void* context );
+
+ void VariableCondition_ApplyToIndexVariable(
+ void* variableCondition,
+ Index globalIndex,
+ VariableCondition_VariableIndex varIndex,
+ void* context );
+
+ /** Checks whether a given (node)/(var at that node) pair is a variable condition */
+ Bool VariableCondition_IsCondition(
+ void* variableCondition,
+ Index globalIndex,
+ Variable_Index varIndex );
+
+ VariableCondition_ValueIndex VariableCondition_GetValueIndex(
+ void* variableCondition,
+ Index globalIndex,
+ Variable_Index varIndex );
+
+ void VariableCondition_PrintConcise( void* variableCondition, Stream* stream );
+
+#endif /* __StGermain_Base_Context_VariableCondition_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableCondition.meta
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableCondition.meta Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+ <param name="Name">VariableCondition</param>
+ <param name="Author">...</param>
+ <param name="Organisation">VPAC</param>
+ <param name="Project">StGermain</param>
+ <param name="Location">./StGermain/Base/Context/src/</param>
+ <param name="Project Web">http://www.stgermainproject.org/</param>
+ <param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
+ <param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
+ <param name="Parent">Stg_Component</param>
+ <param name="Reference">...</param>
+ <param name="Summary">...</param>
+
+ <param name="Description">
+ Base class for any concrete variable condition. Defines the interface for
+ specifying boundary conditions.
+ </param>
+
+ <list name="Params">
+ n/a
+ </list>
+
+ <list name="Dependencies">
+ n/a
+ </list>
+
+ <param name="Example">
+ n/a
+ </param>
+
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableCondition_Register.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableCondition_Register.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,231 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: VariableCondition_Register.c 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+
+#include "types.h"
+#include "shortcuts.h"
+#include "VariableCondition_Register.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+
+/* Textual name of this class */
+const Type VariableCondition_Register_Type = "VariableCondition_Register";
+
+
+/* Global, default instantiation of the register... will be loaded with in built types (built in Init.c) */
+VariableCondition_Register* variableCondition_Register = 0;
+
+
+VariableCondition_Register* VariableCondition_Register_New(void) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(VariableCondition_Register);
+ Type type = VariableCondition_Register_Type;
+ Stg_Class_DeleteFunction* _delete = _VariableCondition_Register_Delete;
+ Stg_Class_PrintFunction* _print = _VariableCondition_Register_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ return _VariableCondition_Register_New( VARIABLECONDITION_REGISTER_PASSARGS );
+}
+
+void VariableCondition_Register_Init( void* variableCondition_Register ) {
+ VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
+
+ /* General info */
+ self->type = VariableCondition_Register_Type;
+ self->_sizeOfSelf = sizeof(VariableCondition_Register);
+ self->_deleteSelf = False;
+
+ /* Virtual info */
+ self->_delete = _VariableCondition_Register_Delete;
+ self->_print = _VariableCondition_Register_Print;
+ self->_copy = NULL;
+ _Stg_Class_Init( (Stg_Class*)self );
+
+ /* VariableCondition_Register info */
+ _VariableCondition_Register_Init( self );
+}
+
+VariableCondition_Register* _VariableCondition_Register_New( VARIABLECONDITION_REGISTER_DEFARGS )
+{
+ VariableCondition_Register* self;
+
+ /* Allocate memory */
+ assert( _sizeOfSelf >= sizeof(VariableCondition_Register) );
+ self = (VariableCondition_Register*)_Stg_Class_New( STG_CLASS_PASSARGS );
+
+ /* General info */
+
+ /* Virtual info */
+
+ _VariableCondition_Register_Init( self );
+
+ return self;
+}
+
+void _VariableCondition_Register_Init( void* variableCondition_Register ) {
+ VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
+
+ /* General and Virtual info should already be set */
+
+ /* VariableCondition_Register info */
+ self->count = 0;
+ self->_size = 8;
+ self->_delta = 8;
+ self->entry = Memory_Alloc_Array( VariableCondition_Register_Entry, self->_size, "VC_Register->entry" );
+ memset( self->entry, 0, sizeof(VariableCondition_Register_Entry) * self->_size );
+}
+
+void _VariableCondition_Register_Delete( void* variableCondition_Register ) {
+ VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
+
+ /* Assumes ownerships of the element types */
+ if( self->entry ) {
+ Memory_Free( self->entry );
+ }
+
+ /* Stg_Class_Delete parent */
+ _Stg_Class_Delete( self );
+}
+
+void _VariableCondition_Register_Print( void* variableCondition_Register, Stream* stream ) {
+ VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
+ #ifdef DEBUG
+ VariableCondition_Index variableCondition_I;
+ #endif
+
+ /* Set the Journal for printing informations */
+ Stream* variableCondition_RegisterStream = stream;
+
+ /* General info */
+ Journal_Printf( variableCondition_RegisterStream, "VariableCondition_Register (ptr): %p\n", self );
+
+ /* Print parent */
+ _Stg_Class_Print( self, variableCondition_RegisterStream );
+
+ /* Virtual info */
+
+ /* VariableCondition_Register info */
+ Journal_Printf( variableCondition_RegisterStream, "\tcount: %u\n", self->count );
+ Journal_Printf( variableCondition_RegisterStream, "\t_size: %lu\n", self->_size );
+ Journal_Printf( variableCondition_RegisterStream, "\t_delta: %lu\n", self->_delta );
+
+ Journal_Printf( variableCondition_RegisterStream, "\tvariableCondition (ptr): %p\n", self->entry );
+ Journal_Printf( variableCondition_RegisterStream, "\tvariableCondition[0-%u]:\n", self->count );
+ #ifdef DEBUG
+ for( variableCondition_I = 0; variableCondition_I < self->count; variableCondition_I++ ) {
+ Journal_Printf( variableCondition_RegisterStream, "\tentry[%u]:\n", variableCondition_I );
+ Journal_Printf( variableCondition_RegisterStream, "\t\ttype: %s\n", self->entry[variableCondition_I].type );
+ Journal_Printf( variableCondition_RegisterStream, "\t\tfactory (func ptr): %p\n", self->entry[variableCondition_I].factory );
+ }
+ #else
+ Journal_Printf( variableCondition_RegisterStream, "...\n" );
+ #endif
+ Journal_Printf( variableCondition_RegisterStream, "\t]\n" );
+}
+
+VariableCondition_Index VariableCondition_Register_Add(
+ void* variableCondition_Register,
+ Type type,
+ VariableCondition_Register_FactoryFunc* factory )
+{
+ VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
+ VariableCondition_Index handle;
+
+ if( self->count >= self->_size ) {
+ SizeT currentSize = self->_size;
+
+ self->_size += self->_delta;
+ self->entry = Memory_Realloc_Array( self->entry, VariableCondition_Register_Entry, self->_size );
+ memset( (Pointer)((ArithPointer)self->entry + (currentSize * sizeof(VariableCondition_Register_Entry)) ),
+ 0, sizeof(VariableCondition_Register_Entry) * (self->_size - currentSize) );
+ }
+
+ handle = self->count;
+ self->entry[handle].type = type;
+ self->entry[handle].factory = factory;
+ self->count++;
+
+ return handle;
+}
+
+VariableCondition_Index VariableCondition_Register_GetIndex( void* variableCondition_Register, Type type ) {
+ VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
+ VariableCondition_Index variableCondition_I;
+
+ for( variableCondition_I = 0; variableCondition_I < self->count; variableCondition_I++ ) {
+ if( self->entry[variableCondition_I].type == type ) {
+ return variableCondition_I;
+ }
+ }
+ /* type is likely to be given from input file in this case... treat comparison checks like for Name... do strcmp too */
+ for( variableCondition_I = 0; variableCondition_I < self->count; variableCondition_I++ ) {
+ if( strcmp( self->entry[variableCondition_I].type, type ) == 0 ) {
+ return variableCondition_I;
+ }
+ }
+ return (unsigned)-1;
+}
+
+VariableCondition_Register_Entry* _VariableCondition_Register_At(
+ void* variableCondition_Register,
+ VariableCondition_Index handle )
+{
+ VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
+
+ return VariableCondition_Register_At( self, handle );
+}
+
+VariableCondition* VariableCondition_Register_CreateNew(
+ void* context,
+ void* variableCondition_Register,
+ void* variable_Register,
+ void* conFunc_Register,
+ Type type,
+ void* dictionary,
+ void* data )
+{
+ VariableCondition_Register* self = (VariableCondition_Register*)variableCondition_Register;
+
+ return VariableCondition_Register_At( self, VariableCondition_Register_GetIndex( self, type ) )->factory(
+ (AbstractContext*)context,
+ (Variable_Register*)variable_Register,
+ (ConditionFunction_Register*)conFunc_Register,
+ (Dictionary*)dictionary,
+ data );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableCondition_Register.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableCondition_Register.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,138 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+** The original sizes need to be manually set by the user.... this whole system needs rethinking... it can be done better
+**
+** $Id: VariableCondition_Register.h 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Base_Context_VariableCondition_Register_h__
+#define __StGermain_Base_Context_VariableCondition_Register_h__
+
+
+ /* Child classes must define these factories */
+ typedef VariableCondition* (VariableCondition_Register_FactoryFunc)
+ ( AbstractContext* context, Variable_Register* variable_Register, ConditionFunction_Register* conFunc_Register, Dictionary* dictionary, void* data );
+
+
+ /** Textual name of this class */
+ extern const Type VariableCondition_Register_Type;
+
+
+ /** Global, default instantiation of the register... will be loaded with in built types (built in Init.c) */
+ extern VariableCondition_Register* variableCondition_Register;
+
+
+ /* Register entry info */
+ #define __VariableCondition_Register_Entry \
+ Type type; \
+ VariableCondition_Register_FactoryFunc* factory;
+ struct _VariableCondition_Register_Entry { __VariableCondition_Register_Entry };
+
+
+ /* VariableCondition_Register info */
+ #define __VariableCondition_Register \
+ /* General info */ \
+ __Stg_Class \
+ \
+ /* Virtual info */ \
+ \
+ /* VariableCondition_Register info */ \
+ VariableCondition_Index count; \
+ SizeT _size; \
+ SizeT _delta; \
+ VariableCondition_Register_Entry* entry;
+ struct _VariableCondition_Register { __VariableCondition_Register };
+
+
+ /* Create a new VariableCondition_Register */
+ VariableCondition_Register* VariableCondition_Register_New(void);
+
+ /* Initialise a VariableCondition_Register */
+ void VariableCondition_Register_Init(
+ void* variableCondition_Register);
+
+ /* Creation implementation / Virtual constructor */
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define VARIABLECONDITION_REGISTER_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define VARIABLECONDITION_REGISTER_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ VariableCondition_Register* _VariableCondition_Register_New( VARIABLECONDITION_REGISTER_DEFARGS );
+
+ /* Initialisation implementation */
+ void _VariableCondition_Register_Init( void* variableCondition_Register);
+
+
+ /* Stg_Class_Delete implementation */
+ void _VariableCondition_Register_Delete( void* variableCondition_Register );
+
+ /* Print implementation */
+ void _VariableCondition_Register_Print( void* variableCondition_Register, Stream* stream );
+
+
+ /* Add a new entry */
+ VariableCondition_Index VariableCondition_Register_Add(
+ void* variableCondition_Register,
+ Type type,
+ VariableCondition_Register_FactoryFunc* factory );
+
+ /* Get the handle to an entry */
+ VariableCondition_Index VariableCondition_Register_GetIndex( void* variableCondition_Register, Type type );
+
+ /* Get an entry from the register */
+ #define VariableCondition_Register_At( variableCondition_Register, handle ) \
+ ( &(variableCondition_Register)->entry[(handle)] )
+ VariableCondition_Register_Entry* _VariableCondition_Register_At(
+ void* variableCondition_Register,
+ VariableCondition_Index handle );
+
+ /* Create a new instance of a type */
+ VariableCondition* VariableCondition_Register_CreateNew(
+ void* context,
+ void* variableCondition_Register,
+ void* variable_Register,
+ void* conFunc_Register,
+ Type type,
+ void* dictionary,
+ void* data );
+
+#endif /* __StGermain_Base_Context_VariableCondition_Register_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableDumpStream.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableDumpStream.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,193 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: VariableDumpStream.c 789 2004-02-10 17:15:11Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+#include "Base/Automation/Automation.h"
+
+#include "types.h"
+#include "Variable.h"
+#include "VariableDumpStream.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+
+
+const Type VariableDumpStream_Type = "VariableDumpStream";
+
+
+Stream* VariableDumpStream_New( Name name )
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(VariableDumpStream);
+ Type type = VariableDumpStream_Type;
+ Stg_Class_DeleteFunction* _delete = _VariableDumpStream_Delete;
+ Stg_Class_PrintFunction* _print = _VariableDumpStream_Print;
+ Stg_Class_CopyFunction* _copy = _VariableDumpStream_Copy;
+ Stream_PrintfFunction* _printf = _CStream_Printf;
+ Stream_WriteFunction* _write = _CStream_Write;
+ Stream_DumpFunction* _dump = _VariableDumpStream_Dump;
+ Stream_SetFileFunction* _setFile = _CStream_SetFile;
+
+ return (Stream*)_VariableDumpStream_New( VARIABLEDUMPSTREAM_PASSARGS );
+}
+
+void VariableDumpStream_Init( VariableDumpStream* self, Name name )
+{
+
+}
+
+
+VariableDumpStream* _VariableDumpStream_New( VARIABLEDUMPSTREAM_DEFARGS )
+{
+ VariableDumpStream* self;
+
+ /* Allocate memory */
+ assert( _sizeOfSelf >= sizeof(VariableDumpStream) );
+ self = (VariableDumpStream*)_CStream_New( CSTREAM_PASSARGS );
+
+ _VariableDumpStream_Init( self );
+
+ return self;
+}
+
+void _VariableDumpStream_Init( VariableDumpStream* self )
+{
+ self->data = NULL;
+ self->numItems = 0;
+}
+
+void _VariableDumpStream_Delete( void* cStream )
+{
+ VariableDumpStream* self = (VariableDumpStream*)cStream;
+
+ /* Stg_Class_Delete parent */
+ _Stream_Delete( self );
+}
+
+void _VariableDumpStream_Print( void* cStream, Stream* stream ) {
+
+ VariableDumpStream* self = (VariableDumpStream*)cStream;
+
+ /* Print parent */
+ _Stream_Print( self, stream );
+
+ /* General info */
+ Journal_Printf( stream, "VariableDumpStream (ptr): %p\n", cStream);
+
+ Journal_Printf( stream, "data (ptr): %p\n", self->data );
+ Journal_Printf( stream, "numItems: %d\n", self->numItems );
+}
+
+void* _VariableDumpStream_Copy( void* variableDumpStream, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap ) {
+ VariableDumpStream* self = (VariableDumpStream*)variableDumpStream;
+ VariableDumpStream* newVariableDumpStream;
+
+ newVariableDumpStream = _Stream_Copy( self, dest, deep, nameExt, ptrMap );
+
+ /* HACK */
+ /* TODO: this should actually copy the data, i think... */
+ newVariableDumpStream->data = NULL;
+ newVariableDumpStream->numItems = 0;
+ /* END HACK */
+ newVariableDumpStream->dumpEvery = self->dumpEvery;
+
+ return newVariableDumpStream;
+}
+
+Bool _VariableDumpStream_Dump( Stream* stream, void* _loop )
+{
+ VariableDumpStream* self = (VariableDumpStream*)stream;
+ int varI, typeI;
+ int* loop = (int*)_loop;
+ float tmp;
+
+
+ if ( self->data == NULL || self->numItems == 0 )
+ {
+ return True;
+ }
+ if ( loop != NULL )
+ {
+ if( !((*loop) == 0 || (((*loop) - 1) % self->dumpEvery == 0)) )
+ return True;
+ }
+
+ /* testing if the others compile....
+ char tmp1 = Variable_GetValueAsChar( self->data, varI );
+ short tmp2 = Variable_GetValueAsShort( self->data, varI );
+ int tmp3 = Variable_GetValueAsInt( self->data, varI );
+ double tmp4 = Variable_GetValueAsDouble( self->data, varI );
+ void* tmp5 = Variable_GetValueAsPointer( self->data, varI );*/
+ for ( varI = 0; varI < self->data->arraySize; ++varI ) {
+ if ( *self->data->dataTypeCounts > 1 ) {
+ for ( typeI = 0; typeI < *self->data->dataTypeCounts; ++typeI ) {
+ tmp = Variable_GetValueAtDoubleAsFloat( self->data, varI, typeI );
+ self->_write(
+ stream,
+ &tmp,
+ sizeof(float), 1 );
+ }
+ }
+ else {
+ tmp = Variable_GetValueDoubleAsFloat( self->data, varI );
+ self->_write(
+ stream,
+ &tmp,
+ sizeof(float), 1 );
+ }
+ }
+
+
+ return True;
+}
+
+void VariableDumpStream_SetVariable( void* stream, Variable* data, int numItems, unsigned int dumpEvery, const Name const fileName )
+{
+ VariableDumpStream* self = (VariableDumpStream*)stream;
+ JournalFile* file;
+
+ self->data = data;
+ self->numItems = numItems;
+ self->dumpEvery = dumpEvery;
+
+ file = Journal_GetFile( fileName );
+ if ( file == NULL )
+ {
+ file = CFile_New2( fileName );
+ Journal_RegisterFile( file );
+ }
+ Stream_SetFile( stream, file );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/VariableDumpStream.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/VariableDumpStream.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,111 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/** \file
+** <b>Role:</b>
+**
+**
+** <b>Assumptions</b>
+** None
+**
+** <b>Comments</b>
+** None
+**
+** <b>Description</b>
+**
+**
+** Comments:
+**
+** $Id: VariableDumpStream.h 789 2004-02-10 17:15:11Z SteveQuenette $
+**
+**/
+
+#ifndef __StGermain_Base_Context_VariableDumpStream_h__
+#define __StGermain_Base_Context_VariableDumpStream_h__
+
+ /** Textual name for VariableDumpStream class. */
+ extern const Type VariableDumpStream_Type;
+
+
+ /** \def __VariableDumpStream See VariableDumpStream. */
+ #define __VariableDumpStream \
+ /* General info */ \
+ __CStream \
+ Variable* data; \
+ Index numItems; \
+ unsigned int dumpEvery;
+ struct VariableDumpStream { __VariableDumpStream };
+
+
+ /** Create a new VariableDumpStream */
+ Stream* VariableDumpStream_New( Name name );
+
+ /** Inits a VariableDumpStream. */
+ void VariableDumpStream_Init( VariableDumpStream* self, Name name );
+
+ /** Constructor interface. */
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define VARIABLEDUMPSTREAM_DEFARGS \
+ CSTREAM_DEFARGS
+
+ #define VARIABLEDUMPSTREAM_PASSARGS \
+ CSTREAM_PASSARGS
+
+ VariableDumpStream* _VariableDumpStream_New( VARIABLEDUMPSTREAM_DEFARGS );
+
+ /** Init interface. */
+ void _VariableDumpStream_Init( VariableDumpStream *self );
+
+ /** Stg_Class_Delete interface. */
+ void _VariableDumpStream_Delete( void* vStream );
+
+ /** Print interface. */
+ void _VariableDumpStream_Print( void* vStream, Stream* stream );
+
+ /** Dumps the variable. */
+ Bool _VariableDumpStream_Dump( Stream* stream, void* loop );
+
+ /** Copy interface. */
+ #define VariableDumpStream_Copy( self ) \
+ (VariableDumpStream*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+ #define VariableDumpStream_DeepCopy( self ) \
+ (VariableDumpStream*)Stg_Class_Copy( self, NULL, True, NULL, NULL )
+
+ void* _VariableDumpStream_Copy( void* variableDumpStream, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
+
+ /** Sets the information that this stream dumps. */
+ void VariableDumpStream_SetVariable( void* stream, Variable* data, int numItems, unsigned int dumpEvery, const Name const fileName );
+
+
+#endif /* __Context_VariableDumpStreamFile_h__ */
+
+
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Variable_Register.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/Variable_Register.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,272 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: Variable_Register.c 4137 2007-06-07 05:46:46Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdarg.h>
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+#include "Base/Container/Container.h"
+#include "Base/Automation/Automation.h"
+
+#include "types.h"
+#include "shortcuts.h"
+#include "Variable.h"
+#include "Variable_Register.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+
+const Type Variable_Register_Type = "Variable_Register";
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Constructor
+*/
+
+Variable_Register* Variable_Register_New(void)
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Variable_Register);
+ Type type = Variable_Register_Type;
+ Stg_Class_DeleteFunction* _delete = _Variable_Register_Delete;
+ Stg_Class_PrintFunction* _print = _Variable_Register_Print;
+ Stg_Class_CopyFunction* _copy = _Variable_Register_Copy;
+
+ return _Variable_Register_New( VARIABLE_REGISTER_PASSARGS );
+}
+
+
+void Variable_Register_Init(Variable_Register* self)
+{
+ /* General info */
+ self->type = Variable_Register_Type;
+ self->_sizeOfSelf = sizeof(Variable_Register);
+ self->_deleteSelf = False;
+
+ /* Virtual info */
+ self->_delete = _Variable_Register_Delete;
+ self->_print = _Variable_Register_Print;
+ self->_copy = _Variable_Register_Copy;
+
+ _Stg_Class_Init((Stg_Class*)self);
+
+ /* Stg_Class info */
+ _Variable_Register_Init(self);
+}
+
+
+Variable_Register* _Variable_Register_New( VARIABLE_REGISTER_DEFARGS )
+{
+ Variable_Register* self;
+
+ /* Allocate memory */
+ self = (Variable_Register*)_Stg_Class_New( STG_CLASS_PASSARGS );
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+ _Variable_Register_Init(self);
+
+ return self;
+}
+
+
+void _Variable_Register_Init(void* variable_Register)
+{
+ Variable_Register* self = (Variable_Register*)variable_Register;
+
+ self->count = 0;
+ self->_size = 8;
+ self->_delta = 8;
+ self->_variable = Memory_Alloc_Array( Variable*, self->_size, "Variable_Register->_variable" );
+ memset(self->_variable, 0, sizeof(Variable*)*self->_size);
+ self->errorStream = Journal_Register( Error_Type, self->type );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** General virtual functions
+*/
+
+void _Variable_Register_Delete(void* variable_Register)
+{
+ Variable_Register* self = (Variable_Register*)variable_Register;
+
+ if (self->_variable) Memory_Free(self->_variable);
+
+ /* Stg_Class_Delete parent class */
+ _Stg_Class_Delete(self);
+}
+
+void _Variable_Register_Print(void* variable_Register, Stream* stream)
+{
+ Variable_Register* self = (Variable_Register*)variable_Register;
+
+ /* Set the Journal for printing informations */
+ Stream* variable_RegisterStream = Journal_Register( InfoStream_Type, "Variable_RegisterStream");
+
+ /* General info */
+ Journal_Printf( variable_RegisterStream, "Variable_Register (ptr): %p\n", self);
+
+ /* Virtual info */
+
+ /* Stg_Class info */
+ Journal_Printf( variable_RegisterStream, "\tcount: %u\n", self->count);
+ Journal_Printf( variable_RegisterStream, "\t_size: %lu\n", self->_size);
+ Journal_Printf( variable_RegisterStream, "\t_delta: %lu\n", self->_delta);
+ Journal_Printf( variable_RegisterStream, "\t_variable (ptr): %p\n", self->_variable);
+ if (self->_variable)
+ {
+ Variable_Index var_I;
+
+ for (var_I = 0; var_I < self->count; var_I++)
+ Stg_Class_Print(self->_variable[var_I], stream);
+ }
+
+ /* Print parent */
+ _Stg_Class_Print(self, variable_RegisterStream);
+}
+
+void* _Variable_Register_Copy( void* vr, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
+
+ Variable_Register* self = (Variable_Register*)vr;
+ Variable_Register* newVariableRegister;
+ int ii;
+
+ newVariableRegister = (Variable_Register*)_Stg_Class_Copy( self, dest, deep, nameExt, ptrMap );
+ PtrMap_Append( ptrMap, self, newVariableRegister );
+
+ newVariableRegister->count = self->count;
+ newVariableRegister->_size = self->_size;
+ newVariableRegister->_variable = Memory_Alloc_Array( Variable*, self->_size, "Variable_Register->_variable" );
+ memset(newVariableRegister->_variable, 0, sizeof(Variable*)*self->_size);
+
+ for ( ii = 0; ii < self->count; ++ii ) {
+ if ( (newVariableRegister->_variable[ii] = PtrMap_Find( ptrMap, self->_variable[ii] )) == NULL ) {
+ newVariableRegister->_variable[ii] = Stg_Class_Copy( self->_variable[ii], NULL, deep, nameExt, ptrMap );
+ }
+ }
+
+ return newVariableRegister;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Macros
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Build functions
+*/
+
+Variable_Index Variable_Register_Add(void* variable_Register, Variable* variable)
+{
+ Variable_Register* self = (Variable_Register*)variable_Register;
+ Variable_Index handle;
+
+ if (self->count >= self->_size)
+ {
+ SizeT currentSize = self->_size;
+
+ self->_size += self->_delta;
+ self->_variable = Memory_Realloc_Array( self->_variable, Variable*, self->_size );
+ memset( (Pointer)((ArithPointer)self->_variable + (currentSize * sizeof(Variable*)) ), 0,
+ sizeof(Variable*) * (self->_size - currentSize) );
+ }
+
+ handle = self->count++;
+ self->_variable[handle] = variable;
+
+ return handle;
+}
+
+
+void Variable_Register_BuildAll(void* variable_Register)
+{
+ Variable_Register* self = (Variable_Register*)variable_Register;
+ Variable_Index var_I;
+
+ for (var_I = 0; var_I < self->count; var_I++)
+ Stg_Component_Build( self->_variable[var_I], 0, False );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Functions
+*/
+
+Variable_Index Variable_Register_GetIndex(void* variable_Register, Name name)
+{
+ Variable_Register* self = (Variable_Register*)variable_Register;
+ Variable_Index var_I;
+
+ for (var_I = 0; var_I < self->count; var_I++)
+ {
+ if (self->_variable[var_I]->name && !strcmp(name, self->_variable[var_I]->name))
+ return var_I;
+ }
+
+ return (Variable_Index)-1;
+}
+
+
+Variable* Variable_Register_GetByName(void* variable_Register, Name name)
+{
+ Variable_Register* self = (Variable_Register*)variable_Register;
+ Variable_Index varIndex;
+
+ if( (varIndex = Variable_Register_GetIndex( self, name )) != (Variable_Index)-1 )
+ return self->_variable[varIndex];
+
+ return NULL;
+}
+
+
+Variable* Variable_Register_GetByIndex(void* variable_Register, Variable_Index varIndex ) {
+ Variable_Register* self = (Variable_Register*)variable_Register;
+ #if DEBUG
+ Stream* error = self->errorStream;
+
+ Journal_DFirewall( (varIndex < self->count), error,
+ "Error: Given variable index %d not between 0 and variable count %d.\n",
+ varIndex, self->count );
+ #endif
+
+ return self->_variable[varIndex];
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/Variable_Register.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/src/Variable_Register.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,132 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+** Instantiates the Variable_Register such that there is only one set of DOF descriptions (for example, all the nodes have the same
+** DOF configuration).
+**
+** Assumptions:
+** All "adding" is done before the Variable_Register_Build(...), which will be done in the mesh's initialisation.
+**
+** Comments:
+** You "add" DOF descriptors by using the Variable_Register_Add( variable_Register, name, offset ), where the "name" is the
+** textual name for the DOF that will be used in the I/O of the DOF (e.g. for initial and boundary conditions), and "offset" is
+** the memory offset of the DOF in the construct that it will be used (e.g. node.vel[0]-node ).
+**
+** $Id: Variable_Register.h 4081 2007-04-27 06:20:07Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Base_Context_Variable_Register_h__
+#define __StGermain_Base_Context_Variable_Register_h__
+
+
+ extern const Type Variable_Register_Type;
+
+ #define __Variable_Register \
+ /* General info */ \
+ __Stg_Class \
+ \
+ /* Virtual info */ \
+ \
+ /* Stg_Class info */ \
+ /** Total number of variables counted */ \
+ Variable_Index count; \
+ SizeT _size; \
+ SizeT _delta; \
+ Variable** _variable; \
+ Stream* errorStream;
+
+ struct _Variable_Register { __Variable_Register };
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructor
+ */
+ Variable_Register* Variable_Register_New(void);
+
+ void Variable_Register_Init(Variable_Register* self);
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define VARIABLE_REGISTER_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define VARIABLE_REGISTER_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ Variable_Register* _Variable_Register_New( VARIABLE_REGISTER_DEFARGS );
+
+ void _Variable_Register_Init(void* variable_Register);
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** General virtual functions
+ */
+
+ void _Variable_Register_Delete(void* variable_Register);
+
+ void _Variable_Register_Print(void* variable_Register, Stream* stream);
+
+ void* _Variable_Register_Copy( void* vr, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Macros
+ */
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Build functions
+ */
+
+ /* Add a variable... do before building */
+ Variable_Index Variable_Register_Add(void* variable_Register, Variable* variable);
+
+ void Variable_Register_BuildAll(void* variable_Register);
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public Functions & Macros
+ */
+
+ Variable_Index Variable_Register_GetIndex(void* variable_Register, Name name);
+
+ Variable* Variable_Register_GetByName(void* variable_Register, Name name);
+
+ Variable* Variable_Register_GetByIndex( void* variable_Register, Variable_Index varIndex);
+
+#endif /* __StGermain_Base_Context_Variable_Register_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/shortcuts.h
--- a/Base/Context/src/shortcuts.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/shortcuts.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Context_shortcuts_h__
-#define __Base_Context_shortcuts_h__
+#ifndef __StGermain_Base_Context_shortcuts_h__
+#define __StGermain_Base_Context_shortcuts_h__
#define Context_PrintConcise AbstractContext_PrintConcise
#define Context_AddEntryPoint AbstractContext_AddEntryPoint
@@ -109,4 +109,4 @@
#define ContextEP_Purge( context, epName ) \
EP_Purge( Context_GetEntryPoint( context, epName ) )
-#endif /* __Base_Context_shortcuts_h__ */
+#endif /* __StGermain_Base_Context_shortcuts_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/types.h
--- a/Base/Context/src/types.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/types.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,9 +39,58 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Context_types_h__
-#define __Base_Context_types_h__
+#ifndef __StGermain_Base_Context_types_h__
+#define __StGermain_Base_Context_types_h__
+ /* types/classes */
+ typedef struct Codelet Codelet;
+ typedef struct _SetVC SetVC;
+ typedef struct _CompositeVC CompositeVC;
+ typedef struct DynamicVC DynamicVC;
+ typedef struct _VariableAllVC_Entry VariableAllVC_Entry;
+ typedef struct _VariableAllVC VariableAllVC;
+ typedef struct _Variable Variable;
+ typedef struct _Variable_Register Variable_Register;
+ typedef struct VariableDumpStream VariableDumpStream;
+ typedef struct _VariableCondition VariableCondition;
+ typedef struct _VariableCondition_Register VariableCondition_Register;
+ typedef struct _ConditionFunction ConditionFunction;
+ typedef struct _ConditionFunction_Register ConditionFunction_Register;
+ typedef Index VariableAllVC_Entry_Index;
+ typedef Index ConditionFunction_Index;
+
+ /* Variable_Register types */
+ typedef Index Variable_Set_Index;
+ typedef Index Variable_Index;
+ typedef Index Dof_Index;
+
+ /* VariableCondition_Register types */
+ typedef struct _VariableCondition_Register_Entry VariableCondition_Register_Entry;
+
+ /* VariableCondition types */
+ typedef enum
+ {
+ VC_ValueType_Double = 1,
+ VC_ValueType_Int,
+ VC_ValueType_Short,
+ VC_ValueType_Char,
+ VC_ValueType_Ptr,
+ VC_ValueType_DoubleArray,
+ VC_ValueType_CFIndex
+ } VariableCondition_ValueType;
+
+ typedef Index VariableCondition_Index;
+ typedef struct _VariableCondition_Value VariableCondition_Value;
+ typedef struct _VariableCondition_Tuple VariableCondition_Tuple;
+ typedef Index VariableCondition_ValueIndex;
+ typedef Index VariableCondition_VariableIndex;
+
+ typedef struct _SetVC_Entry SetVC_Entry;
+ typedef Index SetVC_Entry_Index;
+
+ /* CompositeVC types */
+ typedef Index CompositeVC_ItemIndex;
+
/* Context types/classes */
typedef struct AbstractContext AbstractContext;
typedef struct ContextEntryPoint ContextEntryPoint;
@@ -54,4 +103,4 @@
typedef Stg_ObjectList Pointer_Register;
typedef Stg_ObjectList Register_Register;
-#endif /* __Base_Context_types_h__ */
+#endif /* __StGermain_Base_Context_types_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Context/src/units.h
--- a/Base/Context/src/units.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/src/units.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,7 +39,7 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Context_units_h__
-#define __Base_Context_units_h__
+#ifndef __StGermain_Base_Context_units_h__
+#define __StGermain_Base_Context_units_h__
-#endif /* __Base_Context_units_h__ */
+#endif /* __StGermain_Base_Context_units_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/AbstractContextSuite.c
--- a/Base/Context/tests/AbstractContextSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/tests/AbstractContextSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -49,17 +49,17 @@ Stream* stream;
Stream* stream;
#define __TestContext \
- __AbstractContext \
- unsigned int buildHookCalled; \
- unsigned int icHookCalled; \
- unsigned int dtHookCalled; \
- unsigned int solveHookCalled; \
- unsigned int solve2HookCalled; \
- unsigned int syncHookCalled; \
- unsigned int outputHookCalled; \
- unsigned int dumpHookCalled; \
- unsigned int checkpointHookCalled; \
- double computedValue;
+ __AbstractContext \
+ unsigned int buildHookCalled; \
+ unsigned int icHookCalled; \
+ unsigned int dtHookCalled; \
+ unsigned int solveHookCalled; \
+ unsigned int solve2HookCalled; \
+ unsigned int syncHookCalled; \
+ unsigned int outputHookCalled; \
+ unsigned int dumpHookCalled; \
+ unsigned int checkpointHookCalled; \
+ double computedValue;
struct TestContext { __TestContext };
typedef struct TestContext TestContext;
@@ -71,41 +71,36 @@ void TestSetDt( void* context, double _d
dt = _dt;
}
-
typedef struct {
- TestContext* ctx;
- Dictionary* dict;
+ TestContext* ctx;
+ Dictionary* dict;
} AbstractContextSuiteData;
+TestContext* TestContext_New(
+ Name name,
+ double startTime,
+ double stopTime,
+ MPI_Comm communicator,
+ Dictionary* dictionary )
+{
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(TestContext);
+ Type type = "TestContext";
+ Stg_Class_DeleteFunction* _delete = _AbstractContext_Delete;
+ Stg_Class_PrintFunction* _print = _AbstractContext_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = NULL;
+ Stg_Component_ConstructFunction* _construct = NULL;
+ Stg_Component_BuildFunction* _build = _AbstractContext_Build;
+ Stg_Component_InitialiseFunction* _initialise = _AbstractContext_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _AbstractContext_Execute;
+ Stg_Component_DestroyFunction* _destroy = _AbstractContext_Destroy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+ AbstractContext_SetDt* _setDt = TestSetDt;
-TestContext* TestContext_New(
- Name name,
- double startTime,
- double stopTime,
- MPI_Comm communicator,
- Dictionary* dictionary )
-{
- TestContext* ctx;
+ TestContext* ctx;
- ctx = (TestContext*)_AbstractContext_New(
- sizeof(TestContext),
- "TestContext",
- _AbstractContext_Delete,
- _AbstractContext_Print,
- NULL,
- NULL,
- NULL,
- _AbstractContext_Build,
- _AbstractContext_Initialise,
- _AbstractContext_Execute,
- _AbstractContext_Destroy,
- name,
- True,
- TestSetDt,
- startTime,
- stopTime,
- communicator,
- dictionary );
+ ctx = (TestContext*)_AbstractContext_New( ABSTRACTCONTEXT_PASSARGS );
ctx->buildHookCalled = 0;
ctx->icHookCalled = 0;
@@ -136,7 +131,6 @@ void TestInitialConditions( void* contex
self->computedValue = GLOBAL_COMP_VALUE[self->restartTimestep];
}
}
-
double TestDt( void* context ) {
TestContext* self = (TestContext*)context;
@@ -177,8 +171,9 @@ void TestDump( void* context ) {
}
void AbstractContextSuite_Setup( AbstractContextSuiteData* data ) {
- MPI_Comm CommWorld;
- Index ii;
+ Stg_ComponentFactory* cf;
+ MPI_Comm CommWorld;
+ Index ii;
data->dict = Dictionary_New();
@@ -187,46 +182,44 @@ void AbstractContextSuite_Setup( Abstrac
Dictionary_Add( data->dict, "dumpEvery", Dictionary_Entry_Value_FromUnsignedInt( 2 ) );
Dictionary_Add( data->dict, "maxTimeSteps", Dictionary_Entry_Value_FromUnsignedInt( 10 ) );
+ cf = Stg_ComponentFactory_New( data->dict, NULL );
+
for (ii=0; ii < MAX_TIME_STEPS; ii++) {
GLOBAL_COMP_VALUE[ii] = 0.0;
}
MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
/* Build the context */
- data->ctx = TestContext_New(
- "context",
- 0,
- 0,
- CommWorld,
- data->dict );
+ data->ctx = TestContext_New( "context", 0, 0, CommWorld, data->dict );
+
+ _AbstractContext_Init( (AbstractContext*)data->ctx );
+ _AbstractContext_AssignFromXML( data->ctx, cf, NULL );
Stream_Enable( data->ctx->info, False );
}
void AbstractContextSuite_Teardown( AbstractContextSuiteData* data ) {
- Stg_Class_Delete( data->ctx );
- Stg_Class_Delete( data->dict );
+ _Stg_Component_Delete( data->ctx );
}
-
void AbstractContextSuite_TestDefaultEPs( AbstractContextSuiteData* data ) {
ContextEntryPoint* contextEP=NULL;
/* Assert that default EPs are set up correctly, eg for saving */
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_Construct" );
pcu_check_true( contextEP->hooks->count == 1 );
- pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "default" );
+ pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "_AbstractContext_Construct_Hook" );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_ConstructExtensions" );
pcu_check_true( contextEP->hooks->count == 0 );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_Build" );
- pcu_check_true( contextEP->hooks->count == 1 );
- pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "BuildAllLiveComponents" );
+ pcu_check_true( contextEP->hooks->count == 0 );
+ //pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "BuildAllLiveComponents" );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_Initialise" );
- pcu_check_true( contextEP->hooks->count == 1 );
- pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "InitialiseAllLiveComponents" );
+ pcu_check_true( contextEP->hooks->count == 0 );
+ //pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "InitialiseAllLiveComponents" );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_Execute" );
pcu_check_true( contextEP->hooks->count == 1 );
- pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "default" );
+ pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "_AbstractContext_Execute_Hook" );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_Destroy" );
pcu_check_true( contextEP->hooks->count == 0 );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_DestroyExtensions" );
@@ -235,7 +228,7 @@ void AbstractContextSuite_TestDefaultEPs
pcu_check_true( contextEP->hooks->count == 0 );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_Step" );
pcu_check_true( contextEP->hooks->count == 1 );
- pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "default" );
+ pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "_AbstractContext_Step" );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_Solve" );
pcu_check_true( contextEP->hooks->count == 0 );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_UpdateClass" );
@@ -250,8 +243,8 @@ void AbstractContextSuite_TestDefaultEPs
pcu_check_true( contextEP->hooks->count == 0 );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_Save" );
pcu_check_true( contextEP->hooks->count == 2 );
- pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "CreateCheckpointDirectory" );
- pcu_check_streq( ((Hook*)contextEP->hooks->data[1])->name, "SaveTimeInfo" );
+ pcu_check_streq( ((Hook*)contextEP->hooks->data[0])->name, "_AbstractContext_CreateCheckpointDirectory" );
+ pcu_check_streq( ((Hook*)contextEP->hooks->data[1])->name, "_AbstractContext_SaveTimeInfo" );
contextEP = (ContextEntryPoint*)AbstractContext_GetEntryPoint( data->ctx, "Context_SaveClass" );
pcu_check_true( contextEP->hooks->count == 0 );
}
@@ -279,14 +272,9 @@ void AbstractContextSuite_TestRunBasic(
pcu_check_true( data->ctx->solve2HookCalled == 10 );
pcu_check_true( data->ctx->syncHookCalled == 10 );
pcu_check_true( data->ctx->outputHookCalled == 10 );
- pcu_check_true( data->ctx->dumpHookCalled ==
- 10/Dictionary_GetUnsignedInt(data->dict, "dumpEvery" ) );
- pcu_check_true( data->ctx->checkpointHookCalled ==
- 10/Dictionary_GetUnsignedInt(data->dict, "checkpointEvery" ) );
-
- Stg_Component_Destroy( data->ctx, 0 /* dummy */, False );
+ pcu_check_true( data->ctx->dumpHookCalled == 10/Dictionary_GetUnsignedInt(data->dict, "dumpEvery" ) );
+ pcu_check_true( data->ctx->checkpointHookCalled == 10/Dictionary_GetUnsignedInt(data->dict, "checkpointEvery" ) );
}
-
void AbstractContextSuite_TestRunNoDtDefined( AbstractContextSuiteData* data ) {
ContextEP_ReplaceAll( data->ctx, AbstractContext_EP_Build, TestBuild );
@@ -301,12 +289,10 @@ void AbstractContextSuite_TestRunNoDtDef
stJournal->enable = False;
pcu_check_assert( Stg_Component_Execute( data->ctx, 0 /* dummy */, False ) );
stJournal->enable = True;
-
- Stg_Component_Destroy( data->ctx, 0 /* dummy */, False );
}
-
void AbstractContextSuite_TestRestartFromCheckpoint( AbstractContextSuiteData* data ) {
+ Stg_ComponentFactory* cf;
MPI_Comm CommWorld;
ContextEP_ReplaceAll( data->ctx, AbstractContext_EP_Build, TestBuild );
@@ -319,19 +305,24 @@ void AbstractContextSuite_TestRestartFro
Stg_Component_Execute( data->ctx, 0 /* dummy */, False );
Stg_Component_Destroy( data->ctx, 0 /* dummy */, False );
- Stg_Class_Delete( data->ctx );
-
+ data->dict = Dictionary_New();
+
+ Dictionary_Add( data->dict, "outputPath", Dictionary_Entry_Value_FromString( "output" ) );
+ Dictionary_Add( data->dict, "checkpointEvery", Dictionary_Entry_Value_FromUnsignedInt( 5 ) );
+ Dictionary_Add( data->dict, "dumpEvery", Dictionary_Entry_Value_FromUnsignedInt( 2 ) );
+ Dictionary_Add( data->dict, "maxTimeSteps", Dictionary_Entry_Value_FromUnsignedInt( 10 ) );
+
/* ReBuild the context */
Dictionary_Set( data->dict, "maxTimeSteps", Dictionary_Entry_Value_FromUnsignedInt( 20 ) );
Dictionary_Set( data->dict, "restartTimestep", Dictionary_Entry_Value_FromUnsignedInt( 5 ) );
MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
+ cf = Stg_ComponentFactory_New( data->dict, NULL );
- data->ctx = TestContext_New(
- "context",
- 0,
- 0,
- CommWorld,
- data->dict );
+ data->ctx = TestContext_New( "context", 0, 0, CommWorld, data->dict );
+
+ _AbstractContext_Init( (AbstractContext*)data->ctx );
+ _AbstractContext_AssignFromXML( data->ctx, cf, NULL );
+
Stream_Enable( data->ctx->info, False );
/* add hooks to existing entry points */
@@ -348,11 +339,8 @@ void AbstractContextSuite_TestRestartFro
/* As a fairly simple test of basic CP infrastructure, we know that the timesteps should equal
* run1_ts + run2_ts, and computed value should equal 1.1 to power (run1_ts + run2_ts) */
pcu_check_true( data->ctx->timeStep == (5 + 20) );
- pcu_check_true( data->ctx->computedValue == pow( 1.1, (5 + 20) ) );
-
- Stg_Component_Destroy( data->ctx, 0 /* dummy */, False );
+ pcu_check_true( abs(data->ctx->computedValue - pow( 1.1, (5 + 20) )) < 1e-8 );
}
-
void AbstractContextSuite( pcu_suite_t* suite ) {
pcu_suite_setData( suite, AbstractContextSuiteData );
@@ -362,3 +350,5 @@ void AbstractContextSuite( pcu_suite_t*
pcu_suite_addTest( suite, AbstractContextSuite_TestRunNoDtDefined );
pcu_suite_addTest( suite, AbstractContextSuite_TestRestartFromCheckpoint );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/ConditionFunctionSuite.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/ConditionFunctionSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,82 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+**
+** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "pcu/pcu.h"
+#include "StGermain/Base/Foundation/Foundation.h"
+#include "StGermain/Base/IO/IO.h"
+#include "StGermain/Base/Container/Container.h"
+#include "StGermain/Base/Automation/Automation.h"
+#include "StGermain/Base/Extensibility/Extensibility.h"
+#include "StGermain/Base/Context/Context.h"
+#include "ConditionFunctionSuite.h"
+
+typedef struct {
+} ConditionFunctionSuiteData;
+
+
+#define TEST_CF_RESULT 10
+
+void func(Index index, Variable_Index var_I, void* context, void* result)
+{
+ *((double*)result) = TEST_CF_RESULT;
+}
+
+
+void ConditionFunctionSuite_Setup( ConditionFunctionSuiteData* data ) {
+}
+
+void ConditionFunctionSuite_Teardown( ConditionFunctionSuiteData* data ) {
+}
+
+
+void ConditionFunctionSuite_TestApply( ConditionFunctionSuiteData* data ) {
+ ConditionFunction* cf;
+ double result;
+
+ cf = ConditionFunction_New(func, "quadratic");
+
+ ConditionFunction_Apply(cf, 4, 2, NULL, &result);
+ pcu_check_true( TEST_CF_RESULT == result );
+
+ Stg_Class_Delete(cf);
+}
+
+
+void ConditionFunctionSuite( pcu_suite_t* suite ) {
+ pcu_suite_setData( suite, ConditionFunctionSuiteData );
+ pcu_suite_setFixtures( suite, ConditionFunctionSuite_Setup, ConditionFunctionSuite_Teardown );
+ pcu_suite_addTest( suite, ConditionFunctionSuite_TestApply );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/ConditionFunctionSuite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/ConditionFunctionSuite.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,6 @@
+#ifndef StGermain_ConditionFunctionSuite_h
+#define StGermain_ConditionFunctionSuite_h
+
+void ConditionFunctionSuite( pcu_suite_t* suite );
+
+#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/DictionaryCheckSuite.c
--- a/Base/Context/tests/DictionaryCheckSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Context/tests/DictionaryCheckSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -42,7 +42,7 @@
#include "DictionaryCheckSuite.h"
typedef struct {
- unsigned int rank;
+ int rank;
} DictionaryCheckSuiteData;
void DictionaryCheckSuite_Setup( DictionaryCheckSuiteData* data ) {
@@ -120,3 +120,5 @@ void DictionaryCheckSuite( pcu_suite_t*
pcu_suite_setFixtures( suite, DictionaryCheckSuite_Setup, DictionaryCheckSuite_Teardown );
pcu_suite_addTest( suite, DictionaryCheckSuite_TestCheckKeys );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/LiveComponentRegisterSuite.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/LiveComponentRegisterSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,134 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+**
+** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "pcu/pcu.h"
+#include "StGermain/Base/Foundation/Foundation.h"
+#include "StGermain/Base/IO/IO.h"
+#include "StGermain/Base/Container/Container.h"
+#include "StGermain/Base/Automation/Automation.h"
+#include "StGermain/Base/Extensibility/Extensibility.h"
+#include "StGermain/Base/Context/Context.h"
+#include "LiveComponentRegisterSuite.h"
+
+typedef struct {
+ LiveComponentRegister* lcRegister;
+} LiveComponentRegisterSuiteData;
+
+
+void LiveComponentRegisterSuite_Setup( LiveComponentRegisterSuiteData* data ) {
+ data->lcRegister = LiveComponentRegister_New( );
+}
+
+void LiveComponentRegisterSuite_Teardown( LiveComponentRegisterSuiteData* data ) {
+ Stg_Class_Delete( data->lcRegister );
+}
+
+
+void LiveComponentRegisterSuite_TestGet( LiveComponentRegisterSuiteData* data ) {
+ typedef float Triple[3];
+
+ float* array;
+ Triple* structArray;
+
+ Variable* var;
+ Variable* vec;
+ Variable* vecVar[3];
+ Variable* tempVar = NULL;
+ Index length = 10;
+
+ Variable_Register* reg;
+
+ array = Memory_Alloc_Array( float, length, "test" );
+ structArray = Memory_Alloc_Array( Triple, length, "test" );
+
+ reg = Variable_Register_New();
+
+ var = Variable_NewScalar(
+ "Scalar",
+ NULL,
+ Variable_DataType_Float,
+ &length,
+ NULL,
+ (void**)&array,
+ reg );
+
+ vec = Variable_NewVector(
+ "Three",
+ NULL,
+ Variable_DataType_Float,
+ 3,
+ &length,
+ NULL,
+ (void**)&structArray,
+ reg,
+ "a",
+ "b",
+ "c" );
+
+ vecVar[0] = Variable_Register_GetByName( reg, "a" );
+ vecVar[1] = Variable_Register_GetByName( reg, "b" );
+ vecVar[2] = Variable_Register_GetByName( reg, "c" );
+
+ Variable_Register_BuildAll( reg );
+
+ LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) var );
+ LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) vec );
+ LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) vecVar[0] );
+ LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) vecVar[1] );
+ LiveComponentRegister_Add( data->lcRegister, (Stg_Component*) vecVar[2] );
+
+ tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "Scalar" );
+ pcu_check_true( tempVar == var );
+
+ tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "Three" );
+ pcu_check_true( tempVar == vec );
+
+ tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "a" );
+ pcu_check_true( tempVar == vecVar[0] );
+
+ tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "b" );
+ pcu_check_true( tempVar == vecVar[1] );
+
+ tempVar = (Variable*) LiveComponentRegister_Get( data->lcRegister, "c" );
+ pcu_check_true( tempVar == vecVar[2] );
+}
+
+
+void LiveComponentRegisterSuite( pcu_suite_t* suite ) {
+ pcu_suite_setData( suite, LiveComponentRegisterSuiteData );
+ pcu_suite_setFixtures( suite, LiveComponentRegisterSuite_Setup, LiveComponentRegisterSuite_Teardown );
+ pcu_suite_addTest( suite, LiveComponentRegisterSuite_TestGet );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/LiveComponentRegisterSuite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/LiveComponentRegisterSuite.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,6 @@
+#ifndef StGermain_LiveComponentRegisterSuite_h
+#define StGermain_LiveComponentRegisterSuite_h
+
+void LiveComponentRegisterSuite( pcu_suite_t* suite );
+
+#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/SetVC_Suite.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/SetVC_Suite.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,259 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+**
+** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "pcu/pcu.h"
+#include "StGermain/Base/Foundation/Foundation.h"
+#include "StGermain/Base/IO/IO.h"
+#include "StGermain/Base/Container/Container.h"
+#include "StGermain/Base/Automation/Automation.h"
+#include "StGermain/Base/Extensibility/Extensibility.h"
+#include "StGermain/Base/Context/Context.h"
+#include "SetVC_Suite.h"
+
+/* Note that these params below must match up with setVC.xml input file for the test to work */
+#define NUM_VARS 7
+#define X_INDEX 0
+#define Y_INDEX 1
+#define Z_INDEX 2
+#define VX_INDEX 3
+#define VY_INDEX 4
+#define VZ_INDEX 5
+#define TEMP_INDEX 6
+
+#define NUM_NODES 64
+#define LAST_VC_NODE_INDEX 26
+#define TEMP_VAR_ARRAYSIZE 5
+
+#define VX_CONDVALUE 2
+#define VY_CONDVALUE 20.0
+#define VZ_CONDVALUE 1
+#define TEMP_CONDVALUE_BASE 5
+
+
+typedef struct {
+ Variable_Register* vr;
+ ConditionFunction_Register* conFunc_Register;
+ Dictionary* dict;
+ ConditionFunction* quadCF;
+ double* array[NUM_VARS];
+ Index arraySize;
+ char* varNames[NUM_VARS];
+ Variable* var[NUM_VARS];
+ VariableCondition* vc;
+} SetVC_SuiteData;
+
+
+void quadratic(Index index, Variable_Index var_I, void* context, void* result)
+{
+ *(double *)result = 20.0;
+}
+
+
+void SetVC_Suite_Setup( SetVC_SuiteData* data ) {
+ Index ii=0;
+ char setVC_XMLFilename[PCU_PATH_MAX];
+ XML_IO_Handler* io_handler = XML_IO_Handler_New();
+
+ data->vr = Variable_Register_New();
+ data->conFunc_Register = ConditionFunction_Register_New();
+ data->dict = Dictionary_New();
+ data->arraySize = NUM_NODES;
+
+ Stg_asprintf( &data->varNames[X_INDEX], "x" );
+ Stg_asprintf( &data->varNames[Y_INDEX], "y" );
+ Stg_asprintf( &data->varNames[Z_INDEX], "z" );
+ Stg_asprintf( &data->varNames[VX_INDEX], "vx" );
+ Stg_asprintf( &data->varNames[VY_INDEX], "vy" );
+ Stg_asprintf( &data->varNames[VZ_INDEX], "vz" );
+ Stg_asprintf( &data->varNames[TEMP_INDEX], "temp" );
+
+ /* Load the definition of the SetVC from XML */
+ pcu_filename_input( "setVC.xml", setVC_XMLFilename );
+ IO_Handler_ReadAllFromFile( io_handler, setVC_XMLFilename, data->dict );
+
+ /* Create CF stuff */
+ data->quadCF = ConditionFunction_New( quadratic, "quadratic" );
+ ConditionFunction_Register_Add( data->conFunc_Register, data->quadCF );
+
+ /* Create variables */
+ for (ii = 0; ii < (TEMP_INDEX); ii++) {
+ data->array[ii] = Memory_Alloc_Array( double, data->arraySize, "data->array[]" );
+ data->var[ii] = Variable_NewScalar( data->varNames[ii], NULL, Variable_DataType_Double, &data->arraySize, NULL,
+ (void**)&data->array[ii], 0 );
+ Variable_Register_Add(data->vr, data->var[ii]);
+ }
+
+ data->array[TEMP_INDEX] = Memory_Alloc_Array( double , data->arraySize*TEMP_VAR_ARRAYSIZE, "data->array[TEMP_INDEX]" );
+ data->var[TEMP_INDEX] = Variable_NewVector( data->varNames[TEMP_INDEX], NULL, Variable_DataType_Double, TEMP_VAR_ARRAYSIZE,
+ &data->arraySize, NULL, (void**)&data->array[TEMP_INDEX], 0, "a", "b", "c", "d", "e" );
+ Variable_Register_Add( data->vr, data->var[TEMP_INDEX] );
+
+ Variable_Register_BuildAll( data->vr );
+
+ /* Create the VC */
+ data->vc = (VariableCondition*)SetVC_New( "setVC", NULL, "setVC", data->vr, data->conFunc_Register, data->dict );
+ Stg_Component_Build( data->vc, 0, False );
+
+ /* Blank the memory to be applied to before the test */
+ for (ii = 0; ii < (TEMP_INDEX); ii++) {
+ memset(data->array[ii], 0, sizeof(double)*NUM_NODES);
+ }
+ memset(data->array[TEMP_INDEX], 0, sizeof(double)*NUM_NODES*TEMP_VAR_ARRAYSIZE);
+
+ Memory_Free( io_handler );
+}
+
+
+void SetVC_Suite_Teardown( SetVC_SuiteData* data ) {
+ Index ii=0;
+
+ Stg_Class_Delete(data->vr);
+ Stg_Class_Delete(data->conFunc_Register);
+ Stg_Class_Delete(data->dict);
+
+ Stg_Class_Delete(data->quadCF);
+
+ for (ii = 0; ii < NUM_VARS; ii++) {
+ if (data->array[ii]) Memory_Free(data->array[ii]);
+ Stg_Class_Delete( data->var[ii] );
+ }
+
+ Stg_Class_Delete(data->vc);
+}
+
+
+void SetVC_Suite_TestIsCondition( SetVC_SuiteData* data ) {
+ Index var_I=0, node_I=0;
+
+ /* remember varName[] = {"x", "y", "z", "vx", "vy", "vz", "temp"}*/
+
+ /* X, Y, and Z shouldn't have Conditions applied to them */
+ for( var_I = 0; var_I < VX_INDEX; var_I++ ) {
+ for (node_I = 0; node_I < NUM_NODES; node_I++) {
+ pcu_check_true( False == VariableCondition_IsCondition(data->vc, node_I, var_I) );
+ }
+ }
+ /* VX, VY, VZ, and temp should have Conditions applied to them, at even indices */
+ for( var_I = VX_INDEX; var_I < NUM_VARS; var_I++ ) {
+ for (node_I = 0; node_I < NUM_NODES; node_I++) {
+ if ( (node_I % 2 == 0) && node_I <= LAST_VC_NODE_INDEX ) {
+ pcu_check_true( True == VariableCondition_IsCondition(data->vc, node_I, var_I) );
+ }
+ else {
+ pcu_check_true( False == VariableCondition_IsCondition(data->vc, node_I, var_I) );
+ }
+ }
+ }
+}
+
+
+void SetVC_Suite_TestGetValueIndex( SetVC_SuiteData* data ) {
+ Index var_I=0, node_I=0;
+
+ /* remember varName[] = {"x", "y", "z", "vx", "vy", "vz", "temp"}*/
+ /* These results are dependent on the order the conditions are added in the dictionary */
+
+ for( var_I = 0; var_I < VX_INDEX; var_I++ ) {
+ for (node_I = 0; node_I < NUM_NODES; node_I++) {
+ pcu_check_true( (unsigned)-1 == VariableCondition_GetValueIndex(data->vc, node_I, var_I) );
+ }
+ }
+ for( var_I = VX_INDEX; var_I < NUM_VARS; var_I++ ) {
+ for (node_I = 0; node_I < NUM_NODES; node_I++) {
+ if ( (node_I % 2 == 0) && node_I <= LAST_VC_NODE_INDEX ) {
+ /* Condition indices will start at 0, starting at condition 3 "vx" */
+ pcu_check_true( (var_I-VX_INDEX) == VariableCondition_GetValueIndex(data->vc, node_I, var_I) );
+ }
+ else {
+ pcu_check_true( (unsigned)-1 == VariableCondition_GetValueIndex(data->vc, node_I, var_I) );
+ }
+ }
+ }
+}
+
+
+void SetVC_Suite_TestApply( SetVC_SuiteData* data ) {
+ Index var_I=0, node_I=0, array_I=0;
+
+ /* remember varName[] = {"x", "y", "z", "vx", "vy", "vz", "temp"}; */
+
+ VariableCondition_Apply(data->vc, NULL);
+
+ for( var_I = 0; var_I < VX_INDEX; var_I++ ) {
+ for (node_I = 0; node_I < NUM_NODES; node_I++) {
+ pcu_check_true( 0 == data->array[var_I][node_I] );
+ }
+ }
+ for( var_I = VX_INDEX; var_I < TEMP_INDEX; var_I++ ) {
+ for (node_I = 0; node_I < NUM_NODES; node_I++) {
+ if ( (node_I % 2 == 0) && node_I <= LAST_VC_NODE_INDEX ) {
+ if (var_I == VX_INDEX) {
+ pcu_check_true( VX_CONDVALUE == data->array[var_I][node_I] );
+ }
+ else if (var_I == VY_INDEX) {
+ pcu_check_true( VY_CONDVALUE == data->array[var_I][node_I] );
+ }
+ else if (var_I == VZ_INDEX) {
+ pcu_check_true( VZ_CONDVALUE == data->array[var_I][node_I] );
+ }
+ }
+ else {
+ pcu_check_true( 0 == data->array[var_I][node_I] );
+ }
+ }
+ }
+ /* Now for the "temp" variable */
+ for (node_I = 0; node_I < NUM_NODES; node_I++) {
+ for( array_I = 0; array_I < TEMP_VAR_ARRAYSIZE; array_I++ ) {
+ if ( (node_I % 2 == 0) && node_I <= LAST_VC_NODE_INDEX ) {
+ pcu_check_true( (TEMP_CONDVALUE_BASE+array_I) == data->array[TEMP_INDEX][node_I*TEMP_VAR_ARRAYSIZE + array_I] );
+ }
+ else {
+ pcu_check_true( 0 == data->array[TEMP_INDEX][node_I*TEMP_VAR_ARRAYSIZE + array_I] );
+ }
+ }
+ }
+}
+
+
+void SetVC_Suite( pcu_suite_t* suite ) {
+ pcu_suite_setData( suite, SetVC_SuiteData );
+ pcu_suite_setFixtures( suite, SetVC_Suite_Setup, SetVC_Suite_Teardown );
+ pcu_suite_addTest( suite, SetVC_Suite_TestIsCondition );
+ pcu_suite_addTest( suite, SetVC_Suite_TestGetValueIndex );
+ pcu_suite_addTest( suite, SetVC_Suite_TestApply );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/SetVC_Suite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/SetVC_Suite.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,6 @@
+#ifndef StGermain_SetVC_Suite_h
+#define StGermain_SetVC_Suite_h
+
+void SetVC_Suite( pcu_suite_t* suite );
+
+#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/Stg_MetaSuite.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/Stg_MetaSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+**
+** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "pcu/pcu.h"
+#include "StGermain/Base/Foundation/Foundation.h"
+#include "StGermain/Base/IO/IO.h"
+#include "StGermain/Base/Container/Container.h"
+#include "StGermain/Base/Automation/Automation.h"
+#include "StGermain/Base/Extensibility/Extensibility.h"
+#include "StGermain/Base/Context/Context.h"
+#include "Stg_MetaSuite.h"
+
+
+typedef struct {
+ XML_IO_Handler* io;
+ Dictionary* metaDict;
+ LiveComponentRegister* lcRegister;
+} Stg_MetaSuiteData;
+
+
+void Stg_MetaSuite_Setup( Stg_MetaSuiteData* data ) {
+ data->io = XML_IO_Handler_New();
+ data->metaDict = Dictionary_New();
+ data->lcRegister = LiveComponentRegister_New( );
+}
+
+
+void Stg_MetaSuite_Teardown( Stg_MetaSuiteData* data ) {
+ Stg_Class_Delete( data->io );
+ Stg_Class_Delete( data->metaDict );
+ Stg_Class_Delete( data->lcRegister );
+}
+
+
+/* Use this function if you need to regenerate the testing .xml file */
+void Stg_MetaSuite_RegenerateComponentVC_MetaFile( Stg_MetaSuiteData* data ) {
+ Stg_Class_Delete( data->metaDict );
+ data->metaDict = Stg_ComponentRegister_GetMetadata( Stg_ComponentRegister_Get_ComponentRegister(), CompositeVC_Type, "0" );
+ IO_Handler_WriteAllToFile( data->io, "ComponentVCMetaDict.xml", data->metaDict );
+}
+
+
+void Stg_MetaSuite_TestGetFunctions( Stg_MetaSuiteData* data ) {
+ char metaFilename[PCU_PATH_MAX];
+ Index paramCount=0;
+ Index assocCount=0;
+
+ pcu_filename_input( "ComponentVCMetaDict.xml", metaFilename );
+ IO_Handler_ReadAllFromFile( data->io, metaFilename, data->metaDict );
+
+ pcu_check_streq( Stg_Meta_GetType( data->metaDict ), "CompositeVC" );
+ pcu_check_streq( Stg_Meta_GetCreator( data->metaDict ), "VPAC" );
+ pcu_check_streq( Stg_Meta_GetPublisher( data->metaDict ), "VPAC" );
+ pcu_check_streq( Stg_Meta_GetRights( data->metaDict ), "The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html" );
+ pcu_check_streq( Stg_Meta_GetSource( data->metaDict ), "./StGermain/Base/Automation/src/" );
+ pcu_check_streq( Stg_Meta_GetSubject( data->metaDict ), "StGermain" );
+ pcu_check_streq( Stg_Meta_GetDescription( data->metaDict ), "CompositeVC is used as a container to combine multiple variable conditions." );
+ pcu_check_streq( Stg_Meta_GetExampleDocumentation( data->metaDict ), "" );
+ pcu_check_streq( Stg_Meta_GetExampleCode( data->metaDict ), "Refer to ./StgFEM/Apps/StokesMomentumUzawa/lidDrivenBCs.xml" );
+ pcu_check_streq( Stg_Meta_GetInherits( data->metaDict ), "VariableCondition" );
+
+ pcu_check_streq( Stg_Meta_GetReference( data->metaDict ), "" );
+ pcu_check_streq( Stg_Meta_GetEquation( data->metaDict ), "" );
+
+ paramCount = Stg_Meta_GetParameterCount( data->metaDict );
+ pcu_check_true( paramCount == 2 );
+ pcu_check_streq( Stg_Meta_GetParameterName( data->metaDict, 0 ), "vcName" );
+ pcu_check_streq( Stg_Meta_GetParameterType( data->metaDict, 0 ), "xsd:string" );
+ pcu_check_streq( Stg_Meta_GetParameterDefault( data->metaDict, 0 ), "self->name" );
+ pcu_check_streq( Stg_Meta_GetParameterDocumentation( data->metaDict, 0 ), "Deprecated; should not be used." );
+ pcu_check_streq( Stg_Meta_GetParameterName( data->metaDict, 1 ), "vcList" );
+ pcu_check_streq( Stg_Meta_GetParameterType( data->metaDict, 1 ), "stg:list" );
+ pcu_check_streq( Stg_Meta_GetParameterDefault( data->metaDict, 1 ), "" );
+ pcu_check_streq( Stg_Meta_GetParameterDocumentation( data->metaDict, 1 ), "A list of other VariableCondition definitions." );
+
+ assocCount = Stg_Meta_GetAssociationCount( data->metaDict );
+ pcu_check_true( assocCount == 1 );
+ pcu_check_streq( Stg_Meta_GetAssociationName( data->metaDict, 0 ), "Data" );
+ pcu_check_streq( Stg_Meta_GetAssociationType( data->metaDict, 0 ), "Stg_Component" );
+ pcu_check_streq( Stg_Meta_GetAssociationNillable( data->metaDict, 0 ), "true" );
+ pcu_check_streq( Stg_Meta_GetAssociationDocumentation( data->metaDict, 0 ), "User defined data in the form of a Stg_Component." );
+}
+
+
+void Stg_MetaSuite( pcu_suite_t* suite ) {
+ pcu_suite_setData( suite, Stg_MetaSuiteData );
+ pcu_suite_setFixtures( suite, Stg_MetaSuite_Setup, Stg_MetaSuite_Teardown );
+ pcu_suite_addTest( suite, Stg_MetaSuite_TestGetFunctions );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/Stg_MetaSuite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/Stg_MetaSuite.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,6 @@
+#ifndef StGermain_Stg_MetaSuite_h
+#define StGermain_Stg_MetaSuite_h
+
+void Stg_MetaSuite( pcu_suite_t* suite );
+
+#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/VariableAllVC_Suite.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/VariableAllVC_Suite.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,149 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+**
+** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "pcu/pcu.h"
+#include "StGermain/Base/Foundation/Foundation.h"
+#include "StGermain/Base/IO/IO.h"
+#include "StGermain/Base/Container/Container.h"
+#include "StGermain/Base/Automation/Automation.h"
+#include "StGermain/Base/Extensibility/Extensibility.h"
+#include "StGermain/Base/Context/Context.h"
+#include "VariableAllVC_Suite.h"
+
+#define TEST_CONDVALUE 2.0
+
+
+typedef struct {
+ Variable_Register* vr;
+ ConditionFunction_Register* conFunc_Register;
+ Dictionary* dict;
+ double* testArray;
+ Index arraySize;
+ Variable* var;
+ char* vcKey;
+ VariableCondition* vc;
+} VariableAllVC_SuiteData;
+
+
+void VariableAllVC_Suite_CreateDictEntries( VariableAllVC_SuiteData* data ) {
+ Dictionary_Entry_Value* info;
+ Dictionary_Entry_Value* varList;
+ Dictionary_Entry_Value* varValue;
+
+ info = Dictionary_Entry_Value_NewStruct();
+ varList = Dictionary_Entry_Value_NewList();
+ varValue = Dictionary_Entry_Value_NewStruct();
+
+ Dictionary_Entry_Value_AddMember( varValue, "name", Dictionary_Entry_Value_FromString( "test" ) );
+ Dictionary_Entry_Value_AddMember( varValue, "type", Dictionary_Entry_Value_FromString( "double" ) );
+ Dictionary_Entry_Value_AddMember( varValue, "value", Dictionary_Entry_Value_FromDouble( TEST_CONDVALUE ) );
+
+ Dictionary_Entry_Value_AddElement( varList, varValue );
+ Dictionary_Entry_Value_AddMember( info, "variables", varList );
+ Dictionary_Add( data->dict, data->vcKey, info );
+}
+
+
+void VariableAllVC_Suite_Setup( VariableAllVC_SuiteData* data ) {
+ data->arraySize = 10;
+ data->testArray = Memory_Alloc_Array( double, data->arraySize, "test" );
+
+ data->dict = Dictionary_New();
+ data->conFunc_Register = ConditionFunction_Register_New();
+ data->vr = Variable_Register_New();
+
+ Stg_asprintf( &data->vcKey, "VariableAllVC" );
+ VariableAllVC_Suite_CreateDictEntries( data );
+
+ data->var = Variable_NewScalar( "test", NULL, Variable_DataType_Double, &data->arraySize, NULL, (void**)&data->testArray, data->vr );
+
+ Variable_Register_BuildAll(data->vr);
+
+ data->vc = (VariableCondition*) VariableAllVC_New( "variableAllVC", NULL, "VariableAllVC", data->vr, data->conFunc_Register, data->dict, NULL );
+
+ Stg_Component_Build( data->vc, 0, False );
+}
+
+
+void VariableAllVC_Suite_Teardown( VariableAllVC_SuiteData* data ) {
+ Stg_Class_Delete(data->vr);
+ Stg_Class_Delete(data->conFunc_Register);
+ Stg_Class_Delete(data->dict);
+
+ Memory_Free( data->testArray );
+ Stg_Class_Delete( data->var );
+
+ _Stg_Component_Delete(data->vc);
+}
+
+
+void VariableAllVC_Suite_TestIsCondition( VariableAllVC_SuiteData* data ) {
+ Index node_I=0;
+
+ for (node_I = 0; node_I < data->arraySize; node_I++) {
+ pcu_check_true( True == VariableCondition_IsCondition(data->vc, node_I, 0) );
+ }
+}
+
+
+void VariableAllVC_Suite_TestGetValueIndex( VariableAllVC_SuiteData* data ) {
+ Index node_I=0;
+
+ for (node_I = 0; node_I < data->arraySize; node_I++) {
+ pcu_check_true( 0 == VariableCondition_GetValueIndex(data->vc, node_I, 0) );
+ }
+}
+
+
+void VariableAllVC_Suite_TestApply( VariableAllVC_SuiteData* data ) {
+ Index node_I=0;
+
+ VariableCondition_Apply(data->vc, NULL);
+
+ for (node_I = 0; node_I < data->arraySize; node_I++) {
+ pcu_check_true( TEST_CONDVALUE == data->testArray[node_I] );
+ }
+}
+
+
+void VariableAllVC_Suite( pcu_suite_t* suite ) {
+ pcu_suite_setData( suite, VariableAllVC_SuiteData );
+ pcu_suite_setFixtures( suite, VariableAllVC_Suite_Setup, VariableAllVC_Suite_Teardown );
+ pcu_suite_addTest( suite, VariableAllVC_Suite_TestIsCondition );
+ pcu_suite_addTest( suite, VariableAllVC_Suite_TestGetValueIndex );
+ pcu_suite_addTest( suite, VariableAllVC_Suite_TestApply );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/VariableAllVC_Suite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/VariableAllVC_Suite.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,6 @@
+#ifndef StGermain_VariableAllVC_Suite_h
+#define StGermain_VariableAllVC_Suite_h
+
+void VariableAllVC_Suite( pcu_suite_t* suite );
+
+#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/VariableDumpStreamSuite.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/VariableDumpStreamSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,164 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+**
+** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "pcu/pcu.h"
+#include "StGermain/Base/Foundation/Foundation.h"
+#include "StGermain/Base/IO/IO.h"
+#include "StGermain/Base/Container/Container.h"
+#include "StGermain/Base/Automation/Automation.h"
+#include "StGermain/Base/Extensibility/Extensibility.h"
+#include "StGermain/Base/Context/Context.h"
+#include "VariableDumpStreamSuite.h"
+
+typedef struct {
+ Variable_Register* vr;
+} VariableDumpStreamSuiteData;
+
+
+void VariableDumpStreamSuite_Setup( VariableDumpStreamSuiteData* data ) {
+ /* Construction phase --------------------------------------------------------------------------------------------*/
+ data->vr = Variable_Register_New();
+}
+
+
+void VariableDumpStreamSuite_Teardown( VariableDumpStreamSuiteData* data ) {
+ Variable_Index var_I;
+
+ /* manually delete all the created Variables */
+ for( var_I = 0; var_I < data->vr->count; var_I++ ) {
+ Stg_Class_Delete( data->vr->_variable[var_I] );
+ }
+
+ Stg_Class_Delete( data->vr );
+}
+
+
+void VariableDumpStreamSuite_TestDump( VariableDumpStreamSuiteData* data ) {
+ typedef double Triple[3];
+ double* array;
+ Triple* structArray;
+ Index length = 10;
+ Variable* var;
+ Variable* vec;
+ Stream* dumpStream = NULL;
+ Stream* dumpStream2 = NULL;
+ int i;
+ const Name scalarDumpFilename = "./scalardump.dat" ;
+ const Name vectorDumpFilename = "./vectordump.dat" ;
+ FILE* scalarDumpFile = NULL;
+ FILE* vectorDumpFile = NULL;
+ float scalarCheck = 0;
+ float vectorCheck[3] = {0,0,0};
+
+ array = Memory_Alloc_Array( double, length, "test" );
+ structArray = Memory_Alloc_Array( Triple, length, "test" );
+
+ data->vr = Variable_Register_New();
+
+ var = Variable_NewScalar(
+ "Scalar",
+ NULL,
+ Variable_DataType_Double,
+ &length,
+ NULL,
+ (void**)&array,
+ data->vr );
+
+ vec = Variable_NewVector(
+ "Three",
+ NULL,
+ Variable_DataType_Double,
+ 3,
+ &length,
+ NULL,
+ (void**)&structArray,
+ data->vr,
+ "a",
+ "b",
+ "c" );
+
+ Variable_Register_BuildAll( data->vr );
+
+ for ( i = 0; i < length; ++i ) {
+ Variable_SetValueDouble( var, i, 123.456 );
+
+ Variable_SetValueAtDouble( vec, i, 0, 1.2 );
+ Variable_SetValueAtDouble( vec, i, 1, 3.4 );
+ Variable_SetValueAtDouble( vec, i, 2, 5.6 );
+ }
+
+ dumpStream = Journal_Register( VariableDumpStream_Type, "scalar dump" );
+ VariableDumpStream_SetVariable( dumpStream, var, 1, 0, scalarDumpFilename );
+ pcu_check_true( Journal_Dump( dumpStream, NULL ) );
+ Stream_Flush( dumpStream );
+
+ dumpStream2 = Journal_Register( VariableDumpStream_Type, "vector dump" );
+ VariableDumpStream_SetVariable( dumpStream2, vec, 1, 0, vectorDumpFilename );
+ pcu_check_true( Journal_Dump( dumpStream2, NULL ) );
+ Stream_Flush( dumpStream2 );
+
+ /* Really, you'd think there'd be a function to read a dumpStream. Anyway, hard-code for now */
+ /* Don't want to use expected files here, since we need to continually check the writing ability
+ * of these dump streams */
+ scalarDumpFile = fopen( scalarDumpFilename, "r" );
+ vectorDumpFile = fopen( vectorDumpFilename, "r" );
+ for ( i = 0; i < length; ++i ) {
+ /* See VariableDumpStream.c:166 */
+ pcu_check_true( fread( &scalarCheck, sizeof(float), 1, scalarDumpFile ));
+ pcu_check_true( fabs( scalarCheck - 123.456) < 0.0001 );
+
+ pcu_check_true( fread( vectorCheck, sizeof(float), 3, vectorDumpFile ));
+ pcu_check_true( fabs( vectorCheck[0] - 1.2 ) < 0.001 );
+ pcu_check_true( fabs( vectorCheck[1] - 3.4 ) < 0.001 );
+ pcu_check_true( fabs( vectorCheck[2] - 5.6 ) < 0.001 );
+ }
+
+ Memory_Free( array );
+ Memory_Free( structArray );
+
+ fclose( scalarDumpFile );
+ fclose( vectorDumpFile );
+ remove( scalarDumpFilename );
+ remove( vectorDumpFilename );
+}
+
+
+void VariableDumpStreamSuite( pcu_suite_t* suite ) {
+ pcu_suite_setData( suite, VariableDumpStreamSuiteData );
+ pcu_suite_setFixtures( suite, VariableDumpStreamSuite_Setup, VariableDumpStreamSuite_Teardown );
+ pcu_suite_addTest( suite, VariableDumpStreamSuite_TestDump );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/VariableDumpStreamSuite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/VariableDumpStreamSuite.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,6 @@
+#ifndef StGermain_VariableDumpStreamSuite_h
+#define StGermain_VariableDumpStreamSuite_h
+
+void VariableDumpStreamSuite( pcu_suite_t* suite );
+
+#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/VariableSuite.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/VariableSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,830 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+**
+** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "pcu/pcu.h"
+#include "StGermain/Base/Foundation/Foundation.h"
+#include "StGermain/Base/IO/IO.h"
+#include "StGermain/Base/Container/Container.h"
+#include "StGermain/Base/Automation/Automation.h"
+#include "StGermain/Base/Extensibility/Extensibility.h"
+#include "StGermain/Base/Context/Context.h"
+#include "VariableSuite.h"
+
+typedef double VectorD[3];
+typedef double VectorF[3];
+
+typedef struct {
+ int mass;
+ VectorF force;
+ short num;
+ char* info;
+} Particle;
+
+typedef struct {
+ Variable_Register* vr;
+ Index aSize[3];
+ double* temperature;
+ VectorD* velocity;
+ Particle* particle;
+} VariableSuiteData;
+
+
+
+void VariableSuite_Setup( VariableSuiteData* data ) {
+ Particle tmpParticle;
+ Name pNames[] = { "mass", "force", "info" };
+ SizeT pOffsets[] = { 0, 0, 0 }; /* Init later... */
+ Variable_DataType pDataTypes[] = {
+ Variable_DataType_Int,
+ Variable_DataType_Float,
+ Variable_DataType_Pointer, };
+ Index pDtCounts[] = { 1, 3, 1 };
+ static SizeT pSize = sizeof(Particle);
+
+ data->aSize[0] = 16;
+ data->aSize[1] = 16;
+ data->aSize[2] = 16;
+
+ pOffsets[0] = (ArithPointer)&tmpParticle.mass - (ArithPointer)&tmpParticle;
+ pOffsets[1] = (ArithPointer)&tmpParticle.force - (ArithPointer)&tmpParticle;
+ pOffsets[2] = (ArithPointer)&tmpParticle.info - (ArithPointer)&tmpParticle;
+
+ /* Construction phase --------------------------------------------------------------------------------------------*/
+ data->vr = Variable_Register_New();
+ Variable_NewScalar( "temperature", NULL, Variable_DataType_Double, &data->aSize[0], NULL, (void**)&data->temperature, data->vr );
+ Variable_NewVector( "velocity", NULL, Variable_DataType_Double, 3, &data->aSize[1], NULL, (void**)&data->velocity, data->vr, "vx", "vy", "vz" );
+ Variable_New( "particle", NULL, 3, pOffsets, pDataTypes, pDtCounts, pNames, &pSize, &data->aSize[2], NULL, (void**)&data->particle, data->vr );
+
+ /* Build phase ---------------------------------------------------------------------------------------------------*/
+ data->temperature = Memory_Alloc_Array( double, data->aSize[0], "temperature" );
+ data->velocity = Memory_Alloc_Array( VectorD, data->aSize[1], "velocity" );
+ data->particle = Memory_Alloc_Array( Particle, data->aSize[2], "array" );
+
+ Variable_Register_BuildAll( data->vr );
+}
+
+
+void VariableSuite_Teardown( VariableSuiteData* data ) {
+ Variable_Index var_I;
+
+ /* manually delete all the created Variables */
+ for( var_I = 0; var_I < data->vr->count; var_I++ ) {
+ Stg_Class_Delete( data->vr->_variable[var_I] );
+ }
+
+ Memory_Free( data->particle );
+ Memory_Free( data->velocity );
+ Memory_Free( data->temperature );
+}
+
+
+void VariableSuite_TestGetValueDouble( VariableSuiteData* data ) {
+ Index ii;
+ double tmp;
+ Variable* var = Variable_Register_GetByName( data->vr, "temperature" );
+
+ /* Test the Get and Set of a scalar double....................................................................... */
+ /* Fill the temperature array with a known pattern of kinda random (bit filling) numbers. */
+ for( ii = 0; ii < data->aSize[0]; ii++ ) {
+ data->temperature[ii] = 1.0f / (data->aSize[0]+2) * (ii+1);
+ }
+
+ /* Check that Variable_GetValueDouble on the temperature Variable returns the right numbers */
+ for( ii = 0; ii < data->aSize[0]; ii++ ) {
+ tmp = 1.0f / (data->aSize[0]+2) * (ii+1);
+
+ pcu_check_true( fabs(Variable_GetValueDouble( var, ii ) - tmp ) < 1e-12);
+ }
+}
+
+
+void VariableSuite_TestSetValueDouble( VariableSuiteData* data ) {
+ Index ii;
+ double tmp;
+ Variable* var = Variable_Register_GetByName( data->vr, "temperature" );
+
+ /* Fill the temperature Variable with another known pattern of kinda random (bit filling) numbers */
+ for( ii = 0; ii < data->aSize[0]; ii++ ) {
+
+ Variable_SetValueDouble( var, ii, 1.0f - ( 1.0f / (data->aSize[0]+2) * (ii+1) ) );
+ }
+
+ /* Check that Variable_SetValueDouble on the temperature Variable set the right numbers */
+ for( ii = 0; ii < data->aSize[0]; ii++ ) {
+ tmp = 1.0f - 1.0f / (data->aSize[0]+2) * (ii+1);
+
+ pcu_check_true( fabs(data->temperature[ii] - tmp ) < 1e-12);
+ }
+}
+
+
+/* Test the Get and Set of a vector double....................................................................... */
+void VariableSuite_TestGetValueAtDouble( VariableSuiteData* data ) {
+ Index ii;
+ double tmp;
+ Variable* var = Variable_Register_GetByName( data->vr, "velocity" );
+
+/* Fill the velocity array with a known pattern of kinda random (bit filling) numbers. */
+ for( ii = 0; ii < data->aSize[1]; ii++ ) {
+ int d;
+
+ for( d = 0; d < 3; d++ ) {
+ data->velocity[ii][d] = 1.0f / ((data->aSize[1]*3)+2) * (ii*3+d+1);
+ }
+ }
+
+ /* Check that Variable_GetPtrDouble on the velocity Variable returns the right numbers */
+ for( ii = 0; ii < data->aSize[1]; ii++ ) {
+ int d;
+
+ for( d = 0; d < 3; d++ ) {
+ tmp = 1.0f / ((data->aSize[1]*3)+2) * (ii*3+d+1);
+
+ pcu_check_true( fabs(Variable_GetValueAtDouble(var, ii, d ) - tmp) < 1e-12);
+ }
+ }
+}
+
+
+void VariableSuite_TestSetValueAtDouble( VariableSuiteData* data ) {
+ Index ii;
+ double tmp;
+ int d;
+ Variable* var = Variable_Register_GetByName( data->vr, "velocity" );
+
+ /* Fill the variable Variable with another known pattern of kinda random (bit filling) numbers */
+ for( ii = 0; ii < data->aSize[1]; ii++ ) {
+
+ for( d = 0; d < 3; d++ ) {
+ Variable_SetValueAtDouble( var, ii, d, 1.0 - ( 1.0 / ((data->aSize[1]*3)+2) * (ii*3+d+1) ) );
+ }
+ }
+
+ /* Check that Variable_SetValueDouble on the velocity Variable set the right numbers */
+ for( ii = 0; ii < data->aSize[1]; ii++ ) {
+
+ for( d = 0; d < 3; d++ ) {
+ tmp = 1.0 - ( 1.0 / ((data->aSize[1]*3)+2) * (ii*3+d+1) );
+
+ pcu_check_true( data->velocity[ii][d]-tmp < 1e-12 );
+ }
+ }
+}
+
+
+/* TODO: try out vx, vy, vz, complex tests */
+
+void VariableSuite_TestVariable_Char( VariableSuiteData* data ) {
+ typedef char Triple[3];
+ char* array;
+ Triple* structArray;
+ Index length = 10;
+ /* List of values to test the variable with.
+ * Values to test are hex 5's and a's because they are a series of 0101 and 1010 respectively so they test
+ * each bit in memory to read/set.
+ */
+ long int testValues[] = { 0x55, 0xaa };
+ Index testValueCount = 2;
+ Index test_I;
+ long int testValue;
+ Variable* var;
+ Variable* vec;
+ Variable* vecVar[3];
+ int i, j;
+
+ array = Memory_Alloc_Array( char, length, "test" );
+ structArray = Memory_Alloc_Array( Triple, length, "test" );
+
+ var = Variable_NewScalar( "Char-Scalar", NULL, Variable_DataType_Char, &length, NULL, (void**)&array, data->vr );
+ vec = Variable_NewVector( "Char-Three", NULL, Variable_DataType_Char, 3, &length, NULL, (void**)&structArray, data->vr, "a", "b", "c" );
+
+ vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
+ vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
+ vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
+
+ Variable_Register_BuildAll( data->vr );
+
+ for ( test_I = 0; test_I < testValueCount; ++test_I ) {
+
+ testValue = testValues[test_I];
+
+ for ( i = 0; i < length; ++i ) {
+ Variable_SetValueChar( var, i, testValue );
+ Variable_SetValueAtChar( vec, i, 0, testValue );
+ Variable_SetValueAtChar( vec, i, 1, testValue );
+ Variable_SetValueAtChar( vec, i, 2, testValue );
+ }
+
+ /* ~~~Scalar~~~*/
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueChar( var, i ) == (char)(char)testValue );
+ pcu_check_true( Variable_GetValueCharAsShort( var, i ) == (short)(char)testValue );
+ pcu_check_true( Variable_GetValueCharAsInt( var, i ) == (int)(char)testValue );
+ pcu_check_true( Variable_GetValueCharAsFloat( var, i ) == (float)(char)testValue );
+ pcu_check_true( Variable_GetValueCharAsDouble( var, i ) == (double)(char)testValue );
+ }
+
+ /*~~~Vector~~~*/
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueAtChar( vec, i, 0 ) == (char)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsShort( vec, i, 0 ) == (short)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsInt( vec, i, 0 ) == (int)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsFloat( vec, i, 0 ) == (float)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsDouble( vec, i, 0 ) == (double)(char)testValue );
+
+ pcu_check_true( Variable_GetPtrAtChar( vec, i, 0 ) == &structArray[i][0] );
+
+ pcu_check_true( Variable_GetValueAtChar( vec, i, 1 ) == (char)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsShort( vec, i, 1 ) == (short)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsInt( vec, i, 1 ) == (int)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsFloat( vec, i, 1 ) == (float)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsDouble( vec, i, 1 ) == (double)(char)testValue );
+ pcu_check_true( Variable_GetPtrAtChar( vec, i, 1 ) == &structArray[i][1] );
+
+ pcu_check_true( Variable_GetValueAtChar( vec, i, 2 ) == (char)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsShort( vec, i, 2 ) == (short)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsInt( vec, i, 2 ) == (int)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsFloat( vec, i, 2 ) == (float)(char)testValue );
+ pcu_check_true( Variable_GetValueAtCharAsDouble( vec, i, 2 ) == (double)(char)testValue );
+ pcu_check_true( Variable_GetPtrAtChar( vec, i, 2 ) == &structArray[i][2] );
+ }
+
+ /*~~~Vector: Sub-Variable~~~*/
+ for ( i = 0; i < length; ++i ) {
+ for ( j = 0; j < 3; ++j ) {
+ pcu_check_true( _Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
+ }
+ }
+ }
+}
+
+
+void VariableSuite_TestVariable_Double( VariableSuiteData* data ) {
+ typedef double Triple[3];
+
+ double* array;
+ Triple* structArray;
+ Index length = 10;
+
+ double testValues[] = { 123456789.0, 0.987654321 };
+ Index testValueCount = 2;
+ Index test_I;
+ double testValue;
+
+ Variable* var;
+ Variable* vec;
+ Variable* vecVar[3];
+
+ int i, j;
+
+ array = Memory_Alloc_Array( double, length, "test" );
+ structArray = Memory_Alloc_Array( Triple, length, "test" );
+
+ var = Variable_NewScalar( "Double-Scalar", NULL, Variable_DataType_Double, &length, NULL, (void**)&array, data->vr );
+ vec = Variable_NewVector( "Double-Three", NULL, Variable_DataType_Double, 3, &length, NULL, (void**)&structArray, data->vr, "a", "b", "c" );
+
+ vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
+ vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
+ vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
+
+ Variable_Register_BuildAll( data->vr );
+
+
+ for ( test_I = 0; test_I < testValueCount; ++test_I ) {
+
+ testValue = testValues[test_I];
+
+ for ( i = 0; i < length; ++i ) {
+ Variable_SetValueDouble( var, i, testValue );
+
+ Variable_SetValueAtDouble( vec, i, 0, testValue );
+ Variable_SetValueAtDouble( vec, i, 1, testValue );
+ Variable_SetValueAtDouble( vec, i, 2, testValue );
+ }
+
+ /* "~~~Scalar~~~\n" */
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueDouble( var, i ) == (double)(double)testValue );
+ pcu_check_true( Variable_GetValueDoubleAsChar( var, i ) == (char)(double)testValue );
+ pcu_check_true( Variable_GetValueDoubleAsShort( var, i ) == (short)(double)testValue );
+ pcu_check_true( Variable_GetValueDoubleAsInt( var, i ) == (int)(double)testValue );
+ pcu_check_true( Variable_GetValueDoubleAsFloat( var, i ) == (float)(double)testValue );
+ }
+
+ /*~~~Vector~~~*/
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueAtDouble( vec, i, 0 ) == (double)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsChar( vec, i, 0 ) == (char)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsShort( vec, i, 0 ) == (short)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsInt( vec, i, 0 ) == (int)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsFloat( vec, i, 0 ) == (float)(double)testValue );
+ pcu_check_true( Variable_GetPtrAtDouble( vec, i, 0 ) == &structArray[i][0] );
+
+ pcu_check_true( Variable_GetValueAtDouble( vec, i, 1 ) == (double)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsChar( vec, i, 1 ) == (char)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsShort( vec, i, 1 ) == (short)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsInt( vec, i, 1 ) == (int)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsFloat( vec, i, 1 ) == (float)(double)testValue );
+ pcu_check_true( Variable_GetPtrAtDouble( vec, i, 1 ) == &structArray[i][1] );
+
+ pcu_check_true( Variable_GetValueAtDouble( vec, i, 2 ) == (double)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsChar( vec, i, 2 ) == (char)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsShort( vec, i, 2 ) == (short)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsInt( vec, i, 2 ) == (int)(double)testValue );
+ pcu_check_true( Variable_GetValueAtDoubleAsFloat( vec, i, 2 ) == (float)(double)testValue );
+ pcu_check_true( Variable_GetPtrAtDouble( vec, i, 2 ) == &structArray[i][2] );
+ }
+
+ /*~~~Vector: Sub-Variable~~~*/
+ for ( i = 0; i < length; ++i ) {
+ for ( j = 0; j < 3; ++j ) {
+ pcu_check_true( Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
+ }
+ }
+ }
+}
+
+
+void VariableSuite_TestVariable_Float( VariableSuiteData* data ) {
+ typedef float Triple[3];
+
+ float* array;
+ Triple* structArray;
+ Index length = 10;
+
+ float testValues[] = { 123456789.0, 0.987654321 };
+ Index testValueCount = 2;
+ Index test_I;
+ float testValue;
+
+ Variable* var;
+ Variable* vec;
+ Variable* vecVar[3];
+
+ int i, j;
+
+ array = Memory_Alloc_Array( float, length, "test" );
+ structArray = Memory_Alloc_Array( Triple, length, "test" );
+
+ var = Variable_NewScalar( "Float-Scalar", NULL, Variable_DataType_Float, &length, NULL, (void**)&array, data->vr );
+ vec = Variable_NewVector( "Float-Three", NULL, Variable_DataType_Float, 3, &length, NULL, (void**)&structArray, data->vr, "a", "b", "c" );
+
+ vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
+ vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
+ vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
+
+ Variable_Register_BuildAll( data->vr );
+
+ for ( test_I = 0; test_I < testValueCount; ++test_I ) {
+ testValue = testValues[test_I];
+
+ for ( i = 0; i < length; ++i ) {
+ Variable_SetValueFloat( var, i, testValue );
+
+ Variable_SetValueAtFloat( vec, i, 0, testValue );
+ Variable_SetValueAtFloat( vec, i, 1, testValue );
+ Variable_SetValueAtFloat( vec, i, 2, testValue );
+ }
+
+ /* "~~~Scalar~~~\n" */
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueFloat( var, i ) == (float)(float)testValue );
+ pcu_check_true( Variable_GetValueFloatAsChar( var, i ) == (float)(char)testValue );
+ pcu_check_true( Variable_GetValueFloatAsShort( var, i ) == (float)(short)testValue );
+ pcu_check_true( Variable_GetValueFloatAsInt( var, i ) == (float)(int)testValue );
+ pcu_check_true( Variable_GetValueFloatAsDouble( var, i ) == (double)(float)testValue );
+ }
+
+ /*~~~Vector~~~*/
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueAtFloat( vec, i, 0 ) == (float)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsChar( vec, i, 0 ) == (char)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsShort( vec, i, 0 ) == (short)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsInt( vec, i, 0 ) == (int)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsDouble( vec, i, 0 ) == (double)(float)testValue );
+ pcu_check_true( Variable_GetPtrAtFloat( vec, i, 0 ) == &structArray[i][0] );
+
+ pcu_check_true( Variable_GetValueAtFloat( vec, i, 1 ) == (float)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsChar( vec, i, 1 ) == (char)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsShort( vec, i, 1 ) == (short)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsInt( vec, i, 1 ) == (int)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsDouble( vec, i, 1 ) == (double)(float)testValue );
+ pcu_check_true( Variable_GetPtrAtFloat( vec, i, 1 ) == &structArray[i][1] );
+
+ pcu_check_true( Variable_GetValueAtFloat( vec, i, 2 ) == (float)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsChar( vec, i, 2 ) == (char)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsShort( vec, i, 2 ) == (short)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsInt( vec, i, 2 ) == (int)(float)testValue );
+ pcu_check_true( Variable_GetValueAtFloatAsDouble( vec, i, 2 ) == (double)(float)testValue );
+ pcu_check_true( Variable_GetPtrAtFloat( vec, i, 2 ) == &structArray[i][2] );
+ }
+
+ /*~~~Vector: Sub-Variable~~~*/
+ for ( i = 0; i < length; ++i ) {
+ for ( j = 0; j < 3; ++j ) {
+ pcu_check_true( Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
+ }
+ }
+ }
+}
+
+
+void VariableSuite_TestVariable_Int( VariableSuiteData* data ) {
+ typedef int Triple[3];
+
+ int* array;
+ Triple* structArray;
+ Index length = 10;
+
+ /* List of values to test the variable with.
+ * Values to test are hex 5's and a's because they are a series of 0101 and 1010 respectively so they test
+ * each bit in memory to read/set.
+ */
+ long int testValues[] = { 0x55555555, 0xaaaaaaaa };
+ Index testValueCount = 2;
+ Index test_I;
+ long int testValue;
+
+ Variable* var;
+ Variable* vec;
+ Variable* vecVar[3];
+
+ int i, j;
+
+ array = Memory_Alloc_Array( int, length, "test" );
+ structArray = Memory_Alloc_Array( Triple, length, "test" );
+
+ var = Variable_NewScalar( "Int-Scalar", NULL, Variable_DataType_Int, &length, NULL, (void**)&array, data->vr );
+ vec = Variable_NewVector( "Int-Three", NULL, Variable_DataType_Int, 3, &length, NULL, (void**)&structArray, data->vr, "a", "b", "c" );
+
+ vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
+ vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
+ vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
+
+ Variable_Register_BuildAll( data->vr );
+
+ for ( test_I = 0; test_I < testValueCount; ++test_I ) {
+
+ testValue = testValues[test_I];
+
+ for ( i = 0; i < length; ++i ) {
+ Variable_SetValueInt( var, i, testValue );
+
+ Variable_SetValueAtInt( vec, i, 0, testValue );
+ Variable_SetValueAtInt( vec, i, 1, testValue );
+ Variable_SetValueAtInt( vec, i, 2, testValue );
+ }
+
+ /*~~~Scalar~~~*/
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueInt( var, i ) == (int)(int)testValue );
+ pcu_check_true( Variable_GetValueIntAsChar( var, i ) == (char)(int)testValue );
+ pcu_check_true( Variable_GetValueIntAsShort( var, i ) == (short)(int)testValue );
+ pcu_check_true( fabsf(Variable_GetValueIntAsFloat( var, i ) - (float)(int)testValue) < fabsf(0.00001*testValue) );
+ pcu_check_true( fabs(Variable_GetValueIntAsDouble( var, i ) - (double)(int)testValue) < fabs(0.00001*testValue) );
+ }
+
+ /*~~~Vector~~~*/
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueAtInt( vec, i, 0 ) == (int)(int)testValue );
+ pcu_check_true( Variable_GetValueAtIntAsChar( vec, i, 0 ) == (char)(int)testValue );
+ pcu_check_true( Variable_GetValueAtIntAsShort( vec, i, 0 ) == (short)(int)testValue );
+ pcu_check_true( fabsf(Variable_GetValueAtIntAsFloat( vec, i, 0 ) - (float)(int)testValue) < fabsf(0.00001*testValue) );
+ pcu_check_true( fabs(Variable_GetValueAtIntAsDouble( vec, i, 0 ) - (double)(int)testValue) < fabs(0.00001*testValue));
+ pcu_check_true( Variable_GetPtrAtInt( vec, i, 0 ) == &structArray[i][0] );
+
+ pcu_check_true( Variable_GetValueAtInt( vec, i, 1 ) == (int)(int)testValue );
+ pcu_check_true( Variable_GetValueAtIntAsChar( vec, i, 1 ) == (char)(int)testValue );
+ pcu_check_true( Variable_GetValueAtIntAsShort( vec, i, 1 ) == (short)(int)testValue );
+ pcu_check_true( fabsf(Variable_GetValueAtIntAsFloat( vec, i, 1 ) - (float)(int)testValue) < fabsf(0.00001*testValue) );
+ pcu_check_true( fabs(Variable_GetValueAtIntAsDouble( vec, i, 1 ) - (double)(int)testValue) < fabs(0.00001*testValue));
+ pcu_check_true( Variable_GetPtrAtInt( vec, i, 1 ) == &structArray[i][1] );
+
+ pcu_check_true( Variable_GetValueAtInt( vec, i, 2 ) == (int)(int)testValue );
+ pcu_check_true( Variable_GetValueAtIntAsChar( vec, i, 2 ) == (char)(int)testValue );
+ pcu_check_true( Variable_GetValueAtIntAsShort( vec, i, 2 ) == (short)(int)testValue );
+ pcu_check_true( fabsf(Variable_GetValueAtIntAsFloat( vec, i, 2 ) - (float)(int)testValue) < fabsf(0.00001*testValue));
+ pcu_check_true( fabs(Variable_GetValueAtIntAsDouble( vec, i, 2 ) - (double)(int)testValue) < fabs(0.0001*testValue));
+ pcu_check_true( Variable_GetPtrAtInt( vec, i, 2 ) == &structArray[i][2] );
+ }
+
+ /*~~~Vector: Sub-Variable~~~*/
+ for ( i = 0; i < length; ++i ) {
+ for ( j = 0; j < 3; ++j ) {
+ pcu_check_true( Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
+ }
+ }
+ }
+}
+
+
+void VariableSuite_TestVariable_Short( VariableSuiteData* data ) {
+ typedef short Triple[3];
+
+ short* array;
+ Triple* structArray;
+ Index length = 10;
+
+ /* List of values to test the variable with.
+ * Values to test are hex 5's and a's because they are a series of 0101 and 1010 respectively so they test
+ * each bit in memory to read/set.
+ */
+ long int testValues[] = { 0x5555, 0xaaaa };
+ Index testValueCount = 2;
+ Index test_I;
+ long int testValue;
+
+ Variable* var;
+ Variable* vec;
+ Variable* vecVar[3];
+
+ int i, j;
+
+ array = Memory_Alloc_Array( short, length, "test" );
+ structArray = Memory_Alloc_Array( Triple, length, "test" );
+
+ var = Variable_NewScalar( "Short-Scalar", NULL, Variable_DataType_Short, &length, NULL, (void**)&array, data->vr );
+ vec = Variable_NewVector( "Short-Three", NULL, Variable_DataType_Short, 3, &length, NULL, (void**)&structArray, data->vr, "a", "b", "c" );
+
+ vecVar[0] = Variable_Register_GetByName( data->vr, "a" );
+ vecVar[1] = Variable_Register_GetByName( data->vr, "b" );
+ vecVar[2] = Variable_Register_GetByName( data->vr, "c" );
+
+ Variable_Register_BuildAll( data->vr );
+
+
+ for ( test_I = 0; test_I < testValueCount; ++test_I ) {
+
+ testValue = testValues[test_I];
+
+
+ for ( i = 0; i < length; ++i ) {
+ Variable_SetValueShort( var, i, testValue );
+
+ Variable_SetValueAtShort( vec, i, 0, testValue );
+ Variable_SetValueAtShort( vec, i, 1, testValue );
+ Variable_SetValueAtShort( vec, i, 2, testValue );
+ }
+
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueShort( var, i ) == (short)(short)testValue );
+ pcu_check_true( Variable_GetValueShortAsChar( var, i ) == (char)(short)testValue );
+ pcu_check_true( Variable_GetValueShortAsInt( var, i ) == (int)(short)testValue );
+ pcu_check_true( Variable_GetValueShortAsFloat( var, i ) == (float)(short)testValue );
+ pcu_check_true( Variable_GetValueShortAsDouble( var, i ) == (double)(short)testValue );
+ }
+
+ for ( i = 0; i < length; ++i ) {
+ pcu_check_true( Variable_GetValueAtShort( vec, i, 0 ) == (short)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsChar( vec, i, 0 ) == (char)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsInt( vec, i, 0 ) == (int)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsFloat( vec, i, 0 ) == (float)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsDouble( vec, i, 0 ) == (double)(short)testValue );
+ pcu_check_true( Variable_GetPtrAtShort( vec, i, 0 ) == &structArray[i][0] );
+
+ pcu_check_true( Variable_GetValueAtShort( vec, i, 1 ) == (short)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsChar( vec, i, 1 ) == (char)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsInt( vec, i, 1 ) == (int)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsFloat( vec, i, 1 ) == (float)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsDouble( vec, i, 1 ) == (double)(short)testValue );
+ pcu_check_true( Variable_GetPtrAtShort( vec, i, 1 ) == &structArray[i][1] );
+
+ pcu_check_true( Variable_GetValueAtShort( vec, i, 2 ) == (short)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsChar( vec, i, 2 ) == (char)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsInt( vec, i, 2 ) == (int)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsFloat( vec, i, 2 ) == (float)(short)testValue );
+ pcu_check_true( Variable_GetValueAtShortAsDouble( vec, i, 2 ) == (double)(short)testValue );
+ pcu_check_true( Variable_GetPtrAtShort( vec, i, 2 ) == &structArray[i][2] );
+ }
+
+ for ( i = 0; i < length; ++i ) {
+ for ( j = 0; j < 3; ++j ) {
+ pcu_check_true( Variable_GetStructPtr( vecVar[j], i ) == &structArray[i][j] );
+ }
+ }
+ }
+}
+
+
+/* A few typedefs needed for the next test */
+#define VECTOR_DATA_COUNT 3
+typedef double Triple[VECTOR_DATA_COUNT];
+
+struct ComplexStuff {
+ int x;
+ float y;
+ char z; /* variablise the y and z member */
+};
+typedef struct ComplexStuff ComplexStuff;
+
+struct MockContext {
+ float* scalars;
+ Index scalarCount;
+ Triple* vectors;
+ Index vectorCount;
+ ComplexStuff* stuff;
+ Index stuffCount;
+ SizeT complexStuffSize;
+ Variable_Register* vr;
+};
+typedef struct MockContext MockContext;
+
+void VariableSuite_TestVariableCopy( VariableSuiteData* data ) {
+ MockContext* ctx1 = NULL;
+ MockContext* ctx2 = NULL;
+ Variable* scalar = NULL;
+ Variable* vector = NULL;
+ Variable* complexStuff = NULL;
+ PtrMap* ptrMap = PtrMap_New( 10 );
+ Index ii=0;
+ Index jj=0;
+ Index var_I=0;
+
+
+ ctx1 = Memory_Alloc( MockContext, "ctx1" );
+ ctx2 = Memory_Alloc( MockContext, "ctx2" );
+
+ ctx1->scalarCount = 10;
+ ctx1->vectorCount = 10;
+ ctx1->stuffCount = 10;
+ ctx1->complexStuffSize = sizeof( ComplexStuff );
+
+ ctx1->scalars = Memory_Alloc_Array( float, ctx1->scalarCount, "ctx1->scalars" );
+ ctx1->vectors = Memory_Alloc_Array( Triple, ctx1->vectorCount, "ctx1->vectors" );
+ ctx1->stuff = Memory_Alloc_Array( ComplexStuff, ctx1->stuffCount, "ctx1->stuff" );
+
+ ctx1->vr = Variable_Register_New();
+
+ Variable_NewScalar( "Scalar", NULL, Variable_DataType_Float, &(ctx1->scalarCount), NULL, (void**)&(ctx1->scalars), ctx1->vr );
+ Variable_NewVector( "Vector", NULL, Variable_DataType_Double, VECTOR_DATA_COUNT, &(ctx1->vectorCount), NULL, (void**)&(ctx1->vectors), ctx1->vr, "x", "y", "z" );
+
+ {
+ ComplexStuff tmp;
+ SizeT dataOffsets[] = { 0, 0 };
+ Variable_DataType dataTypes[] = { Variable_DataType_Float, Variable_DataType_Char };
+ Index dataTypeCounts[] = { 1, 1 };
+ Name dataNames[] = { "complexY", "complexZ" };
+
+ dataOffsets[0] = (ArithPointer)&tmp.y - (ArithPointer)&tmp;
+ dataOffsets[1] = (ArithPointer)&tmp.z - (ArithPointer)&tmp;
+
+ Variable_New( "Complex", NULL, 2, dataOffsets, dataTypes, dataTypeCounts, dataNames, &(ctx1->complexStuffSize), &(ctx1->stuffCount), NULL, (void**)&(ctx1->stuff), ctx1->vr );
+ }
+
+ Variable_Register_BuildAll( ctx1->vr );
+
+ scalar = Variable_Register_GetByName( ctx1->vr, "Scalar" );
+ vector = Variable_Register_GetByName( ctx1->vr, "Vector" );
+ complexStuff = Variable_Register_GetByName( ctx1->vr, "Complex" );
+
+ for ( ii = 0; ii < ctx1->scalarCount; ++ii ) {
+ Variable_SetValueFloat( scalar, ii, (float)ii );
+ }
+ for ( ii = 0; ii < ctx1->vectorCount; ++ii ) {
+ Variable_SetValueAtDouble( vector, ii, 0, (double)ii );
+ Variable_SetValueAtDouble( vector, ii, 1, (double)ii );
+ Variable_SetValueAtDouble( vector, ii, 2, (double)ii );
+ }
+ for ( ii = 0; ii < ctx1->stuffCount; ++ii ) {
+ ComplexStuff* stuff = Variable_GetStructPtr( complexStuff, ii );
+ stuff->y = (float)ii;
+ stuff->z = '0' + ii;
+ }
+
+ /* Indicate the area of memory which is given for data so that Variables can attach to it */
+ PtrMap_Append( ptrMap, &(ctx1->scalars), &(ctx2->scalars) );
+ PtrMap_Append( ptrMap, &(ctx1->vectors), &(ctx2->vectors) );
+ PtrMap_Append( ptrMap, &(ctx1->stuff), &(ctx2->stuff) );
+
+ PtrMap_Append( ptrMap, &(ctx1->scalarCount), &(ctx2->scalarCount) );
+ PtrMap_Append( ptrMap, &(ctx1->vectorCount), &(ctx2->vectorCount) );
+ PtrMap_Append( ptrMap, &(ctx1->stuffCount), &(ctx2->stuffCount) );
+ PtrMap_Append( ptrMap, &(ctx1->complexStuffSize), &(ctx2->complexStuffSize) );
+
+ ctx2->scalars = Memory_Alloc_Array( float, ctx1->scalarCount, "scalars" );
+ ctx2->vectors = Memory_Alloc_Array( Triple, ctx1->vectorCount, "vectors" );
+ ctx2->stuff = Memory_Alloc_Array( ComplexStuff, ctx1->stuffCount, "stuff" );
+ PtrMap_Append( ptrMap, ctx1->scalars, ctx2->scalars );
+ PtrMap_Append( ptrMap, ctx1->vectors, ctx2->vectors );
+ PtrMap_Append( ptrMap, ctx1->stuff, ctx2->stuff );
+
+ /* Doing a copy of the whole Variable Register, should trigger a copy of the values in all the variables */
+ ctx2->vr = Stg_Class_Copy( ctx1->vr, NULL, True, NULL, ptrMap );
+
+ /* test equality of copy */
+ for ( ii = 0; ii < ctx1->scalarCount; ++ii ) {
+ pcu_check_true( ctx1->scalars[ii] == ctx2->scalars[ii] );
+ }
+ for ( ii = 0; ii < ctx1->vectorCount; ++ii ) {
+ for ( jj = 0; jj < VECTOR_DATA_COUNT; ++jj ) {
+ pcu_check_true( ctx1->vectors[ii][jj] == ctx2->vectors[ii][jj] );
+ }
+ }
+ for ( ii = 0; ii < ctx1->stuffCount; ++ii ) {
+ pcu_check_true( ctx1->stuff->y == ctx2->stuff->y );
+ pcu_check_true( ctx1->stuff->z == ctx2->stuff->z );
+ }
+
+ /* Clean up */
+ for ( var_I = 0; var_I < ctx1->vr->count; ++var_I ) {
+ Stg_Class_Delete( ctx1->vr->_variable[var_I] );
+ }
+ Memory_Free( ctx1->scalars );
+ Memory_Free( ctx1->vectors );
+ Memory_Free( ctx1->stuff );
+ Stg_Class_Delete( ctx1->vr );
+ Memory_Free( ctx1 );
+ for ( var_I = 0; var_I < ctx2->vr->count; ++var_I ) {
+ Stg_Class_Delete( ctx2->vr->_variable[var_I] );
+ }
+ Memory_Free( ctx2->scalars );
+ Memory_Free( ctx2->vectors );
+ Memory_Free( ctx2->stuff );
+ Stg_Class_Delete( ctx2->vr );
+ Memory_Free( ctx2 );
+}
+
+
+void VariableSuite_TestVariableValueCompare( VariableSuiteData* data ) {
+ Variable* orig;
+ Variable* compare;
+ double* dataArray;
+ double* dataArray2;
+ Index arrayCount = 150;
+ Index componentCount = 4;
+ Index index;
+ double amp = 0.1;
+ double tolerance = 0.04;
+
+ dataArray = Memory_Alloc_Array( double, arrayCount * componentCount, "test" );
+ dataArray2 = Memory_Alloc_Array( double, arrayCount * componentCount, "test" );
+ for( index = 0; index < arrayCount * componentCount; index++ ) {
+ dataArray[index] = 1.0f / (arrayCount+2) * (index+1);
+ dataArray2[ index ] = dataArray[ index ] + amp * cos( index );
+ }
+
+ orig = Variable_NewVector( "orig", NULL, Variable_DataType_Double, componentCount,
+ &arrayCount, NULL, (void**)&dataArray, data->vr, "orig1", "orig2", "orig3", "orig4" );
+ compare = Variable_NewVector( "compare", NULL, Variable_DataType_Double, componentCount,
+ &arrayCount, NULL, (void**)&dataArray2, data->vr, "compare1", "compare2", "compare3", "compare4" );
+
+ Stg_Component_Build( orig, 0, False );
+ Stg_Component_Build( compare, 0, False );
+
+ pcu_check_true( abs( 0.030987 - Variable_ValueCompare( orig, compare ) ) < 0.00001 );
+ pcu_check_true( True == Variable_ValueCompareWithinTolerance( orig, compare, tolerance ) );
+
+ Memory_Free( dataArray );
+ Memory_Free( dataArray2 );
+}
+
+
+void VariableSuite( pcu_suite_t* suite ) {
+ pcu_suite_setData( suite, VariableSuiteData );
+ pcu_suite_setFixtures( suite, VariableSuite_Setup, VariableSuite_Teardown );
+ pcu_suite_addTest( suite, VariableSuite_TestGetValueDouble );
+ pcu_suite_addTest( suite, VariableSuite_TestSetValueDouble );
+ pcu_suite_addTest( suite, VariableSuite_TestGetValueAtDouble );
+ pcu_suite_addTest( suite, VariableSuite_TestSetValueAtDouble );
+ pcu_suite_addTest( suite, VariableSuite_TestVariable_Char );
+ pcu_suite_addTest( suite, VariableSuite_TestVariable_Double );
+ pcu_suite_addTest( suite, VariableSuite_TestVariable_Float );
+ pcu_suite_addTest( suite, VariableSuite_TestVariable_Int );
+ pcu_suite_addTest( suite, VariableSuite_TestVariable_Short );
+ pcu_suite_addTest( suite, VariableSuite_TestVariableCopy );
+ pcu_suite_addTest( suite, VariableSuite_TestVariableValueCompare );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/VariableSuite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/VariableSuite.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,6 @@
+#ifndef StGermain_VariableSuite_h
+#define StGermain_VariableSuite_h
+
+void VariableSuite( pcu_suite_t* suite );
+
+#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/Variable_RegisterSuite.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/Variable_RegisterSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,98 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+**
+** $Id: testJournal-Dictionary.c 2745 2005-03-05 08:12:18Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "pcu/pcu.h"
+#include "StGermain/Base/Foundation/Foundation.h"
+#include "StGermain/Base/IO/IO.h"
+#include "StGermain/Base/Container/Container.h"
+#include "StGermain/Base/Automation/Automation.h"
+#include "StGermain/Base/Extensibility/Extensibility.h"
+#include "StGermain/Base/Context/Context.h"
+#include "Variable_RegisterSuite.h"
+
+typedef struct {
+ Variable_Register* reg;
+} Variable_RegisterSuiteData;
+
+
+void Variable_RegisterSuite_Setup( Variable_RegisterSuiteData* data ) {
+ data->reg = Variable_Register_New();
+}
+
+void Variable_RegisterSuite_Teardown( Variable_RegisterSuiteData* data ) {
+ Stg_Class_Delete( data->reg );
+}
+
+
+void Variable_RegisterSuite_TestAddGet( Variable_RegisterSuiteData* data ) {
+ Variable* var[10];
+ #define ARRAY_SIZE 4
+ #define STRUCT_SIZE 4
+ double array[ARRAY_SIZE];
+ Index arraySize = ARRAY_SIZE;
+ char* name[10] = {"testVar0", "testVar1", "testVar2", "testVar3",
+ "testVar4", "testVar5", "testVar6", "testVar7",
+ "testVar8", "testVar9"};
+ Index i;
+
+ for (i = 0; i < 10; i++) {
+ var[i] = Variable_NewVector( name[i], NULL, Variable_DataType_Double, 4, &arraySize, NULL, (void**)&array, 0 );
+ }
+
+ for (i = 0; i < 10; i++)
+ {
+ Variable_Register_Add(data->reg, var[i]);
+ }
+
+ for (i = 0; i < 10; i++) {
+ pcu_check_true( i == Variable_Register_GetIndex(data->reg, name[i]));
+ }
+
+ for (i = 0; i < 10; i++) {
+ pcu_check_true( var[i] == Variable_Register_GetByName(data->reg, name[i]));
+ }
+
+ for (i = 0; i < 10; i++) {
+ Stg_Class_Delete(var[i]);
+ }
+}
+
+
+void Variable_RegisterSuite( pcu_suite_t* suite ) {
+ pcu_suite_setData( suite, Variable_RegisterSuiteData );
+ pcu_suite_setFixtures( suite, Variable_RegisterSuite_Setup, Variable_RegisterSuite_Teardown );
+ pcu_suite_addTest( suite, Variable_RegisterSuite_TestAddGet );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/Variable_RegisterSuite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/Variable_RegisterSuite.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,6 @@
+#ifndef StGermain_Variable_RegisterSuite_h
+#define StGermain_Variable_RegisterSuite_h
+
+void Variable_RegisterSuite( pcu_suite_t* suite );
+
+#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/input/ComponentVCMetaDict.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/input/ComponentVCMetaDict.xml Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,121 @@
+<?xml version="1.0"?>
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+ <element type="param" name="xml"><?xml version="1.0" ?>
+<meta xmlns="urn:stgermainmeta-schema" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://purl.org/dc/elements/1.1/ dc.xsd http://www.w3.org/2001/XMLSchema XMLSchema.xsd urn:stgermainmeta-schema stgermainmeta.xsd">
+ <info>
+ <dc:title>
+ CompositeVC
+ </dc:title>
+ <dc:creator>
+ VPAC
+ </dc:creator>
+ <dc:publisher>
+ VPAC
+ </dc:publisher>
+ <dc:rights>
+ The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+ </dc:rights>
+ <dc:source>
+ ./StGermain/Base/Automation/src/
+ </dc:source>
+ <dc:subject>
+ StGermain
+ </dc:subject>
+ <dc:description>
+<![CDATA[
+ CompositeVC is used as a container to combine multiple variable conditions.
+]]> </dc:description>
+ </info>
+ <code>
+ <xsd:annotation>
+ <xsd:documentation/>
+ <xsd:appinfo>
+<![CDATA[
+ Refer to ./StgFEM/Apps/StokesMomentumUzawa/lidDrivenBCs.xml
+]]> </xsd:appinfo>
+ </xsd:annotation>
+ <inherits>
+ VariableCondition
+ </inherits>
+ </code>
+ <implements>
+ <reference/>
+ <equation/>
+ </implements>
+ <parameters>
+ <xsd:element default="self-&gt;name" name="vcName" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+<![CDATA[
+ Deprecated; should not be used.
+ ]]> </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element default="" name="vcList" type="stg:list">
+ <xsd:annotation>
+ <xsd:documentation>
+<![CDATA[
+ A list of other VariableCondition definitions.
+ ]]> </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ </parameters>
+ <associations>
+ <xsd:element name="Data" nillable="true" type="Stg_Component">
+ <xsd:annotation>
+ <xsd:documentation>
+<![CDATA[
+ User defined data in the form of a Stg_Component.
+ ]]> </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ </associations>
+</meta>
+</element>
+ <element type="struct" name="info">
+ <element type="param" name="title">CompositeVC</element>
+ <element type="param" name="creator">VPAC</element>
+ <element type="param" name="publisher">VPAC</element>
+ <element type="param" name="rights">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</element>
+ <element type="param" name="source">./StGermain/Base/Automation/src/</element>
+ <element type="param" name="subject">StGermain</element>
+ <element type="param" name="description">
+ CompositeVC is used as a container to combine multiple variable conditions.
+</element>
+ </element>
+ <element type="struct" name="code">
+ <element type="param" name="example-code">
+ Refer to ./StgFEM/Apps/StokesMomentumUzawa/lidDrivenBCs.xml
+</element>
+ <element type="param" name="inherits">VariableCondition</element>
+ </element>
+ <element type="struct" name="implements"/>
+ <element type="struct" name="parameters">
+ <element type="struct" name="vcName">
+ <element type="param" name="name">vcName</element>
+ <element type="param" name="type">xsd:string</element>
+ <element type="param" name="default">self->name</element>
+ <element type="param" name="documentation">
+ Deprecated; should not be used.
+ </element>
+ </element>
+ <element type="struct" name="vcList">
+ <element type="param" name="name">vcList</element>
+ <element type="param" name="type">stg:list</element>
+ <element type="param" name="default"></element>
+ <element type="param" name="documentation">
+ A list of other VariableCondition definitions.
+ </element>
+ </element>
+ </element>
+ <element type="struct" name="associations">
+ <element type="struct" name="Data">
+ <element type="param" name="name">Data</element>
+ <element type="param" name="type">Stg_Component</element>
+ <element type="param" name="nillable">true</element>
+ <element type="param" name="documentation">
+ User defined data in the form of a Stg_Component.
+ </element>
+ </element>
+ </element>
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/input/metatest.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/input/metatest.xml Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+ <struct name="components">
+ <struct name="vc">
+ <param name="Type">CompositeVC</param>
+ </struct>
+ </struct>
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Context/tests/input/setVC.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Context/tests/input/setVC.xml Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<!-- A StGermain input file -->
+<!-- DTD to validate against -->
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+ <struct name="setVC">
+ <param name="type">SetVC</param>
+ <param name="indexCount">64</param>
+ <list name="indices">
+ <param>0</param>
+ <param>2</param>
+ <param>4</param>
+ <param>6</param>
+ <param>8</param>
+ <param>10</param>
+ <param>12</param>
+ <param>14</param>
+ <param>16</param>
+ <param>18</param>
+ <param>20</param>
+ <param>22</param>
+ <param>24</param>
+ <param>26</param>
+ </list>
+ <list name="variables">
+ <struct>
+ <param name="name">vx</param>
+ <param name="type">double</param>
+ <param name="value" type="double">2</param>
+ </struct>
+ <struct>
+ <param name="name">vy</param>
+ <param name="type">func</param>
+ <param name="value">quadratic</param>
+ </struct>
+ <struct>
+ <param name="name">vz</param>
+ <param name="type">double</param>
+ <param name="value" type="double">1</param>
+ </struct>
+ <struct>
+ <param name="name">temp</param>
+ <param name="type">array</param>
+ <list name="value">
+ <param type="double">5</param>
+ <param type="double">6</param>
+ <param type="double">7</param>
+ <param type="double">8</param>
+ <param type="double">9</param>
+ </list>
+ </struct>
+ </list>
+ </struct>
+
+</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/distributedtests/MockContext.c
--- a/Base/Extensibility/distributedtests/MockContext.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/distributedtests/MockContext.c Tue Jan 12 14:38:16 2010 +1100
@@ -45,7 +45,7 @@ void* _MockContext_DefaultNew( Name name
void* _MockContext_DefaultNew( Name name ) {
return NULL;
}
-void _MockContext_Construct( void* c, Stg_ComponentFactory* cf, void* data ) {
+void _MockContext_AssignFromXML( void* c, Stg_ComponentFactory* cf, void* data ) {
}
void _MockContext_Build( void* c, void* data ) {
@@ -62,22 +62,24 @@ void _MockContext_Destroy( void* c, void
}
MockContext* MockContext_New( Dictionary* dictionary ) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( MockContext );
+ Type type = "MockContext";
+ Stg_Class_DeleteFunction* _delete = _MockContext_Delete;
+ Stg_Class_PrintFunction* _print = NULL;
+ Stg_Class_CopyFunction* _copy = NULL;
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor = _MockContext_DefaultNew;
+ Stg_Component_ConstructFunction* _construct = _MockContext_AssignFromXML;
+ Stg_Component_BuildFunction* _build = _MockContext_Build;
+ Stg_Component_InitialiseFunction* _initialise = _MockContext_Initialise;
+ Stg_Component_ExecuteFunction* _execute = _MockContext_Execute;
+ Stg_Component_DestroyFunction* _destroy = _MockContext_Destroy;
+ Name name = "context";
+ AllocationType nameAllocationType = NON_GLOBAL;
+
MockContext* self;
- self = (MockContext*) _Stg_Component_New(
- sizeof( MockContext ),
- "MockContext",
- _MockContext_Delete,
- NULL,
- NULL,
- _MockContext_DefaultNew,
- _MockContext_Construct,
- _MockContext_Build,
- _MockContext_Initialise,
- _MockContext_Execute,
- _MockContext_Destroy,
- "context",
- NON_GLOBAL );
+ self = (MockContext*) _Stg_Component_New( STG_COMPONENT_PASSARGS );
self->plugins = PluginsManager_New();
ModulesManager_AddDirectory( "StGermain", LIB_DIR );
@@ -96,3 +98,5 @@ void _MockContext_Delete( void* context
_Stg_Class_Delete( self );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/distributedtests/testDistributedPlugin.c
--- a/Base/Extensibility/distributedtests/testDistributedPlugin.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/distributedtests/testDistributedPlugin.c Tue Jan 12 14:38:16 2010 +1100
@@ -109,3 +109,5 @@ int main( int argc, char* argv[] ) {
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/distributedtests/testPlugin.c
--- a/Base/Extensibility/distributedtests/testPlugin.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/distributedtests/testPlugin.c Tue Jan 12 14:38:16 2010 +1100
@@ -91,3 +91,5 @@ int main( int argc, char* argv[] ) {
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/distributedtests/testplugins/LocalPlugin/LocalPlugin.c
--- a/Base/Extensibility/distributedtests/testplugins/LocalPlugin/LocalPlugin.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/distributedtests/testplugins/LocalPlugin/LocalPlugin.c Tue Jan 12 14:38:16 2010 +1100
@@ -49,7 +49,7 @@ void LocalPlugin_Function( void* context
/* Plugins are components, so they need a Construct() function. This is where you add the entry points and extensions */
-void _LocalPlugin_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
+void _LocalPlugin_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) {
MockContext* context = (MockContext*)Stg_ComponentFactory_ConstructByName(cf, "context", Stg_Component, True, data );
EP_Append( context->ep, LocalPlugin_Function );
@@ -60,7 +60,7 @@ void* _LocalPlugin_DefaultNew( Name name
return Codelet_New(
LocalPlugin_Type,
_LocalPlugin_DefaultNew,
- _LocalPlugin_Construct,
+ _LocalPlugin_AssignFromXML,
_Codelet_Build,
_Codelet_Initialise,
_Codelet_Execute,
@@ -74,3 +74,5 @@ Index LocalPlugin_Register( PluginsManag
return ModulesManager_Submit( pluginsManager, LocalPlugin_Type, "0", _LocalPlugin_DefaultNew );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/distributedtests/testplugins/LocalPluginDep/LocalPlugin1.c
--- a/Base/Extensibility/distributedtests/testplugins/LocalPluginDep/LocalPlugin1.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/distributedtests/testplugins/LocalPluginDep/LocalPlugin1.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,7 +51,7 @@ void LocalPlugin1_Function( void* contex
printf( "LocalPlugin2 value: %d\n", *ext2 );
}
-void _LocalPlugin1_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
+void _LocalPlugin1_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) {
MockContext* context = (MockContext*)Stg_ComponentFactory_ConstructByName(cf, "context", Stg_Component, True, data );
EP_Append( context->ep, LocalPlugin1_Function );
@@ -61,7 +61,7 @@ void* _LocalPlugin1_DefaultNew( Name nam
return Codelet_New(
LocalPlugin1_Type,
_LocalPlugin1_DefaultNew,
- _LocalPlugin1_Construct,
+ _LocalPlugin1_AssignFromXML,
_Codelet_Build,
_Codelet_Initialise,
_Codelet_Execute,
@@ -73,3 +73,5 @@ Index LocalPlugin1_Register( PluginsMana
return ModulesManager_Submit( pluginsManager, LocalPlugin1_Type, "0", _LocalPlugin1_DefaultNew );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/distributedtests/testplugins/LocalPluginDep/LocalPlugin2.c
--- a/Base/Extensibility/distributedtests/testplugins/LocalPluginDep/LocalPlugin2.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/distributedtests/testplugins/LocalPluginDep/LocalPlugin2.c Tue Jan 12 14:38:16 2010 +1100
@@ -42,7 +42,7 @@ void LocalPlugin2_Function() {
printf( "%s\n", __func__ );
}
-void _LocalPlugin2_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
+void _LocalPlugin2_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) {
MockContext* context = (MockContext*)Stg_ComponentFactory_ConstructByName(cf, "context", Stg_Component, True, data );
int* ext;
@@ -61,7 +61,7 @@ void* _LocalPlugin2_DefaultNew( Name nam
return Codelet_New(
LocalPlugin2_Type,
_LocalPlugin2_DefaultNew,
- _LocalPlugin2_Construct,
+ _LocalPlugin2_AssignFromXML,
_Codelet_Build,
_Codelet_Initialise,
_Codelet_Execute,
@@ -72,3 +72,5 @@ Index LocalPlugin2_Register( PluginsMana
Index LocalPlugin2_Register( PluginsManager* pluginsManager ) {
return ModulesManager_Submit( pluginsManager, LocalPlugin2_Type, "0", _LocalPlugin2_DefaultNew );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/distributedtests/testplugins/RemotePlugin1.c
--- a/Base/Extensibility/distributedtests/testplugins/RemotePlugin1.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/distributedtests/testplugins/RemotePlugin1.c Tue Jan 12 14:38:16 2010 +1100
@@ -44,3 +44,5 @@ void RemotePlugin1_Register( void* entry
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ClassHook.c
--- a/Base/Extensibility/src/ClassHook.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ClassHook.c Tue Jan 12 14:38:16 2010 +1100
@@ -50,16 +50,17 @@ const Type ClassHook_Type = "ClassHook";
/** allocate and initialise a new ClassHook. */
ClassHook* ClassHook_New( Name name, Func_Ptr funcPtr, char* addedBy, void* reference ) {
- return _ClassHook_New(
- sizeof(ClassHook),
- ClassHook_Type,
- _ClassHook_Delete,
- _ClassHook_Print,
- _ClassHook_Copy,
- name,
- funcPtr,
- addedBy,
- reference );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ClassHook);
+ Type type = ClassHook_Type;
+ Stg_Class_DeleteFunction* _delete = _ClassHook_Delete;
+ Stg_Class_PrintFunction* _print = _ClassHook_Print;
+ Stg_Class_CopyFunction* _copy = _ClassHook_Copy;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _ClassHook_New( CLASSHOOK_PASSARGS );
}
void ClassHook_Init( void* hook, Name name, Func_Ptr funcPtr, char* addedBy, void* reference ) {
@@ -81,22 +82,18 @@ void ClassHook_Init( void* hook, Name na
}
-ClassHook* _ClassHook_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Func_Ptr funcPtr,
- char* addedBy,
- void* reference )
+ClassHook* _ClassHook_New( CLASSHOOK_DEFARGS )
{
ClassHook* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(ClassHook) );
- self = (ClassHook*)_Stg_Object_New( _sizeOfSelf, type, _delete, _print, _copy, name, NON_GLOBAL );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = NON_GLOBAL;
+
+ self = (ClassHook*)_Stg_Object_New( STG_OBJECT_PASSARGS );
/* General info */
@@ -153,3 +150,5 @@ void* _ClassHook_Copy( void* hook, void*
return (void*)newClassHook;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ClassHook.h
--- a/Base/Extensibility/src/ClassHook.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ClassHook.h Tue Jan 12 14:38:16 2010 +1100
@@ -36,8 +36,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_ClassHook_h__
-#define __Base_Extensibility_ClassHook_h__
+#ifndef __StGermain_Base_Extensibility_ClassHook_h__
+#define __StGermain_Base_Extensibility_ClassHook_h__
/** Textual name of this class */
@@ -58,16 +58,24 @@
void ClassHook_Init( void* hook, Name name, Func_Ptr funcPtr, char* addedBy, void* reference );
/* Creation implementation */
- ClassHook* _ClassHook_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Func_Ptr funcPtr,
- char* addedBy,
- void* reference );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define CLASSHOOK_DEFARGS \
+ STG_OBJECT_DEFARGS, \
+ Func_Ptr funcPtr, \
+ char* addedBy, \
+ void* reference
+
+ #define CLASSHOOK_PASSARGS \
+ STG_OBJECT_PASSARGS, \
+ funcPtr, \
+ addedBy, \
+ reference
+
+ ClassHook* _ClassHook_New( CLASSHOOK_DEFARGS );
/* Initialisation implementation */
void _ClassHook_Init( ClassHook* self, Func_Ptr funcPtr, char* addedBy, void* reference );
@@ -87,4 +95,5 @@
void* _ClassHook_Copy( void* hook, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
-#endif /* __Base_Extensibility_ClassHook_h__ */
+#endif /* __StGermain_Base_Extensibility_ClassHook_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ClassPtrExtensionInfo.c
--- a/Base/Extensibility/src/ClassPtrExtensionInfo.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ClassPtrExtensionInfo.c Tue Jan 12 14:38:16 2010 +1100
@@ -55,16 +55,19 @@ const Type ClassPtrExtensionInfo_Type =
/** allocate and initialise a new ClassPtrExtensionInfo. */
ClassPtrExtensionInfo* ClassPtrExtensionInfo_New( const Name name, Stg_Class_CopyFunction* copyFunc, Index count ) {
- return _ClassPtrExtensionInfo_New(
- sizeof(ClassPtrExtensionInfo),
- ClassPtrExtensionInfo_Type,
- _ClassPtrExtensionInfo_Delete,
- _ClassPtrExtensionInfo_Print,
- _ClassPtrExtensionInfo_Copy,
- _ClassPtrExtensionInfo_DataCopy,
- (Name)name,
- copyFunc,
- count );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ClassPtrExtensionInfo);
+ Type type = ClassPtrExtensionInfo_Type;
+ Stg_Class_DeleteFunction* _delete = _ClassPtrExtensionInfo_Delete;
+ Stg_Class_PrintFunction* _print = _ClassPtrExtensionInfo_Print;
+ Stg_Class_CopyFunction* _copy = _ClassPtrExtensionInfo_Copy;
+ ExtensionInfo_DataCopyFunction* _dataCopy = _ClassPtrExtensionInfo_DataCopy;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+ SizeT size = ZERO;
+
+ return _ClassPtrExtensionInfo_New( CLASSPTREXTENSIONINFO_PASSARGS );
}
@@ -87,31 +90,18 @@ void ClassPtrExtensionInfo_Init( void* a
}
-ClassPtrExtensionInfo* _ClassPtrExtensionInfo_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ExtensionInfo_DataCopyFunction* _dataCopy,
- Name name,
- Stg_Class_CopyFunction* copyFunc,
- Index count )
+ClassPtrExtensionInfo* _ClassPtrExtensionInfo_New( CLASSPTREXTENSIONINFO_DEFARGS )
{
ClassPtrExtensionInfo* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(ClassPtrExtensionInfo) );
- self = (ClassPtrExtensionInfo*)_ExtensionInfo_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _dataCopy,
- name,
- sizeof(ClassPtrExtensionInfo_PtrClass),
- count );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ size = sizeof(ClassPtrExtensionInfo_PtrClass);
+
+ self = (ClassPtrExtensionInfo*)_ExtensionInfo_New( EXTENSIONINFO_PASSARGS );
/* General info */
@@ -193,3 +183,5 @@ void* _ClassPtrExtensionInfo_DataCopy(
/* Public member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ClassPtrExtensionInfo.h
--- a/Base/Extensibility/src/ClassPtrExtensionInfo.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ClassPtrExtensionInfo.h Tue Jan 12 14:38:16 2010 +1100
@@ -47,8 +47,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_ClassPtrExtensionInfo_h__
-#define __Base_Extensibility_ClassPtrExtensionInfo_h__
+#ifndef __StGermain_Base_Extensibility_ClassPtrExtensionInfo_h__
+#define __StGermain_Base_Extensibility_ClassPtrExtensionInfo_h__
/** Textual name of this class */
extern const Type ClassPtrExtensionInfo_Type;
@@ -76,16 +76,20 @@
void ClassPtrExtensionInfo_Init( void* arrayExtensionInfo, const Name name, Stg_Class_CopyFunction* copyFunc, Index count );
/* Creation implementation */
- ClassPtrExtensionInfo* _ClassPtrExtensionInfo_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ExtensionInfo_DataCopyFunction* _dataCopy,
- Name name,
- Stg_Class_CopyFunction* copyFunc,
- Index count );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define CLASSPTREXTENSIONINFO_DEFARGS \
+ EXTENSIONINFO_DEFARGS, \
+ Stg_Class_CopyFunction* copyFunc
+
+ #define CLASSPTREXTENSIONINFO_PASSARGS \
+ EXTENSIONINFO_PASSARGS, \
+ copyFunc
+
+ ClassPtrExtensionInfo* _ClassPtrExtensionInfo_New( CLASSPTREXTENSIONINFO_DEFARGS );
/* Initialisation implementation */
void _ClassPtrExtensionInfo_Init( ClassPtrExtensionInfo* self, Name name, Stg_Class_CopyFunction* copyFunc, Index count );
@@ -110,4 +114,5 @@
/* Public member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#endif /* __Base_Extensibility_ClassPtrExtensionInfo_h__ */
+#endif /* __StGermain_Base_Extensibility_ClassPtrExtensionInfo_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Codelet.c
--- a/Base/Extensibility/src/Codelet.c Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Comments:
-**
-** $Id: Codelet.c 3192 2005-08-25 01:45:42Z AlanLo $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdarg.h>
-#include "Base/Foundation/Foundation.h"
-#include "Base/IO/IO.h"
-#include "Base/Container/Container.h"
-#include "Base/Automation/Automation.h"
-
-#include "types.h"
-#include "shortcuts.h"
-#include "Codelet.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h>
-
-const Type Codelet_Type = "Codelet";
-
-void* Codelet_New(
- Type type,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name )
-{
- return _Codelet_New(
- sizeof( Codelet ),
- type,
- _Codelet_Delete,
- _Codelet_Print,
- _Codelet_Copy,
- _defaultConstructor,
- _construct,
- _build,
- _initialise,
- _execute,
- _destroy,
- name );
-}
-
-void* _Codelet_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name )
-{
- return _Stg_Component_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _defaultConstructor,
- _construct,
- _build,
- _initialise,
- _execute,
- _destroy,
- name,
- NON_GLOBAL );
-}
-
-void _Codelet_Delete( void* codelet ) {
- _Stg_Component_Delete( codelet );
-}
-void _Codelet_Print( void* codelet, Stream* stream ) {
- Codelet* self = (Codelet*)codelet;
-
- Journal_Printf( stream, "Codelet: %s, Type %s\n", self->name, self->type );
- _Stg_Component_Print( self, stream );
-}
-void* _Codelet_Copy( void* codelet, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap ) {
- return _Stg_Component_Copy( codelet, dest, deep, nameExt, ptrMap );
-}
-
-
-void _Codelet_Build( void* codelet, void* data ) {
-
-}
-void _Codelet_Initialise( void* codelet, void* data ) {
-
-}
-void _Codelet_Execute( void* codelet, void* data ) {
-
-}
-void _Codelet_Destroy( void* codelet, void* data ) {
-
-}
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Codelet.h
--- a/Base/Extensibility/src/Codelet.h Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Comments:
-**
-** $Id: Codelet.h 3192 2005-08-25 01:45:42Z AlanLo $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Base_Extensibility_Codelet_h__
-#define __Base_Extensibility_Codelet_h__
-
- /* Textual name of this class */
- extern const Type Codelet_Type;
-
- /* Codelets info */
- #define __Codelet \
- __Stg_Component
-
- struct Codelet { __Codelet };
-
-
- void* Codelet_New(
- Type type,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name );
-
- void* _Codelet_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name );
-
- void _Codelet_Delete( void* codelet );
- void _Codelet_Print( void* codelet, Stream* stream );
- void* _Codelet_Copy( void* codelet, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
-
- void _Codelet_Build( void* codelet, void* data );
- void _Codelet_Initialise( void* codelet, void* data );
- void _Codelet_Execute( void* codelet, void* data );
- void _Codelet_Destroy( void* codelet, void* data );
-
-#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Codelet.meta
--- a/Base/Extensibility/src/Codelet.meta Wed Jan 06 13:09:34 2010 +1100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
-<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
-
-<param name="Name">Codelet</param>
-<param name="Author">Steve Quenette</param>
-<param name="Organisation">VPAC</param>
-<param name="Project">StGermain</param>
-<param name="Location">./StGermain/Base/Extensibility/src/</param>
-<param name="Project Web">http://www.stgermainproject.org/</param>
-<param name="Copyright">StGermain Framework. Copyright (C) 2003-2005 VPAC.</param>
-<param name="License">The Gnu Lesser General Public License v2.1 - http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</param>
-<param name="Parent">Stg_Component</param>
-<param name="Reference"></param>
-<param name="Summary">Codelets are components that are used to encapsulate the concerns of a plugin into one object.</param>
-<param name="Description">
-<p>Codelets are essentially nothing more than Components that are used for encapsulating the concerns/features of a plugin into one object. The plugin registration process expects Codelet to be submitted for addition to the component factory. Codelets are assumed to be instantiated only one (i.e. are singletons) by the system.</p>
-
-<p>A Codelet is an abstract class that is used in the C API and not directly in the XML model description files</p>
-</param>
-
-
-<list name="Params">
- <!-- None -->
-</list>
-
-
-<list name="Dependencies">
- <!-- None -->
-</list>
-
-
-<param name="Example">n/a</param>
-
-</StGermainData>
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/EntryPoint.c
--- a/Base/Extensibility/src/EntryPoint.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/EntryPoint.c Tue Jan 12 14:38:16 2010 +1100
@@ -62,8 +62,18 @@ static const Type _EntryPoint_Run_Type =
* \param name textual name of the entry point (useful if its to be stored in a list).
* \return the allocated entry point. */
EntryPoint* EntryPoint_New( const Name name, unsigned int castType ) {
- return _EntryPoint_New( sizeof(EntryPoint), EntryPoint_Type, _EntryPoint_Delete, _EntryPoint_Print, _EntryPoint_Copy, _EntryPoint_GetRun,
- name, castType );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(EntryPoint);
+ Type type = EntryPoint_Type;
+ Stg_Class_DeleteFunction* _delete = _EntryPoint_Delete;
+ Stg_Class_PrintFunction* _print = _EntryPoint_Print;
+ Stg_Class_CopyFunction* _copy = _EntryPoint_Copy;
+ EntryPoint_GetRunFunction* _getRun = _EntryPoint_GetRun;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _EntryPoint_New( ENTRYPOINT_PASSARGS );
}
/** Initialise an existing entry point. See EntryPoint_New() for argument descriptions. */
@@ -87,21 +97,18 @@ void EntryPoint_Init( void* entryPoint,
_EntryPoint_Init( self, castType );
}
-EntryPoint* _EntryPoint_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- EntryPoint_GetRunFunction* _getRun,
- const Name name,
- unsigned int castType )
+EntryPoint* _EntryPoint_New( ENTRYPOINT_DEFARGS )
{
EntryPoint* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(EntryPoint) );
- self = (EntryPoint*)_Stg_Object_New( _sizeOfSelf, type, _delete, _print, _copy, name, GLOBAL );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = GLOBAL;
+
+ self = (EntryPoint*)_Stg_Object_New( STG_OBJECT_PASSARGS );
/* General info */
@@ -914,3 +921,5 @@ void EntryPoint_ErrorIfNoHooks( void* en
epName, parentFunction, epName );
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/EntryPoint.h
--- a/Base/Extensibility/src/EntryPoint.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/EntryPoint.h Tue Jan 12 14:38:16 2010 +1100
@@ -58,8 +58,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_EntryPoint_h__
-#define __Base_Extensibility_EntryPoint_h__
+#ifndef __StGermain_Base_Extensibility_EntryPoint_h__
+#define __StGermain_Base_Extensibility_EntryPoint_h__
/* Templates of virtual functions */
@@ -126,15 +126,22 @@
void EntryPoint_Init( void* entryPoint, const Name name, unsigned int castType );
/** Creation implementation */
- EntryPoint* _EntryPoint_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- EntryPoint_GetRunFunction* _getRun,
- Name name,
- unsigned int castType );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define ENTRYPOINT_DEFARGS \
+ STG_OBJECT_DEFARGS, \
+ EntryPoint_GetRunFunction* _getRun, \
+ unsigned int castType
+
+ #define ENTRYPOINT_PASSARGS \
+ STG_OBJECT_PASSARGS, \
+ _getRun, \
+ castType
+
+ EntryPoint* _EntryPoint_New( ENTRYPOINT_DEFARGS );
/** Member Initialisation implementation */
void _EntryPoint_Init( EntryPoint* self, unsigned int castType );
@@ -302,4 +309,5 @@
void EntryPoint_ErrorIfNoHooks( void* entryPoint, const char* parentFunction );
-#endif /* __Base_Extensibility_EntryPoint_h__ */
+#endif /* __StGermain_Base_Extensibility_EntryPoint_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/EntryPoint_Register.c
--- a/Base/Extensibility/src/EntryPoint_Register.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/EntryPoint_Register.c Tue Jan 12 14:38:16 2010 +1100
@@ -49,7 +49,14 @@ const Type EntryPoint_Register_Type = "E
EntryPoint_Register* EntryPoint_Register_New( void ) {
- return _EntryPoint_Register_New( sizeof(EntryPoint_Register), EntryPoint_Register_Type, _EntryPoint_Register_Delete, _EntryPoint_Register_Print, NULL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(EntryPoint_Register);
+ Type type = EntryPoint_Register_Type;
+ Stg_Class_DeleteFunction* _delete = _EntryPoint_Register_Delete;
+ Stg_Class_PrintFunction* _print = _EntryPoint_Register_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ return _EntryPoint_Register_New( ENTRYPOINT_REGISTER_PASSARGS );
}
void EntryPoint_Register_Init( void* entryPoint_Register ) {
@@ -70,18 +77,13 @@ void EntryPoint_Register_Init( void* ent
_EntryPoint_Register_Init( self );
}
-EntryPoint_Register* _EntryPoint_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
+EntryPoint_Register* _EntryPoint_Register_New( ENTRYPOINT_REGISTER_DEFARGS )
{
EntryPoint_Register* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(EntryPoint_Register) );
- self = (EntryPoint_Register*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (EntryPoint_Register*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -209,3 +211,5 @@ EntryPoint_Index EntryPoint_Register_Fin
return (EntryPoint_Index)-1;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/EntryPoint_Register.h
--- a/Base/Extensibility/src/EntryPoint_Register.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/EntryPoint_Register.h Tue Jan 12 14:38:16 2010 +1100
@@ -37,8 +37,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_EntryPoint_Register_h__
-#define __Base_Extensibility_EntryPoint_Register_h__
+#ifndef __StGermain_Base_Extensibility_EntryPoint_Register_h__
+#define __StGermain_Base_Extensibility_EntryPoint_Register_h__
/* Textual name of this class */
@@ -66,12 +66,18 @@
void EntryPoint_Register_Init( void* entryPoint_Register );
/* Creation implementation / Virtual constructor */
- EntryPoint_Register* _EntryPoint_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define ENTRYPOINT_REGISTER_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define ENTRYPOINT_REGISTER_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ EntryPoint_Register* _EntryPoint_Register_New( ENTRYPOINT_REGISTER_DEFARGS );
/* Initialisation implementation */
void _EntryPoint_Register_Init( void* entryPoint_Register );
@@ -97,4 +103,5 @@
/* If 'entryPoint' is in the register, return its index */
EntryPoint_Index EntryPoint_Register_Find( void* entryPoint_Register, void* entryPoint );
-#endif /* __Base_Extensibility_EntryPoint_Register_h__ */
+#endif /* __StGermain_Base_Extensibility_EntryPoint_Register_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Extensibility.h
--- a/Base/Extensibility/src/Extensibility.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Extensibility.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_h__
-#define __Base_Extensibility_h__
+#ifndef __StGermain_Base_Extensibility_h__
+#define __StGermain_Base_Extensibility_h__
#include "types.h"
#include "shortcuts.h"
@@ -51,7 +51,6 @@
#include "ClassHook.h"
#include "EntryPoint.h"
#include "EntryPoint_Register.h"
- #include "Codelet.h"
#include "Module.h"
#include "Plugin.h"
#include "ModulesManager.h"
@@ -60,5 +59,5 @@
#include "Init.h"
#include "Finalise.h"
-#endif /* __Base_Extensibility_h__ */
+#endif /* __StGermain_Base_Extensibility_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ExtensionInfo.c
--- a/Base/Extensibility/src/ExtensionInfo.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ExtensionInfo.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,22 +51,18 @@
/* Textual name of this class */
const Type ExtensionInfo_Type = "ExtensionInfo";
-ExtensionInfo* _ExtensionInfo_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ExtensionInfo_DataCopyFunction* _dataCopy,
- Name name,
- SizeT size,
- Index count )
+ExtensionInfo* _ExtensionInfo_New( EXTENSIONINFO_DEFARGS )
{
ExtensionInfo* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(ExtensionInfo) );
- self = (ExtensionInfo*)_Stg_Object_New( _sizeOfSelf, type, _delete, _print, _copy, name, NON_GLOBAL );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = NON_GLOBAL;
+
+ self = (ExtensionInfo*)_Stg_Object_New( STG_OBJECT_PASSARGS );
/* General info */
@@ -286,3 +282,5 @@ void ExtensionInfo_Register(
/* To consider... is there a way of checking that the handle is a sane value? SQ20050505 */
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ExtensionInfo.h
--- a/Base/Extensibility/src/ExtensionInfo.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ExtensionInfo.h Tue Jan 12 14:38:16 2010 +1100
@@ -54,8 +54,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_ExtensionInfo_h__
-#define __Base_Extensibility_ExtensionInfo_h__
+#ifndef __StGermain_Base_Extensibility_ExtensionInfo_h__
+#define __StGermain_Base_Extensibility_ExtensionInfo_h__
/** Textual name of this class */
extern const Type ExtensionInfo_Type;
@@ -91,16 +91,24 @@
/* Creation implementation */
- ExtensionInfo* _ExtensionInfo_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete, /**< Derivatives: implement how to delete the extension */
- Stg_Class_PrintFunction* _print, /**< Derivatives: implement how to print the extension */
- Stg_Class_CopyFunction* _copy, /**< Derivatives: implement how to copy the extension */
- ExtensionInfo_DataCopyFunction* _dataCopy, /**< Derivatives: implement how to copy the extension data */
- Name name,
- SizeT size,
- Index count );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define EXTENSIONINFO_DEFARGS \
+ STG_OBJECT_DEFARGS, \
+ ExtensionInfo_DataCopyFunction* _dataCopy, \
+ SizeT size, \
+ Index count
+
+ #define EXTENSIONINFO_PASSARGS \
+ STG_OBJECT_PASSARGS, \
+ _dataCopy, \
+ size, \
+ count
+
+ ExtensionInfo* _ExtensionInfo_New( EXTENSIONINFO_DEFARGS );
/* Initialisation implementation */
void _ExtensionInfo_Init( ExtensionInfo* self, Name name, SizeT size, Index count );
@@ -202,4 +210,5 @@
ExtensionInfo_Index handle,
void* data );
-#endif /* __Base_Extensibility_ExtensionInfo_h__ */
+#endif /* __StGermain_Base_Extensibility_ExtensionInfo_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ExtensionManager.c
--- a/Base/Extensibility/src/ExtensionManager.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ExtensionManager.c Tue Jan 12 14:38:16 2010 +1100
@@ -56,38 +56,44 @@ ExtensionManager* ExtensionManager_New_O
Name name,
SizeT initialSize )
{
- return _ExtensionManager_New(
- sizeof(ExtensionManager),
- ExtensionManager_Type,
- _ExtensionManager_Delete,
- _ExtensionManager_Print,
- _ExtensionManager_Copy,
- name,
- initialSize,
- NULL, /* no existing object */
- NULL, /* no array */
- 0,
- NULL,
- 0 );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ExtensionManager);
+ Type type = ExtensionManager_Type;
+ Stg_Class_DeleteFunction* _delete = _ExtensionManager_Delete;
+ Stg_Class_PrintFunction* _print = _ExtensionManager_Print;
+ Stg_Class_CopyFunction* _copy = _ExtensionManager_Copy;
+ void* _existingObject = NULL;
+ void* _array = NULL;
+ SizeT itemSize = 0;
+ ExtensionManager* em = NULL;
+ Index count = 0;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _ExtensionManager_New( EXTENSIONMANAGER_PASSARGS );
}
ExtensionManager* ExtensionManager_New_OfExistingObject(
Name name,
void* _existingObject )
{
- return _ExtensionManager_New(
- sizeof(ExtensionManager),
- ExtensionManager_Type,
- _ExtensionManager_Delete,
- _ExtensionManager_Print,
- _ExtensionManager_Copy,
- name,
- 0, /* not extending a struct here */
- _existingObject,
- NULL, /* not doing arrays here */
- 0,
- NULL,
- 0 );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ExtensionManager);
+ Type type = ExtensionManager_Type;
+ Stg_Class_DeleteFunction* _delete = _ExtensionManager_Delete;
+ Stg_Class_PrintFunction* _print = _ExtensionManager_Print;
+ Stg_Class_CopyFunction* _copy = _ExtensionManager_Copy;
+ SizeT initialSize = 0;
+ void* _array = NULL;
+ SizeT itemSize = 0;
+ ExtensionManager* em = NULL;
+ Index count = 0;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _ExtensionManager_New( EXTENSIONMANAGER_PASSARGS );
}
ExtensionManager* ExtensionManager_New_OfArray(
@@ -96,19 +102,20 @@ ExtensionManager* ExtensionManager_New_O
SizeT itemSize,
Index count )
{
- return _ExtensionManager_New(
- sizeof( ExtensionManager ),
- ExtensionManager_Type,
- _ExtensionManager_Delete,
- _ExtensionManager_Print,
- _ExtensionManager_Copy,
- name,
- 0, /* not extending a struct here */
- NULL, /* not doing single object */
- _array,
- itemSize,
- NULL, /* not extending an array of extended structs */
- count );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( ExtensionManager );
+ Type type = ExtensionManager_Type;
+ Stg_Class_DeleteFunction* _delete = _ExtensionManager_Delete;
+ Stg_Class_PrintFunction* _print = _ExtensionManager_Print;
+ Stg_Class_CopyFunction* _copy = _ExtensionManager_Copy;
+ SizeT initialSize = 0;
+ void* _existingObject = NULL;
+ ExtensionManager* em = NULL;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _ExtensionManager_New( EXTENSIONMANAGER_PASSARGS );
}
ExtensionManager* ExtensionManager_New_OfExtendedArray(
@@ -117,19 +124,20 @@ ExtensionManager* ExtensionManager_New_O
ExtensionManager* em,
Index count )
{
- return _ExtensionManager_New(
- sizeof(ExtensionManager),
- ExtensionManager_Type,
- _ExtensionManager_Delete,
- _ExtensionManager_Print,
- _ExtensionManager_Copy,
- name,
- 0, /* not extending a struct here */
- NULL, /* not doing single object */
- _array,
- 0, /* take itemSize from em */
- em, /* The ExtensionManager which extended the struct */
- count );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ExtensionManager);
+ Type type = ExtensionManager_Type;
+ Stg_Class_DeleteFunction* _delete = _ExtensionManager_Delete;
+ Stg_Class_PrintFunction* _print = _ExtensionManager_Print;
+ Stg_Class_CopyFunction* _copy = _ExtensionManager_Copy;
+ SizeT initialSize = 0;
+ void* _existingObject = NULL;
+ SizeT itemSize = 0;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _ExtensionManager_New( EXTENSIONMANAGER_PASSARGS );
}
void ExtensionManager_Init_OfStruct(
@@ -253,25 +261,18 @@ void ExtensionManager_Init_OfExtendedArr
count );
}
-ExtensionManager* _ExtensionManager_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- SizeT initialSize,
- void* _existingObject,
- void* _array,
- SizeT itemSize,
- ExtensionManager* em,
- Index count )
+ExtensionManager* _ExtensionManager_New( EXTENSIONMANAGER_DEFARGS )
{
ExtensionManager* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(ExtensionManager) );
- self = (ExtensionManager*)_Stg_Object_New( _sizeOfSelf, type, _delete, _print, _copy, name, NON_GLOBAL );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = NON_GLOBAL;
+
+ self = (ExtensionManager*)_Stg_Object_New( STG_OBJECT_PASSARGS );
/* General info */
@@ -954,3 +955,5 @@ Bool ExtensionManager_GetLockDown( void*
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ExtensionManager.h
--- a/Base/Extensibility/src/ExtensionManager.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ExtensionManager.h Tue Jan 12 14:38:16 2010 +1100
@@ -45,8 +45,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_ExtensionManager_h__
-#define __Base_Extensibility_ExtensionManager_h__
+#ifndef __StGermain_Base_Extensibility_ExtensionManager_h__
+#define __StGermain_Base_Extensibility_ExtensionManager_h__
/* Textual name of this class */
@@ -128,19 +128,30 @@
Index count );
/** Creation implementation / Virtual constructor */
- ExtensionManager* _ExtensionManager_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- SizeT initialSize,
- void* _existingObject,
- void* _array,
- SizeT itemSize,
- ExtensionManager* em,
- Index count );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define EXTENSIONMANAGER_DEFARGS \
+ STG_OBJECT_DEFARGS, \
+ SizeT initialSize, \
+ void* _existingObject, \
+ void* _array, \
+ SizeT itemSize, \
+ ExtensionManager* em, \
+ Index count
+
+ #define EXTENSIONMANAGER_PASSARGS \
+ STG_OBJECT_PASSARGS, \
+ initialSize, \
+ _existingObject, \
+ _array, \
+ itemSize, \
+ em, \
+ count
+
+ ExtensionManager* _ExtensionManager_New( EXTENSIONMANAGER_DEFARGS );
/* Initialisation implementation */
void _ExtensionManager_Init(
@@ -450,4 +461,5 @@
/* Property Set/Get for lockdown */
void ExtensionManager_SetLockDown( void* extension, Bool lockDown );
Bool ExtensionManager_GetLockDown( void* extension );
-#endif /* __Base_Extensibility_ExtensionManager_h__ */
+#endif /* __StGermain_Base_Extensibility_ExtensionManager_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ExtensionManager_Register.c
--- a/Base/Extensibility/src/ExtensionManager_Register.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ExtensionManager_Register.c Tue Jan 12 14:38:16 2010 +1100
@@ -47,13 +47,21 @@
/* Textual name of this class */
const Type ExtensionManager_Register_Type = "ExtensionManager_Register";
+ExtensionManager_Register* extensionMgr_Register = 0;
ExtensionManager_Register* ExtensionManager_Register_New( void ) {
- return _ExtensionManager_Register_New( sizeof(ExtensionManager_Register), ExtensionManager_Register_Type, _ExtensionManager_Register_Delete, _ExtensionManager_Register_Print, NULL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ExtensionManager_Register);
+ Type type = ExtensionManager_Register_Type;
+ Stg_Class_DeleteFunction* _delete = _ExtensionManager_Register_Delete;
+ Stg_Class_PrintFunction* _print = _ExtensionManager_Register_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ return _ExtensionManager_Register_New( EXTENSIONMANAGER_REGISTER_PASSARGS );
}
-void ExtensionManager_Register_Init( void* extensionMgr_Register ) {
- ExtensionManager_Register* self = (ExtensionManager_Register*)extensionMgr_Register;
+void ExtensionManager_Register_Init( void* extensionManager_Register ) {
+ ExtensionManager_Register* self = (ExtensionManager_Register*)extensionManager_Register;
/* General info */
self->type = ExtensionManager_Register_Type;
@@ -70,18 +78,13 @@ void ExtensionManager_Register_Init( voi
_ExtensionManager_Register_Init( self );
}
-ExtensionManager_Register* _ExtensionManager_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
+ExtensionManager_Register* _ExtensionManager_Register_New( EXTENSIONMANAGER_REGISTER_DEFARGS )
{
ExtensionManager_Register* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(ExtensionManager_Register) );
- self = (ExtensionManager_Register*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (ExtensionManager_Register*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -92,8 +95,8 @@ ExtensionManager_Register* _ExtensionMan
return self;
}
-void _ExtensionManager_Register_Init( void* extensionMgr_Register ) {
- ExtensionManager_Register* self = (ExtensionManager_Register*)extensionMgr_Register;
+void _ExtensionManager_Register_Init( void* extensionManager_Register ) {
+ ExtensionManager_Register* self = (ExtensionManager_Register*)extensionManager_Register;
/* General and Virtual info should already be set */
@@ -101,8 +104,8 @@ void _ExtensionManager_Register_Init( vo
self->extensions = Stg_ObjectList_New();
}
-void _ExtensionManager_Register_Delete( void* extensionMgr_Register ) {
- ExtensionManager_Register* self = (ExtensionManager_Register*)extensionMgr_Register;
+void _ExtensionManager_Register_Delete( void* extensionManager_Register ) {
+ ExtensionManager_Register* self = (ExtensionManager_Register*)extensionManager_Register;
/* Assumes ownerships of the element types */
Stg_Class_Delete( self->extensions );
@@ -111,8 +114,8 @@ void _ExtensionManager_Register_Delete(
_Stg_Class_Delete( self );
}
-void _ExtensionManager_Register_Print( void* extensionMgr_Register, Stream* stream ) {
- ExtensionManager_Register* self = (ExtensionManager_Register*)extensionMgr_Register;
+void _ExtensionManager_Register_Print( void* extensionManager_Register, Stream* stream ) {
+ ExtensionManager_Register* self = (ExtensionManager_Register*)extensionManager_Register;
/* General info */
Journal_Printf( (void*) stream, "ExtensionManager_Register (ptr): %p\n", self );
@@ -129,20 +132,28 @@ void _ExtensionManager_Register_Print( v
Stg_Class_Print( self->extensions, stream );
}
-ExtensionManager_Index ExtensionManager_Register_Add( void* extensionMgr_Register, void* extension ) {
- ExtensionManager_Register* self = (ExtensionManager_Register*)extensionMgr_Register;
+ExtensionManager_Index ExtensionManager_Register_Add( void* extensionManager_Register, void* extension ) {
+ ExtensionManager_Register* self = (ExtensionManager_Register*)extensionManager_Register;
return Stg_ObjectList_Append( self->extensions, extension );
}
-ExtensionManager_Index ExtensionManager_Register_GetExtensionHandle( void* extensionMgr_Register, Name toGet ) {
- ExtensionManager_Register* self = (ExtensionManager_Register*)extensionMgr_Register;
+ExtensionManager_Index ExtensionManager_Register_Remove( void* extensionManager_Register, void* extension ) {
+ ExtensionManager_Register* self = (ExtensionManager_Register*)extensionManager_Register;
+
+ return Stg_ObjectList_Remove( self->extensions, ((ExtensionManager*)extension)->name, KEEP );
+}
+
+ExtensionManager_Index ExtensionManager_Register_GetExtensionHandle( void* extensionManager_Register, Name toGet ) {
+ ExtensionManager_Register* self = (ExtensionManager_Register*)extensionManager_Register;
return Stg_ObjectList_GetIndex( self->extensions, toGet );
}
-ExtensionManager* _ExtensionManager_Register_GetExtension( void* extensionMgr_Register, ExtensionManager_Index handle ) {
- ExtensionManager_Register* self = (ExtensionManager_Register*)extensionMgr_Register;
+ExtensionManager* _ExtensionManager_Register_GetExtension( void* extensionManager_Register, ExtensionManager_Index handle ) {
+ ExtensionManager_Register* self = (ExtensionManager_Register*)extensionManager_Register;
return ExtensionManager_Register_GetExtension( self, handle );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ExtensionManager_Register.h
--- a/Base/Extensibility/src/ExtensionManager_Register.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ExtensionManager_Register.h Tue Jan 12 14:38:16 2010 +1100
@@ -40,12 +40,15 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_ExtensionManager_Register_h__
-#define __Base_Extensibility_ExtensionManager_Register_h__
+#ifndef __StGermain_Base_Extensibility_ExtensionManager_Register_h__
+#define __StGermain_Base_Extensibility_ExtensionManager_Register_h__
/** Textual name of this class */
extern const Type ExtensionManager_Register_Type;
+
+ /* global default instantiation of the register (created in Init.c) */
+ extern ExtensionManager_Register* extensionMgr_Register;
/** ExtensionManager_Register class contents */
#define __ExtensionManager_Register \
@@ -67,12 +70,18 @@
void ExtensionManager_Register_Init( void* extension_Register );
/** Creation implementation / Virtual constructor */
- ExtensionManager_Register* _ExtensionManager_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define EXTENSIONMANAGER_REGISTER_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define EXTENSIONMANAGER_REGISTER_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ ExtensionManager_Register* _ExtensionManager_Register_New( EXTENSIONMANAGER_REGISTER_DEFARGS );
/** Initialisation implementation */
void _ExtensionManager_Register_Init( void* extension_Register );
@@ -86,6 +95,9 @@
/** Add a new Extension to the register. */
ExtensionManager_Index ExtensionManager_Register_Add( void* extension_Register, void* extension );
+
+ /** Removes an Extension from the register */
+ ExtensionManager_Index ExtensionManager_Register_Remove( void* extensionManager_Register, void* extension );
/** Get the handle of an extension in the register. */
ExtensionManager_Index ExtensionManager_Register_GetExtensionHandle( void* extension_Register, Name toGet );
@@ -96,4 +108,5 @@
ExtensionManager* _ExtensionManager_Register_At( void* extension_Register, ExtensionManager_Index handle );
-#endif /* __Base_Extensibility_ExtensionManager_Register_h__ */
+#endif /* __StGermain_Base_Extensibility_ExtensionManager_Register_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Finalise.c
--- a/Base/Extensibility/src/Finalise.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Finalise.c Tue Jan 12 14:38:16 2010 +1100
@@ -36,6 +36,7 @@
#include "types.h"
#include "shortcuts.h"
+#include "ExtensionManager_Register.h"
#include "Init.h"
#include "Finalise.h"
@@ -45,6 +46,9 @@ Bool BaseExtensibility_Finalise( void )
Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
Stg_Class_Delete( stgToolboxesManager );
+ Stg_Class_Delete( extensionMgr_Register );
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Finalise.h
--- a/Base/Extensibility/src/Finalise.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Finalise.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,9 +38,9 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_BaseExtensibility_Finalise_h__
-#define __Base_BaseExtensibility_Finalise_h__
+#ifndef __StGermain_Base_BaseExtensibility_Finalise_h__
+#define __StGermain_Base_BaseExtensibility_Finalise_h__
Bool BaseExtensibility_Finalise( void );
-#endif /* __Base_BaseExtensibility_Finalise_h__ */
+#endif /* __StGermain_Base_BaseExtensibility_Finalise_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Hook.c
--- a/Base/Extensibility/src/Hook.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Hook.c Tue Jan 12 14:38:16 2010 +1100
@@ -49,7 +49,17 @@ const Type Hook_Type = "Hook";
/** allocate and initialise a new Hook. */
Hook* Hook_New( Name name, Func_Ptr funcPtr, char* addedBy ) {
- return _Hook_New( sizeof(Hook), Hook_Type, _Hook_Delete, _Hook_Print, _Hook_Copy, name, funcPtr, addedBy );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Hook);
+ Type type = Hook_Type;
+ Stg_Class_DeleteFunction* _delete = _Hook_Delete;
+ Stg_Class_PrintFunction* _print = _Hook_Print;
+ Stg_Class_CopyFunction* _copy = _Hook_Copy;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _Hook_New( HOOK_PASSARGS );
}
void Hook_Init( void* hook, Name name, Func_Ptr funcPtr, char* addedBy ) {
@@ -72,21 +82,18 @@ void Hook_Init( void* hook, Name name, F
}
-Hook* _Hook_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Func_Ptr funcPtr,
- char* addedBy )
+Hook* _Hook_New( HOOK_DEFARGS )
{
Hook* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(Hook) );
- self = (Hook*)_Stg_Object_New( _sizeOfSelf, type, _delete, _print, _copy, name, NON_GLOBAL );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = NON_GLOBAL;
+
+ self = (Hook*)_Stg_Object_New( STG_OBJECT_PASSARGS );
/* General info */
@@ -162,3 +169,5 @@ void* _Hook_Copy( void* hook, void* dest
return (void*)newHook;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Hook.h
--- a/Base/Extensibility/src/Hook.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Hook.h Tue Jan 12 14:38:16 2010 +1100
@@ -36,8 +36,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_Hook_h__
-#define __Base_Extensibility_Hook_h__
+#ifndef __StGermain_Base_Extensibility_Hook_h__
+#define __StGermain_Base_Extensibility_Hook_h__
/** Textual name of this class */
@@ -59,15 +59,22 @@
void Hook_Init( void* hook, Name name, Func_Ptr funcPtr, char* addedBy );
/* Creation implementation */
- Hook* _Hook_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Func_Ptr funcPtr,
- char* addedBy );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define HOOK_DEFARGS \
+ STG_OBJECT_DEFARGS, \
+ Func_Ptr funcPtr, \
+ char* addedBy
+
+ #define HOOK_PASSARGS \
+ STG_OBJECT_PASSARGS, \
+ funcPtr, \
+ addedBy
+
+ Hook* _Hook_New( HOOK_DEFARGS );
/* Initialisation implementation */
void _Hook_Init( Hook* self, Func_Ptr funcPtr, char* addedBy );
@@ -87,4 +94,5 @@
void* _Hook_Copy( void* hook, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
-#endif /* __Base_Extensibility_Hook_h__ */
+#endif /* __StGermain_Base_Extensibility_Hook_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Init.c
--- a/Base/Extensibility/src/Init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Init.c Tue Jan 12 14:38:16 2010 +1100
@@ -63,6 +63,8 @@ Bool BaseExtensibility_Init( int* argc,
Bool BaseExtensibility_Init( int* argc, char** argv[] ) {
Journal_Printf( Journal_Register( DebugStream_Type, "Context" ), "In: %s\n", __func__ ); /* DO NOT CHANGE OR REMOVE */
+ extensionMgr_Register = ExtensionManager_Register_New();
+
RegisterParent( Hook_Type, Stg_Object_Type );
RegisterParent( ClassHook_Type, Hook_Type );
@@ -78,7 +80,7 @@ Bool BaseExtensibility_Init( int* argc,
RegisterParent( Module_Type, Stg_Object_Type );
RegisterParent( Plugin_Type, Module_Type );
- RegisterParent( Toolbox_Type, Toolbox_Type );
+ RegisterParent( Toolbox_Type, Module_Type );
RegisterParent( ModulesManager_Type, Stg_Class_Type );
RegisterParent( PluginsManager_Type, ModulesManager_Type );
RegisterParent( ToolboxesManager_Type, ModulesManager_Type );
@@ -87,3 +89,5 @@ Bool BaseExtensibility_Init( int* argc,
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Init.h
--- a/Base/Extensibility/src/Init.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Init.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,12 +39,12 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_BaseExtensibility_Init_h__
-#define __Base_BaseExtensibility_Init_h__
+#ifndef __StGermain_Base_BaseExtensibility_Init_h__
+#define __StGermain_Base_BaseExtensibility_Init_h__
/** The toolboxes singleton... this is the manager of loading and unloading toolboxes */
extern ToolboxesManager* stgToolboxesManager;
Bool BaseExtensibility_Init( int* argc, char** argv[] );
-#endif /* __Base_BaseExtensibility_Init_h__ */
+#endif /* __StGermain_Base_BaseExtensibility_Init_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Module.c
--- a/Base/Extensibility/src/Module.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Module.c Tue Jan 12 14:38:16 2010 +1100
@@ -89,21 +89,18 @@ void ***stg_module_funcs = NULL;
void ***stg_module_funcs = NULL;
#endif
-Module* _Module_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Module_MangleNameFunction MangleName,
- Stg_ObjectList* directories )
+Module* _Module_New( MODULE_DEFARGS )
{
Module* self;
assert( _sizeOfSelf >= sizeof(Module) );
- self = (Module*)_Stg_Object_New( _sizeOfSelf, type, _delete, _print, _copy, name, NON_GLOBAL );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = NON_GLOBAL;
+
+ self = (Module*)_Stg_Object_New( STG_OBJECT_PASSARGS );
_Module_Init( self, MangleName, directories );
@@ -359,3 +356,7 @@ void* Module_MapStaticSymbol(Module *sel
return stg_module_funcs[ii][jj];
}
#endif
+
+
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Module.h
--- a/Base/Extensibility/src/Module.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Module.h Tue Jan 12 14:38:16 2010 +1100
@@ -36,8 +36,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_Module_h__
-#define __Base_Extensibility_Module_h__
+#ifndef __StGermain_Base_Extensibility_Module_h__
+#define __StGermain_Base_Extensibility_Module_h__
/* The prototype for the virtual functions in a module */
typedef char* (Module_MangleNameFunction) ( char* name );
@@ -70,15 +70,22 @@
/* Creation implementation / Virtual constructor */
- Module* _Module_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Module_MangleNameFunction MangleName,
- Stg_ObjectList* directories );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define MODULE_DEFARGS \
+ STG_OBJECT_DEFARGS, \
+ Module_MangleNameFunction* MangleName, \
+ Stg_ObjectList* directories
+
+ #define MODULE_PASSARGS \
+ STG_OBJECT_PASSARGS, \
+ MangleName, \
+ directories
+
+ Module* _Module_New( MODULE_DEFARGS );
/* Initialisation implementation */
void _Module_Init(
@@ -108,4 +115,5 @@
/** Un load the module */
void Module_UnLoad( void* module );
-#endif /* __Base_Extensibility_Module_h__ */
+#endif /* __StGermain_Base_Extensibility_Module_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ModulesManager.c
--- a/Base/Extensibility/src/ModulesManager.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ModulesManager.c Tue Jan 12 14:38:16 2010 +1100
@@ -38,6 +38,7 @@
#include "shortcuts.h"
#include "Module.h"
#include "ModulesManager.h"
+#include "ToolboxesManager.h"
#include <stdio.h>
#include <stdlib.h>
@@ -70,22 +71,13 @@ const char* Codelet_GetMetadata();
/* Define memory for global pointer to moduleDirectories */
Stg_ObjectList* moduleDirectories = NULL;
-ModulesManager* _ModulesManager_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ModulesManager_GetModulesListFunction* _getModulesList,
- ModulesManager_LoadModuleFunction* _loadModule,
- ModulesManager_UnloadModuleFunction* _unloadModule,
- ModulesManager_ModuleFactoryFunction* _moduleFactory )
+ModulesManager* _ModulesManager_New( MODULESMANAGER_DEFARGS )
{
ModulesManager* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(ModulesManager) );
- self = (ModulesManager*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (ModulesManager*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -94,6 +86,8 @@ ModulesManager* _ModulesManager_New(
self->_loadModule = _loadModule;
self->_unloadModule = _unloadModule;
self->_moduleFactory = _moduleFactory;
+ self->_checkContext = _checkContext;
+ self->_getModuleName = _getModuleName;
_ModulesManager_Init( self );
@@ -169,7 +163,6 @@ void _ModulesManager_Print( void* module
}
}
-
Dictionary_Entry_Value* ModulesManager_GetModulesList( void* modulesManager, void* _dictionary ) {
ModulesManager* self = (ModulesManager*)modulesManager;
Dictionary* dictionary = (Dictionary*)_dictionary;
@@ -177,22 +170,35 @@ Dictionary_Entry_Value* ModulesManager_G
return self->_getModulesList( self, dictionary );
}
+Bool ModulesManager_CheckContext( void* modulesManager, Dictionary_Entry_Value* modulesVal, unsigned int entry_I, Name contextName ) {
+ ModulesManager* self = (ModulesManager*)modulesManager;
-void ModulesManager_Load( void* modulesManager, void* _dictionary ) {
+ return self->_checkContext( self, modulesVal, entry_I, contextName );
+}
+
+Name ModulesManager_GetModuleName( void* modulesManager, Dictionary_Entry_Value* moduleVal, unsigned int entry_I ) {
+ ModulesManager* self = (ModulesManager*)modulesManager;
+
+ return self->_getModuleName( self, moduleVal, entry_I );
+}
+
+void ModulesManager_Load( void* modulesManager, void* _dictionary, Name contextName ) {
ModulesManager* self = (ModulesManager*)modulesManager;
- Dictionary* dictionary = (Dictionary*)_dictionary;
- unsigned int entryCount;
- unsigned int entry_I;
- Dictionary_Entry_Value* modulesVal;
+ Dictionary* dictionary = (Dictionary*)_dictionary;
+ unsigned int entryCount;
+ unsigned int entry_I;
+ Dictionary_Entry_Value* modulesVal;
/* First add the directory list onto LD_LIBRARY_PATH so that it can potentially
* resolve the unknown symbols */
+#ifndef NOSHARED
char* curEnvPath;
char* newEnvPath;
- Index newEnvPathLength = 0;
+ Index newEnvPathLength;
Index dir_I;
-
-#ifndef NOSHARED
+
+ newEnvPathLength = 0;
+
if( dictionary ) {
Dictionary_Entry_Value* localLibDirList = Dictionary_Get( dictionary, "LD_LIBRARY_PATH" );
if( localLibDirList ) {
@@ -249,7 +255,11 @@ void ModulesManager_Load( void* modulesM
for( entry_I = 0; entry_I < entryCount; entry_I++ ) {
Name moduleName;
- moduleName = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement( modulesVal, entry_I ) );
+ moduleName = ModulesManager_GetModuleName( self, modulesVal, entry_I );
+ //moduleName = Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement( modulesVal, entry_I ) );
+
+ if( !ModulesManager_CheckContext( self, modulesVal, entry_I, contextName ) )
+ continue;
if ( ! ModulesManager_LoadModule( self, moduleName ) ) {
#ifndef NOSHARED
@@ -422,7 +432,9 @@ Index ModulesManager_Submit(
codeletInstance = defaultNew( codeletName );
result = Stg_ObjectList_Append( self->codelets, codeletInstance );
- if( LiveComponentRegister_GetLiveComponentRegister() ) {
+
+ /* only submit if not a toolbox */
+ if( LiveComponentRegister_GetLiveComponentRegister() && strcmp( self->type, ToolboxesManager_Type ) ) {
LiveComponentRegister_Add( LiveComponentRegister_GetLiveComponentRegister(), codeletInstance );
}
@@ -459,7 +471,7 @@ void ModulesManager_ConstructModules( vo
int i;
for( i = 0; i < self->codelets->count; ++i ) {
- Stg_Component_Construct( self->codelets->data[i], cf, data, False );
+ Stg_Component_AssignFromXML( self->codelets->data[i], cf, data, False );
}
}
@@ -473,7 +485,9 @@ Bool ModulesManager_ConstructModule( voi
if( codelet == NULL )
return False;
else
- Stg_Component_Construct( codelet, cf, data, False );
+ Stg_Component_AssignFromXML( codelet, cf, data, False );
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ModulesManager.h
--- a/Base/Extensibility/src/ModulesManager.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ModulesManager.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_ModulesManager_h__
-#define __Base_Extensibility_ModulesManager_h__
+#ifndef __StGermain_Base_Extensibility_ModulesManager_h__
+#define __StGermain_Base_Extensibility_ModulesManager_h__
/* Textual name of this class */
@@ -50,6 +50,11 @@
typedef Bool (ModulesManager_LoadModuleFunction) ( void* modulesManager, Module* module );
typedef Bool (ModulesManager_UnloadModuleFunction) ( void* modulesManager, Module* module );
typedef Module* (ModulesManager_ModuleFactoryFunction) ( Name name, Stg_ObjectList* directories );
+ typedef Bool (ModulesManager_CheckContextFunction) ( void* modulesManager,
+ Dictionary_Entry_Value* modulesVal,
+ unsigned int entry_I,
+ Name contextName );
+ typedef Name (ModulesManager_GetModuleNameFunction) ( void* modulesManager, Dictionary_Entry_Value* modulesVal, unsigned int entry_I );
/* Modules info */
#define __ModulesManager \
@@ -61,6 +66,8 @@
ModulesManager_LoadModuleFunction* _loadModule; \
ModulesManager_UnloadModuleFunction* _unloadModule; \
ModulesManager_ModuleFactoryFunction* _moduleFactory; \
+ ModulesManager_CheckContextFunction* _checkContext; \
+ ModulesManager_GetModuleNameFunction* _getModuleName; \
\
/* Modules info */ \
Stg_ObjectList* modules; \
@@ -72,16 +79,30 @@
extern Stg_ObjectList* moduleDirectories;
/* Creation implementation / Virtual constructor */
- ModulesManager* _ModulesManager_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ModulesManager_GetModulesListFunction* _getModulesList,
- ModulesManager_LoadModuleFunction* _loadModule,
- ModulesManager_UnloadModuleFunction* _unloadModule,
- ModulesManager_ModuleFactoryFunction* _moduleFactory );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define MODULESMANAGER_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ ModulesManager_GetModulesListFunction* _getModulesList, \
+ ModulesManager_LoadModuleFunction* _loadModule, \
+ ModulesManager_UnloadModuleFunction* _unloadModule, \
+ ModulesManager_ModuleFactoryFunction* _moduleFactory, \
+ ModulesManager_CheckContextFunction* _checkContext, \
+ ModulesManager_GetModuleNameFunction* _getModuleName
+
+ #define MODULESMANAGER_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ _getModulesList, \
+ _loadModule, \
+ _unloadModule, \
+ _moduleFactory, \
+ _checkContext, \
+ _getModuleName
+
+ ModulesManager* _ModulesManager_New( MODULESMANAGER_DEFARGS );
/* Initialisation implementation */
void _ModulesManager_Init( void* modulesManager );
@@ -94,9 +115,15 @@
/** Get the modules list from the dictionary */
Dictionary_Entry_Value* ModulesManager_GetModulesList( void* modulesManager, void* dictionary );
+
+ /** check that a given module is associated with a given context (from the XML) - always true for toolboxes,
+ whereas plugins are associated with a specific context */
+ Bool ModulesManager_CheckContext( void* modulesManager, Dictionary_Entry_Value* modulesVal, unsigned int entry_I, Name contextName );
+
+ Name ModulesManaget_GetModuleName( void* modulesManager, Dictionary_Entry_Value* moduleVal, unsigned int entry_I );
/** Load the specified modules from the dictionary attaching the codelets (components) */
- void ModulesManager_Load( void* modulesManager, void* dictionary );
+ void ModulesManager_Load( void* modulesManager, void* dictionary, Name contextName );
/** Load a module attaching the codelet (component) */
Bool ModulesManager_LoadModule( void* modulesManager, Name moduleName );
@@ -123,4 +150,5 @@
Bool ModulesManager_ConstructModule( void* modulesManager, Name moduleName, Stg_ComponentFactory* cf, void* data );
-#endif /* __Base_Extensibility_ModulesManager_h__ */
+#endif /* __StGermain_Base_Extensibility_ModulesManager_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Plugin.c
--- a/Base/Extensibility/src/Plugin.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Plugin.c Tue Jan 12 14:38:16 2010 +1100
@@ -59,36 +59,31 @@ static const char* PLUGIN_REGISTER_SUFFI
Plugin* Plugin_New( Name name, Stg_ObjectList* directories ) {
- return _Plugin_New(
- sizeof(Plugin),
- Plugin_Type,
- _Plugin_Delete,
- _Plugin_Print,
- NULL,
- name,
- _Plugin_MangleName,
- directories );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Plugin);
+ Type type = Plugin_Type;
+ Stg_Class_DeleteFunction* _delete = _Plugin_Delete;
+ Stg_Class_PrintFunction* _print = _Plugin_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ Module_MangleNameFunction* MangleName = _Plugin_MangleName;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _Plugin_New( PLUGIN_PASSARGS );
}
Module* Plugin_Factory( Name name, Stg_ObjectList* directories ) {
return (Module*)Plugin_New( name, directories );
}
-Plugin* _Plugin_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Module_MangleNameFunction MangleName,
- Stg_ObjectList* directories )
+Plugin* _Plugin_New( PLUGIN_DEFARGS )
{
Plugin* self;
assert( _sizeOfSelf >= sizeof(Plugin) );
- self = (Plugin*)_Module_New( _sizeOfSelf, type, _delete, _print, _copy, name, MangleName, directories );
+ self = (Plugin*)_Module_New( MODULE_PASSARGS );
_Plugin_Init( self );
@@ -140,3 +135,5 @@ Plugin_RegisterFunction* Plugin_GetRegis
return self->Register;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Plugin.h
--- a/Base/Extensibility/src/Plugin.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Plugin.h Tue Jan 12 14:38:16 2010 +1100
@@ -36,8 +36,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_Plugin_h__
-#define __Base_Extensibility_Plugin_h__
+#ifndef __StGermain_Base_Extensibility_Plugin_h__
+#define __StGermain_Base_Extensibility_Plugin_h__
/** The prototype for the Register function in a plugin */
typedef Index (Plugin_RegisterFunction) ( void* pluginsManager );
@@ -63,15 +63,18 @@
Module* Plugin_Factory( Name name, Stg_ObjectList* directories );
/* Creation implementation / Virtual constructor */
- Plugin* _Plugin_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Module_MangleNameFunction MangleName,
- Stg_ObjectList* directories );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define PLUGIN_DEFARGS \
+ MODULE_DEFARGS
+
+ #define PLUGIN_PASSARGS \
+ MODULE_PASSARGS
+
+ Plugin* _Plugin_New( PLUGIN_DEFARGS );
/* Initialisation implementation */
void _Plugin_Init( Plugin* self );
@@ -88,4 +91,5 @@
/** Get the function pointer the to the plugin's register function */
Plugin_RegisterFunction* Plugin_GetRegisterFunc( void* plugin );
-#endif /* __Base_Extensibility_Plugin_h__ */
+#endif /* __StGermain_Base_Extensibility_Plugin_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/PluginsManager.c
--- a/Base/Extensibility/src/PluginsManager.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/PluginsManager.c Tue Jan 12 14:38:16 2010 +1100
@@ -29,6 +29,7 @@
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <stdarg.h>
+#include <string.h>
#include "Base/Foundation/Foundation.h"
#include "Base/IO/IO.h"
#include "Base/Container/Container.h"
@@ -47,43 +48,29 @@ const Type PluginsManager_Type = "Plugin
PluginsManager* PluginsManager_New( void ) {
- return _PluginsManager_New(
- sizeof(PluginsManager),
- PluginsManager_Type,
- _PluginsManager_Delete,
- _PluginsManager_Print,
- NULL,
- _PluginsManager_GetPluginsList,
- _PluginsManager_LoadPlugin,
- _PluginsManager_UnloadPlugin,
- Plugin_Factory );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(PluginsManager);
+ Type type = PluginsManager_Type;
+ Stg_Class_DeleteFunction* _delete = _PluginsManager_Delete;
+ Stg_Class_PrintFunction* _print = _PluginsManager_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ ModulesManager_GetModulesListFunction* _getModulesList = _PluginsManager_GetPluginsList;
+ ModulesManager_LoadModuleFunction* _loadModule = _PluginsManager_LoadPlugin;
+ ModulesManager_UnloadModuleFunction* _unloadModule = _PluginsManager_UnloadPlugin;
+ ModulesManager_ModuleFactoryFunction* _moduleFactory = Plugin_Factory;
+ ModulesManager_CheckContextFunction* _checkContext = _PluginsManager_CheckContext;
+ ModulesManager_GetModuleNameFunction* _getModuleName = _PluginsManager_GetModuleName;
+
+ return _PluginsManager_New( PLUGINSMANAGER_PASSARGS );
}
-PluginsManager* _PluginsManager_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ModulesManager_GetModulesListFunction* _getModulesList,
- ModulesManager_LoadModuleFunction* _loadModule,
- ModulesManager_UnloadModuleFunction* _unloadModule,
- ModulesManager_ModuleFactoryFunction* _moduleFactory )
+PluginsManager* _PluginsManager_New( PLUGINSMANAGER_DEFARGS )
{
PluginsManager* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(PluginsManager) );
- self = (PluginsManager*)_ModulesManager_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _getModulesList,
- _loadModule,
- _unloadModule,
- _moduleFactory );
+ self = (PluginsManager*)_ModulesManager_New( MODULESMANAGER_PASSARGS );
/* General info */
@@ -126,7 +113,6 @@ Dictionary_Entry_Value* _PluginsManager_
return pluginsList;
}
-
Bool _PluginsManager_LoadPlugin( void* pluginsManager, Module* plugin ) {
PluginsManager* self = (PluginsManager*)pluginsManager;
@@ -136,7 +122,55 @@ Bool _PluginsManager_LoadPlugin( void* p
}
Bool _PluginsManager_UnloadPlugin( void* pluginsManager, Module* plugin ) {
- /*PluginsManager* self = (PluginsManager*)pluginsManager;*/
+ PluginsManager* self = (PluginsManager*)pluginsManager;
+
+ ModulesManager_Unload( self );
return True;
}
+
+void PluginsManager_RemoveAllFromComponentRegister( void* pluginsManager ) {
+ PluginsManager* self = (PluginsManager*)pluginsManager;
+ Stg_ComponentRegister* componentRegister = Stg_ComponentRegister_Get_ComponentRegister();
+ Index i;
+
+ for (i=0; i<Stg_ObjectList_Count(self->codelets); i++) {
+ Stg_Object *codelet = self->codelets->data[i];
+ Stg_ComponentRegister_RemoveEntry(componentRegister, codelet->type, "0");
+ }
+}
+
+Bool _PluginsManager_CheckContext( void* pluginsManager, Dictionary_Entry_Value* modulesVal, unsigned int entry_I, Name contextName ) {
+ PluginsManager* self;
+ Dictionary_Entry_Value* pluginDEV = Dictionary_Entry_Value_GetElement( modulesVal, entry_I );
+ Dictionary* pluginDict;
+ Name componentName;
+
+ self = (PluginsManager*)pluginsManager;
+
+ pluginDict = Dictionary_Entry_Value_AsDictionary( pluginDEV );
+ if( !pluginDict )
+ return False;
+
+ componentName = Dictionary_GetString_WithDefault( pluginDict, "Context", "context" );
+
+ if( !strcmp( componentName, contextName ) )
+ return True;
+
+ return False;
+}
+
+Name _PluginsManager_GetModuleName( void* pluginsManager, Dictionary_Entry_Value* moduleVal, unsigned int entry_I ) {
+ PluginsManager* self;
+ Dictionary_Entry_Value* pluginDEV = Dictionary_Entry_Value_GetElement( moduleVal, entry_I );
+ Dictionary* pluginDict = Dictionary_Entry_Value_AsDictionary( pluginDEV );
+ Name pluginName = Dictionary_GetString( pluginDict, "Type" );
+
+ self = (PluginsManager*)pluginsManager;
+
+ return pluginName;
+}
+
+
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/PluginsManager.h
--- a/Base/Extensibility/src/PluginsManager.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/PluginsManager.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_PluginsManager_h__
-#define __Base_Extensibility_PluginsManager_h__
+#ifndef __StGermain_Base_Extensibility_PluginsManager_h__
+#define __StGermain_Base_Extensibility_PluginsManager_h__
/* Textual name of this class */
@@ -64,16 +64,18 @@
PluginsManager* PluginsManager_New( void );
/* Creation implementation / Virtual constructor */
- PluginsManager* _PluginsManager_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ModulesManager_GetModulesListFunction* _getModulesList,
- ModulesManager_LoadModuleFunction* _loadModule,
- ModulesManager_UnloadModuleFunction* _unloadModule,
- ModulesManager_ModuleFactoryFunction* _moduleFactory );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define PLUGINSMANAGER_DEFARGS \
+ MODULESMANAGER_DEFARGS
+
+ #define PLUGINSMANAGER_PASSARGS \
+ MODULESMANAGER_PASSARGS
+
+ PluginsManager* _PluginsManager_New( PLUGINSMANAGER_DEFARGS );
/* Initialisation implementation */
void _PluginsManager_Init( void* pluginsManager );
@@ -89,10 +91,18 @@
/** Exactly what to do to load the plugin */
Bool _PluginsManager_LoadPlugin( void* pluginsManager, Module* plugin );
-
+
/** Exactly what to do to unload the plugin */
Bool _PluginsManager_UnloadPlugin( void* pluginsManager, Module* plugin );
+ /** Remove all plugins from register */
+ void PluginsManager_RemoveAllFromComponentRegister( void* pluginsManager );
+
+ Bool _PluginsManager_CheckContext( void* pluginsManager, Dictionary_Entry_Value* modulesVal, unsigned int entry_I, Name contextName );
+
+ Name _PluginsManager_GetModuleName( void* pluginsManager, Dictionary_Entry_Value* moduleVal, unsigned int entry_I );
+
#define PluginsManager_Submit ModulesManager_Submit
-#endif /* __Base_Extensibility_PluginsManager_h__ */
+#endif /* __StGermain_Base_Extensibility_PluginsManager_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/SimpleExtensionInfo.c
--- a/Base/Extensibility/src/SimpleExtensionInfo.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/SimpleExtensionInfo.c Tue Jan 12 14:38:16 2010 +1100
@@ -55,16 +55,18 @@ const Type SimpleExtensionInfo_Type = "S
/** allocate and initialise a new SimpleExtensionInfo. */
SimpleExtensionInfo* SimpleExtensionInfo_New( const Name name, SizeT size, Index count ) {
- return _SimpleExtensionInfo_New(
- sizeof(SimpleExtensionInfo),
- SimpleExtensionInfo_Type,
- _SimpleExtensionInfo_Delete,
- _SimpleExtensionInfo_Print,
- _SimpleExtensionInfo_Copy,
- _SimpleExtensionInfo_DataCopy,
- (Name)name,
- size,
- count );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(SimpleExtensionInfo);
+ Type type = SimpleExtensionInfo_Type;
+ Stg_Class_DeleteFunction* _delete = _SimpleExtensionInfo_Delete;
+ Stg_Class_PrintFunction* _print = _SimpleExtensionInfo_Print;
+ Stg_Class_CopyFunction* _copy = _SimpleExtensionInfo_Copy;
+ ExtensionInfo_DataCopyFunction* _dataCopy = _SimpleExtensionInfo_DataCopy;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _SimpleExtensionInfo_New( SIMPLEEXTENSIONINFO_PASSARGS );
}
@@ -87,31 +89,13 @@ void SimpleExtensionInfo_Init( void* sim
}
-SimpleExtensionInfo* _SimpleExtensionInfo_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ExtensionInfo_DataCopyFunction* _dataCopy,
- Name name,
- SizeT size,
- Index count )
+SimpleExtensionInfo* _SimpleExtensionInfo_New( SIMPLEEXTENSIONINFO_DEFARGS )
{
SimpleExtensionInfo* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(SimpleExtensionInfo) );
- self = (SimpleExtensionInfo*)_ExtensionInfo_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _dataCopy,
- name,
- size,
- count );
+ self = (SimpleExtensionInfo*)_ExtensionInfo_New( EXTENSIONINFO_PASSARGS );
/* General info */
@@ -193,3 +177,5 @@ void* _SimpleExtensionInfo_DataCopy(
/* Public member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/SimpleExtensionInfo.h
--- a/Base/Extensibility/src/SimpleExtensionInfo.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/SimpleExtensionInfo.h Tue Jan 12 14:38:16 2010 +1100
@@ -48,8 +48,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_SimpleExtensionInfo_h__
-#define __Base_Extensibility_SimpleExtensionInfo_h__
+#ifndef __StGermain_Base_Extensibility_SimpleExtensionInfo_h__
+#define __StGermain_Base_Extensibility_SimpleExtensionInfo_h__
/** Textual name of this class */
extern const Type SimpleExtensionInfo_Type;
@@ -72,16 +72,18 @@
void SimpleExtensionInfo_Init( void* simpleExtensionInfo, const Name name, SizeT size, Index count );
/* Creation implementation */
- SimpleExtensionInfo* _SimpleExtensionInfo_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ExtensionInfo_DataCopyFunction* _dataCopy,
- Name name,
- SizeT size,
- Index count );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define SIMPLEEXTENSIONINFO_DEFARGS \
+ EXTENSIONINFO_DEFARGS
+
+ #define SIMPLEEXTENSIONINFO_PASSARGS \
+ EXTENSIONINFO_PASSARGS
+
+ SimpleExtensionInfo* _SimpleExtensionInfo_New( SIMPLEEXTENSIONINFO_DEFARGS );
/* Initialisation implementation */
void _SimpleExtensionInfo_Init( SimpleExtensionInfo* self, Name name, SizeT size, Index count );
@@ -105,4 +107,5 @@
/* Public member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#endif /* __Base_Extensibility_SimpleExtensionInfo_h__ */
+#endif /* __StGermain_Base_Extensibility_SimpleExtensionInfo_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Toolbox.c
--- a/Base/Extensibility/src/Toolbox.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Toolbox.c Tue Jan 12 14:38:16 2010 +1100
@@ -60,36 +60,31 @@ static const char* TOOLBOX_MODULE_SUFFIX
#endif
Toolbox* Toolbox_New( Name name, Stg_ObjectList* directories ) {
- return _Toolbox_New(
- sizeof(Toolbox),
- Toolbox_Type,
- _Toolbox_Delete,
- _Toolbox_Print,
- NULL,
- name,
- _Toolbox_MangleName,
- directories );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Toolbox);
+ Type type = Toolbox_Type;
+ Stg_Class_DeleteFunction* _delete = _Toolbox_Delete;
+ Stg_Class_PrintFunction* _print = _Toolbox_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ Module_MangleNameFunction* MangleName = _Toolbox_MangleName;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _Toolbox_New( TOOLBOX_PASSARGS );
}
Module* Toolbox_Factory( Name name, Stg_ObjectList* directories ) {
return (Module*)Toolbox_New( name, directories );
}
-Toolbox* _Toolbox_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Module_MangleNameFunction MangleName,
- Stg_ObjectList* directories )
+Toolbox* _Toolbox_New( TOOLBOX_DEFARGS )
{
Toolbox* self;
assert( _sizeOfSelf >= sizeof(Toolbox) );
- self = (Toolbox*)_Module_New( _sizeOfSelf, type, _delete, _print, _copy, name, MangleName, directories );
+ self = (Toolbox*)_Module_New( MODULE_PASSARGS );
_Toolbox_Init( self );
@@ -159,3 +154,5 @@ Toolbox_FinaliseFunction* Toolbox_GetFin
return self->Finalise;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/Toolbox.h
--- a/Base/Extensibility/src/Toolbox.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/Toolbox.h Tue Jan 12 14:38:16 2010 +1100
@@ -36,8 +36,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_Toolbox_h__
-#define __Base_Extensibility_Toolbox_h__
+#ifndef __StGermain_Base_Extensibility_Toolbox_h__
+#define __StGermain_Base_Extensibility_Toolbox_h__
/** The prototype for the Register function in a toolbox */
typedef Index (Toolbox_RegisterFunction) ( void* toolboxesManager );
@@ -67,15 +67,18 @@
Module* Toolbox_Factory( Name name, Stg_ObjectList* directories );
/* Creation implementation / Virtual constructor */
- Toolbox* _Toolbox_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Module_MangleNameFunction MangleName,
- Stg_ObjectList* directories );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define TOOLBOX_DEFARGS \
+ MODULE_DEFARGS
+
+ #define TOOLBOX_PASSARGS \
+ MODULE_PASSARGS
+
+ Toolbox* _Toolbox_New( TOOLBOX_DEFARGS );
/* Initialisation implementation */
void _Toolbox_Init( Toolbox* self );
@@ -98,4 +101,5 @@
/** Get the function pointer the to the toolbox's register function */
Toolbox_FinaliseFunction* Toolbox_GetFinaliseFunc( void* toolbox );
-#endif /* __Base_Extensibility_Toolbox_h__ */
+#endif /* __StGermain_Base_Extensibility_Toolbox_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ToolboxesManager.c
--- a/Base/Extensibility/src/ToolboxesManager.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ToolboxesManager.c Tue Jan 12 14:38:16 2010 +1100
@@ -42,53 +42,36 @@
#include "ToolboxesManager.h"
#include <stdlib.h>
+#include <string.h>
/* Textual name of this class */
const Type ToolboxesManager_Type = "ToolboxesManager";
ToolboxesManager* ToolboxesManager_New( int* argc, char*** argv ) {
- return _ToolboxesManager_New(
- sizeof(ToolboxesManager),
- ToolboxesManager_Type,
- _ToolboxesManager_Delete,
- _ToolboxesManager_Print,
- NULL,
- _ToolboxesManager_GetToolboxesList,
- _ToolboxesManager_LoadToolbox,
- _ToolboxesManager_UnloadToolbox,
- Toolbox_Factory,
- argc,
- argv );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(ToolboxesManager);
+ Type type = ToolboxesManager_Type;
+ Stg_Class_DeleteFunction* _delete = _ToolboxesManager_Delete;
+ Stg_Class_PrintFunction* _print = _ToolboxesManager_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ ModulesManager_GetModulesListFunction* _getModulesList = _ToolboxesManager_GetToolboxesList;
+ ModulesManager_LoadModuleFunction* _loadModule = _ToolboxesManager_LoadToolbox;
+ ModulesManager_UnloadModuleFunction* _unloadModule = _ToolboxesManager_UnloadToolbox;
+ ModulesManager_ModuleFactoryFunction* _moduleFactory = Toolbox_Factory;
+ ModulesManager_CheckContextFunction* _checkContext = _ToolboxesManager_CheckContext;
+ ModulesManager_GetModuleNameFunction* _getModuleName = _ToolboxesManager_GetModuleName;
+
+ return _ToolboxesManager_New( TOOLBOXESMANAGER_PASSARGS );
}
-ToolboxesManager* _ToolboxesManager_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ModulesManager_GetModulesListFunction* _getModulesList,
- ModulesManager_LoadModuleFunction* _loadModule,
- ModulesManager_UnloadModuleFunction* _unloadModule,
- ModulesManager_ModuleFactoryFunction* _moduleFactory,
- int* argc,
- char*** argv )
+ToolboxesManager* _ToolboxesManager_New( TOOLBOXESMANAGER_DEFARGS )
{
ToolboxesManager* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(ToolboxesManager) );
- self = (ToolboxesManager*)_ModulesManager_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _getModulesList,
- _loadModule,
- _unloadModule,
- _moduleFactory );
+ self = (ToolboxesManager*)_ModulesManager_New( MODULESMANAGER_PASSARGS );
/* General info */
@@ -112,14 +95,24 @@ void _ToolboxesManager_Init( void* toolb
void _ToolboxesManager_Delete( void* toolboxesManager ) {
ToolboxesManager* self = (ToolboxesManager*)toolboxesManager;
+ unsigned count;
+ /* free all strings, defining loaded Toolboxes */
+ for( count = 0 ; count < self->_initialisedCount ; count++ ) {
+ Memory_Free( self->initialised[count] );
+ }
Memory_Free( self->initialised );
self->_initialisedSize = 0;
self->_initialisedCount = 0;
self->initialised = 0;
+ Stg_ObjectList_DeleteAllObjects( self->codelets );
+ Stg_Class_Delete( self->codelets );
+ ModulesManager_Unload( self );
+ Stg_Class_Delete( self->modules );
+
/* Delete parent */
- _ModulesManager_Delete( self );
+ _Stg_Class_Delete( self );
}
void _ToolboxesManager_Print( void* toolboxesManager, Stream* stream ) {
@@ -169,6 +162,15 @@ Bool _ToolboxesManager_UnloadToolbox( vo
((Toolbox*)toolbox)->Finalise( self );
return True;
+}
+
+/* toolboxes do not need to be associated with contexts, so just return true */
+Bool _ToolboxesManager_CheckContext( void* toolboxesManager, Dictionary_Entry_Value* modulesVal, unsigned int entry_I, Name contextName ) {
+ return True;
+}
+
+Name _ToolboxesManager_GetModuleName( void* toolboxesManager, Dictionary_Entry_Value* moduleVal, unsigned int entry_I ) {
+ return Dictionary_Entry_Value_AsString( Dictionary_Entry_Value_GetElement( moduleVal, entry_I ) );
}
Index ToolboxesManager_SetInitialised( void* initRegister, char* label ) {
@@ -201,3 +203,6 @@ Bool ToolboxesManager_IsInitialised( voi
}
return False;
}
+
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/ToolboxesManager.h
--- a/Base/Extensibility/src/ToolboxesManager.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/ToolboxesManager.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_ToolboxesManager_h__
-#define __Base_Extensibility_ToolboxesManager_h__
+#ifndef __StGermain_Base_Extensibility_ToolboxesManager_h__
+#define __StGermain_Base_Extensibility_ToolboxesManager_h__
/* Textual name of this class */
@@ -69,18 +69,22 @@
ToolboxesManager* ToolboxesManager_New( int* argc, char*** argv );
/* Creation implementation / Virtual constructor */
- ToolboxesManager* _ToolboxesManager_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- ModulesManager_GetModulesListFunction* _getModulesList,
- ModulesManager_LoadModuleFunction* _loadModule,
- ModulesManager_UnloadModuleFunction* _unloadModule,
- ModulesManager_ModuleFactoryFunction* _moduleFactory,
- int* argc,
- char*** argv );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define TOOLBOXESMANAGER_DEFARGS \
+ MODULESMANAGER_DEFARGS, \
+ int* argc, \
+ char*** argv
+
+ #define TOOLBOXESMANAGER_PASSARGS \
+ MODULESMANAGER_PASSARGS, \
+ argc, \
+ argv
+
+ ToolboxesManager* _ToolboxesManager_New( TOOLBOXESMANAGER_DEFARGS );
/* Initialisation implementation */
void _ToolboxesManager_Init( void* toolboxesManager, int* argc, char*** argv );
@@ -100,6 +104,10 @@
/** Exactly what to do to unload the toolbox */
Bool _ToolboxesManager_UnloadToolbox( void* toolboxesManager, Module* toolbox );
+ Bool _ToolboxesManager_CheckContext( void* toolboxesManager, Dictionary_Entry_Value* modulesVal, unsigned int entry_I, Name contextName );
+
+ Name _ToolboxesManager_GetModuleName( void* toolboxesManager, Dictionary_Entry_Value* moduleVal, unsigned int entry_I );
+
#define ToolboxesManager_Submit ModulesManager_Submit
/** Let StGermain know that the "Init" function of a module has been called. This exists to handle the case where a module
@@ -111,5 +119,5 @@
function. */
Bool ToolboxesManager_IsInitialised( void* toolboxesManager, char* label );
+#endif /* __StGermain_Base_Extensibility_ToolboxesManager_h__ */
-#endif /* __Base_Extensibility_ToolboxesManager_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/shortcuts.h
--- a/Base/Extensibility/src/shortcuts.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/shortcuts.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_shortcuts_h__
-#define __Base_Extensibility_shortcuts_h__
+#ifndef __StGermain_Base_Extensibility_shortcuts_h__
+#define __StGermain_Base_Extensibility_shortcuts_h__
/** Macro to grab an extension from a named Stg_ObjectList */
#define ExtensionManager_FromList( extList, index ) \
@@ -187,5 +187,5 @@
#define EP_Purge( entryPoint ) \
EntryPoint_Purge( entryPoint )
-#endif /* __Base_Extensibility_shortcuts_h__ */
+#endif /* __StGermain_Base_Extensibility_shortcuts_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/src/types.h
--- a/Base/Extensibility/src/types.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/src/types.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Extensibility_types_h__
-#define __Base_Extensibility_types_h__
+#ifndef __StGermain_Base_Extensibility_types_h__
+#define __StGermain_Base_Extensibility_types_h__
/* Generic types */
/* Base types/classes */
@@ -53,7 +53,6 @@
typedef struct ExtensionManager ExtensionManager;
typedef struct ExtensionManager_Register ExtensionManager_Register;
typedef struct EntryPoint_Register EntryPoint_Register;
- typedef struct Codelet Codelet;
typedef struct Module Module;
typedef struct Plugin Plugin;
typedef struct Toolbox Toolbox;
@@ -83,4 +82,4 @@
typedef void* DLL_Handle;
typedef DLL_Handle* DLL_Handle_List;
-#endif /* __Base_Extensibility_types_h__ */
+#endif /* __StGermain_Base_Extensibility_types_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/tests/EntryPointSuite.c
--- a/Base/Extensibility/tests/EntryPointSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/tests/EntryPointSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -45,9 +45,9 @@ Stream* stream;
#define NUM_TEST_FUNCS 10
typedef struct {
- EntryPoint* ep;
- Bool testFuncsRan[NUM_TEST_FUNCS];
- unsigned int rank;
+ EntryPoint* ep;
+ Bool testFuncsRan[NUM_TEST_FUNCS];
+ int rank;
} EntryPointSuiteData;
void TestHook0( EntryPointSuiteData* data ) {
@@ -403,3 +403,5 @@ void EntryPointSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, EntryPointSuite_TestClassHook );
pcu_suite_addTest( suite, EntryPointSuite_TestMinMax );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Extensibility/tests/ExtensionSuite.c
--- a/Base/Extensibility/tests/ExtensionSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Extensibility/tests/ExtensionSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -697,3 +697,5 @@ void ExtensionSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, ExtensionSuite_TestExtendOfExtendedArray );
pcu_suite_addTest( suite, ExtensionSuite_TestCopyExtendedArray );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/FlattenXML/src/main.c
--- a/Base/FlattenXML/src/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/FlattenXML/src/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -90,3 +90,5 @@ int main( int argc, char* argv[] )
return 0; /* success */
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Class.c
--- a/Base/Foundation/src/Class.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Class.c Tue Jan 12 14:38:16 2010 +1100
@@ -99,8 +99,9 @@ void _Stg_Class_Delete( void* _class ) {
if( self->_deleteSelf ) {
Memory_CountDec( self );
+ Memory_Free( self );
if ( Memory_CountGet( self ) <= 0 ) {
- Memory_Free( self );
+ //Memory_Free( self );
}
}
}
@@ -118,7 +119,7 @@ void _Stg_Class_Print( void* _class, str
Journal_Printf( stream, "Stg_Class (ptr): %p\n", self );
Stream_Indent( stream );
- Journal_Printf( stream, "sizeOfSelf: %lu\n", self->_sizeOfSelf );
+ Journal_Printf( stream, "_sizeOfSelf: %lu\n", self->_sizeOfSelf );
Journal_Printf( stream, "_deleteSelf: %s\n", self->_deleteSelf ? "Yes" : "No" );
Journal_Printf( stream, "type: %s\n", self->type == Type_Invalid ? "Invalid" : self->type );
Journal_Printf( stream, "_delete (func ptr): %p\n", self->_delete );
@@ -201,6 +202,7 @@ void* _Stg_Class_Copy( void* _class, voi
newClass->_delete = self->_delete;
newClass->_print = self->_print;
newClass->_copy = self->_copy;
+ newClass->nRefs = self->nRefs;
return (void*)newClass;
}
@@ -233,3 +235,7 @@ void Stg_Class_RemoveRef( void* _class )
if( !(--self->nRefs) )
Stg_Class_Delete( self );
}
+
+
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Class.h
--- a/Base/Foundation/src/Class.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Class.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation_Class_h__
-#define __Base_Foundation_Class_h__
+#ifndef __StGermain_Base_Foundation_Class_h__
+#define __StGermain_Base_Foundation_Class_h__
/* Textual name of this class */
extern const Type Stg_Class_Type;
@@ -72,14 +72,14 @@
/* Class Administration members ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#define STG_CLASS_DEFARGS \
- SizeT sizeOfSelf, \
+ SizeT _sizeOfSelf, \
Type type, \
- Stg_Class_DeleteFunction* deleteFunc, \
- Stg_Class_PrintFunction* printFunc, \
- Stg_Class_CopyFunction* copyFunc
+ Stg_Class_DeleteFunction* _delete, \
+ Stg_Class_PrintFunction* _print, \
+ Stg_Class_CopyFunction* _copy
#define STG_CLASS_PASSARGS \
- sizeOfSelf, type, deleteFunc, printFunc, copyFunc
+ _sizeOfSelf, type, _delete, _print, _copy
/** Constructor interface. */
@@ -146,4 +146,4 @@
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#endif /* __Base_Foundation_Class_h__ */
+#endif /* __StGermain_Base_Foundation_Class_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/CommonRoutines.c
--- a/Base/Foundation/src/CommonRoutines.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/CommonRoutines.c Tue Jan 12 14:38:16 2010 +1100
@@ -303,3 +303,5 @@ unsigned int Stg_LongestMatchingSubseque
return lmsLength;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/CommonRoutines.h
--- a/Base/Foundation/src/CommonRoutines.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/CommonRoutines.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation_CommonRoutines_h__
-#define __Base_Foundation_CommonRoutines_h__
+#ifndef __StGermain_Base_Foundation_CommonRoutines_h__
+#define __StGermain_Base_Foundation_CommonRoutines_h__
#include <stdarg.h>
/** Global map from a Boolean's enum value to a string: for printing purposes */
@@ -73,4 +73,4 @@
* but possibly with gaps between occurrences of each character. */
unsigned int Stg_LongestMatchingSubsequenceLength( char* string1, char* string2, Bool caseSensitive ) ;
-#endif /* __Base_Foundation_CommonRoutines_h__ */
+#endif /* __StGermain_Base_Foundation_CommonRoutines_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Finalise.c
--- a/Base/Foundation/src/Finalise.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Finalise.c Tue Jan 12 14:38:16 2010 +1100
@@ -44,3 +44,5 @@ Bool BaseFoundation_Finalise( void ) {
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Finalise.h
--- a/Base/Foundation/src/Finalise.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Finalise.h Tue Jan 12 14:38:16 2010 +1100
@@ -40,9 +40,9 @@
**
**/
-#ifndef __Base_BaseFoundation_Finalise_h__
-#define __Base_BaseFoundation_Finalise_h__
+#ifndef __StGermain_Base_Foundation_Finalise_h__
+#define __StGermain_Base_Foundation_Finalise_h__
- Bool BaseFoundation_Finalise( void );
+ Bool Foundation_Finalise( void );
-#endif /* __Base_BaseFoundation_Finalise_h__ */
+#endif /* __StGermain_Base_Foundation_Finalise_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Foundation.h
--- a/Base/Foundation/src/Foundation.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Foundation.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation_h__
-#define __Base_Foundation_h__
+#ifndef __StGermain_Base_Foundation_h__
+#define __StGermain_Base_Foundation_h__
#include "types.h"
#include "shortcuts.h"
@@ -66,4 +66,4 @@
#include "Finalise.h"
#include "Log.h"
-#endif /* __Base_Foundation_h__ */
+#endif /* __StGermain_Base_Foundation_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Init.c
--- a/Base/Foundation/src/Init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Init.c Tue Jan 12 14:38:16 2010 +1100
@@ -37,6 +37,7 @@
#include "Init.h"
#include <stdio.h>
+#include <assert.h>
/* constants */
const int DEFAULT_LIST_INITIAL_SIZE = 8;
@@ -44,9 +45,12 @@ const int DEFAULT_LIST_DELTA = 8;
Bool BaseFoundation_Init( int* argc, char** argv[] ) {
stgMemory = Memory_Init();
+ assert( stgMemory );
Stg_TimeMonitor_Initialise();
Stg_MemMonitor_Initialise();
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Init.h
--- a/Base/Foundation/src/Init.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Init.h Tue Jan 12 14:38:16 2010 +1100
@@ -40,9 +40,9 @@
**
**/
-#ifndef __Base_BaseFoundation_Init_h__
-#define __Base_BaseFoundation_Init_h__
+#ifndef __StGermain_Base_Foundation_Init_h__
+#define __StGermain_Base_Foundation_Init_h__
- Bool BaseFoundation_Init( int* argc, char** argv[] );
-
-#endif /* __Base_BaseFoundation_Init_h__ */
+ Bool Foundation_Init( int* argc, char** argv[] );
+
+#endif /* __StGermain_Base_Foundation_Init_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Log.c
--- a/Base/Foundation/src/Log.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Log.c Tue Jan 12 14:38:16 2010 +1100
@@ -192,3 +192,5 @@ void stg_profile_Func( char func_name[],
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Log.h
--- a/Base/Foundation/src/Log.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Log.h Tue Jan 12 14:38:16 2010 +1100
@@ -23,8 +23,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __STG_BASE_FOUNDATION_SRC_LOG__
-#define __STG_BASE_FOUNDATION_SRC_LOG__
+#ifndef __StGermain_Base_Foundation_Log_h__
+#define __StGermain_Base_Foundation_Log_h__
void stg_log_printf( const char *format, ... );
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/MemMonitor.c
--- a/Base/Foundation/src/MemMonitor.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/MemMonitor.c Tue Jan 12 14:38:16 2010 +1100
@@ -262,3 +262,5 @@ void Stg_MemMonitor_ConvertBytesToPrinti
sprintf( unitString, "tb" );
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/MemMonitor.h
--- a/Base/Foundation/src/MemMonitor.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/MemMonitor.h Tue Jan 12 14:38:16 2010 +1100
@@ -28,8 +28,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Foundation_MemMonitor_h__
-#define __Base_Foundation_MemMonitor_h__
+#ifndef __StGermain_Base_Foundation_MemMonitor_h__
+#define __StGermain_Base_Foundation_MemMonitor_h__
extern double Stg_MemoryWatchCriteria;
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Memory.c
--- a/Base/Foundation/src/Memory.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Memory.c Tue Jan 12 14:38:16 2010 +1100
@@ -195,6 +195,7 @@ Memory* Memory_Init()
result->stgCurrentMemory = 0;
result->stgPeakMemory = 0;
+ stgMemory = result;
return result;
}
@@ -216,6 +217,7 @@ void Memory_Delete()
if( stgMemory->pointers != NULL){
BTree_Delete( stgMemory->pointers );
}
+ free( stgMemory );
}
@@ -1204,9 +1206,10 @@ void* _Memory_Realloc_3DArrayAs1D_Func(
/* This function should only be called on ptrs allocated by StGermain's Memory routines */
-void _Memory_Free_Func( void* ptr )
-{
+void _Memory_Free_Func( void* ptr ) {
+ #ifdef MEMORY_STATS
MemoryPointer* memoryPointer = NULL;
+ #endif
if( !ptr ) return;
@@ -1858,3 +1861,5 @@ void _Memory_OutOfMemoryErrorFunc( const
stgMemory->stgCurrentMemory );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Memory.h
--- a/Base/Foundation/src/Memory.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Memory.h Tue Jan 12 14:38:16 2010 +1100
@@ -67,8 +67,8 @@
**
**/
-#ifndef __Base_Foundation_Memory_h__
-#define __Base_Foundation_Memory_h__
+#ifndef __StGermain_Base_Foundation_Memory_h__
+#define __StGermain_Base_Foundation_Memory_h__
/** Textual name for Memory class. */
@@ -754,4 +754,4 @@
#define MemArray3D Memory_Alloc_3DArray
#define MemFree Memory_Free
-#endif /* __Base_Foundation_Memory_h__ */
+#endif /* __StGermain_Base_Foundation_Memory_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/MemoryField.c
--- a/Base/Foundation/src/MemoryField.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/MemoryField.c Tue Jan 12 14:38:16 2010 +1100
@@ -311,3 +311,5 @@ unsigned int _MemoryField_CalcLongestSub
return longestSubFieldNameLen;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/MemoryField.h
--- a/Base/Foundation/src/MemoryField.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/MemoryField.h Tue Jan 12 14:38:16 2010 +1100
@@ -46,8 +46,8 @@
**
**/
-#ifndef __Base_Foundation_MemoryField_h__
-#define __Base_Foundation_MemoryField_h__
+#ifndef __StGermain_Base_Foundation_MemoryField_h__
+#define __StGermain_Base_Foundation_MemoryField_h__
/** Textual name for MemoryField class. */
extern const Type MemoryField_Type;
@@ -134,4 +134,4 @@
unsigned int _MemoryField_CalcLongestSubFieldNameLen( MemoryField* memoryField );
-#endif /* __Base_Foundation_MemoryField_h__ */
+#endif /* __StGermain_Base_Foundation_MemoryField_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/MemoryPointer.c
--- a/Base/Foundation/src/MemoryPointer.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/MemoryPointer.c Tue Jan 12 14:38:16 2010 +1100
@@ -329,3 +329,5 @@ void MemoryPointer_Print_File_Func_Helpe
MemoryPointer_Print ( (MemoryPointer*) memoryPointer, arguments->printOptions );
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/MemoryPointer.h
--- a/Base/Foundation/src/MemoryPointer.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/MemoryPointer.h Tue Jan 12 14:38:16 2010 +1100
@@ -42,8 +42,8 @@
**
**/
-#ifndef __Base_Foundation_MemoryPointer_h__
-#define __Base_Foundation_MemoryPointer_h__
+#ifndef __StGermain_Base_Foundation_MemoryPointer_h__
+#define __StGermain_Base_Foundation_MemoryPointer_h__
/** Textual name for MemoryPointer class. */
extern const Type MemoryPointer_Type;
@@ -179,7 +179,7 @@
/** Displays all fields of a MemoryPointer. */
#define MemoryPointer_PrintAll( memoryPointer ) MemoryPointer_Print( memoryPointer, MEMORYPOINTER_ALL );
-#endif /* __Base_Foundation_MemoryPointer_h__ */
+#endif /* __StGermain_Base_Foundation_MemoryPointer_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/MemoryReport.c
--- a/Base/Foundation/src/MemoryReport.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/MemoryReport.c Tue Jan 12 14:38:16 2010 +1100
@@ -61,10 +61,8 @@ MemoryReport* MemoryReport_New( ) {
}
-void _MemoryReport_Init( MemoryReport* memoryReport )
-{
- char reportQueryName[1000];
- Index ii=0;
+void _MemoryReport_Init( MemoryReport* memoryReport ) {
+ Index ii=0;
memoryReport->groupCount = 0;
memoryReport->groupSize = MEMORYREPORT_SIZE;
@@ -78,13 +76,11 @@ void _MemoryReport_Init( MemoryReport* m
}
memoryReport->memoryManager = stgMemory; /* Use this as the default, unless user overrides */
-
memoryReport->reportField = MemoryField_New( "Report Query:" );
}
-void MemoryReport_Delete( MemoryReport* memoryReport )
-{
+void MemoryReport_Delete( MemoryReport* memoryReport ) {
Index i;
MemoryField_Delete( memoryReport->reportField );
@@ -273,3 +269,5 @@ const char* _MemoryReport_GetValue( Memo
}
return valueString;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/MemoryReport.h
--- a/Base/Foundation/src/MemoryReport.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/MemoryReport.h Tue Jan 12 14:38:16 2010 +1100
@@ -44,8 +44,8 @@
**
**/
-#ifndef __Base_Foundation_MemoryReport_h__
-#define __Base_Foundation_MemoryReport_h__
+#ifndef __StGermain_Base_Foundation_MemoryReport_h__
+#define __StGermain_Base_Foundation_MemoryReport_h__
/** Textual name for MemoryReport class. */
extern const Type MemoryReport_Type;
@@ -95,7 +95,7 @@
const char* _MemoryReport_GetValue( MemoryReport* memoryReport, MemoryReportGroup reportGroup, MemoryPointer* memPtr );
-#endif /* __Base_Foundation_MemoryReport_h__ */
+#endif /* __StGermain_Base_Foundation_MemoryReport_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/MemoryTag.h
--- a/Base/Foundation/src/MemoryTag.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/MemoryTag.h Tue Jan 12 14:38:16 2010 +1100
@@ -37,8 +37,8 @@
**
**/
-#ifndef __Base_Foundation_MemoryTag_h__
-#define __Base_Foundation_MemoryTag_h__
+#ifndef __StGermain_Base_Foundation_MemoryTag_h__
+#define __StGermain_Base_Foundation_MemoryTag_h__
/* Memory Header that is inserted into every malloc
* As this grows, we can move into separate file.
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/NamedObject_Register.c
--- a/Base/Foundation/src/NamedObject_Register.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/NamedObject_Register.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,31 +51,23 @@ const Type NamedObject_Register_Type = "
const Type NamedObject_Register_Type = "NamedObject_Register";
NamedObject_Register* NamedObject_Register_New( void ) {
- return _NamedObject_Register_New(
- sizeof(NamedObject_Register),
- NamedObject_Register_Type,
- _NamedObject_Register_Delete,
- _NamedObject_Register_Print,
- _NamedObject_Register_Copy );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(NamedObject_Register);
+ Type type = NamedObject_Register_Type;
+ Stg_Class_DeleteFunction* _delete = _NamedObject_Register_Delete;
+ Stg_Class_PrintFunction* _print = _NamedObject_Register_Print;
+ Stg_Class_CopyFunction* _copy = _NamedObject_Register_Copy;
+
+ return _NamedObject_Register_New( NAMEDOBJECT_REGISTER_PASSARGS );
}
-NamedObject_Register* _NamedObject_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
+NamedObject_Register* _NamedObject_Register_New( NAMEDOBJECT_REGISTER_DEFARGS )
{
NamedObject_Register* self;
/* Allocate memory/General info */
assert(_sizeOfSelf >= sizeof(NamedObject_Register));
- self = (NamedObject_Register*)_Stg_Class_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy );
+ self = (NamedObject_Register*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* Virtual info */
@@ -100,6 +92,16 @@ void _NamedObject_Register_Delete( void*
_Stg_Class_Delete( self );
}
+void NamedObject_Register_DeleteAll( void* reg ) {
+ /* Deletes all elements from register and then
+ deletes the register */
+ NamedObject_Register* self = (NamedObject_Register*)reg;
+
+ Stg_ObjectList_DeleteAllObjects( self->objects );
+
+ /* Stg_Class_Delete parent */
+ Stg_Class_Delete( self );
+}
void _NamedObject_Register_Print( void* namedObjectRegister, struct Stream* stream ) {
NamedObject_Register* self = (NamedObject_Register*)namedObjectRegister;
@@ -137,3 +139,5 @@ void* _NamedObject_Register_Copy( void*
/* Public member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/NamedObject_Register.h
--- a/Base/Foundation/src/NamedObject_Register.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/NamedObject_Register.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Foundation_NamedObject_Register_h__
-#define __Base_Foundation_NamedObject_Register_h__
+#ifndef __StGermain_Base_Foundation_NamedObject_Register_h__
+#define __StGermain_Base_Foundation_NamedObject_Register_h__
extern const Type NamedObject_Register_Type;
@@ -61,12 +61,18 @@
NamedObject_Register* NamedObject_Register_New( void );
- NamedObject_Register* _NamedObject_Register_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define NAMEDOBJECT_REGISTER_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define NAMEDOBJECT_REGISTER_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ NamedObject_Register* _NamedObject_Register_New( NAMEDOBJECT_REGISTER_DEFARGS );
void _NamedObject_Register_Init( NamedObject_Register* self );
@@ -79,6 +85,9 @@
/* Public member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+ /* Deletes all elements from register and then
+ deletes the register */
+ void NamedObject_Register_DeleteAll( void* reg );
#define NamedObject_Register_Add( self, nameObject ) \
( Stg_ObjectList_Append( (self)->objects, nameObject ) )
@@ -96,4 +105,5 @@
( Stg_ObjectList_PrintAllEntryNames( (self)->objects, stream ) )
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#endif /* __Base_Foundation_NamedObject_Register_h__ */
+#endif /* __StGermain_Base_Foundation_NamedObject_Register_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/NewClass.c
--- a/Base/Foundation/src/NewClass.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/NewClass.c Tue Jan 12 14:38:16 2010 +1100
@@ -54,10 +54,7 @@ void _NewClass_Destruct( void* _self ) {
#ifndef NDEBUG
if( ((NewClass*)self)->curAllocd != 0 ) {
- fprintf( stderr, "\nWhile destructing a class memory has been leaked.\n"
- "Class type: %s\n"
- "Memory leaked: %ld\n",
- self->type, self->curAllocd );
+ fprintf( stderr, "\nWhile destructing a class memory has been leaked.\n" "Class type: %s\n" "Memory leaked: %ld\n", self->type, self->curAllocd );
}
#endif
}
@@ -137,3 +134,5 @@ SizeT NewClass_GetMemUsage( const void*
Stg_Class_Delete( ptrs );
return mem;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/NewObject.c
--- a/Base/Foundation/src/NewObject.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/NewObject.c Tue Jan 12 14:38:16 2010 +1100
@@ -77,3 +77,5 @@ const char* NewObject_GetName( void* sel
return ((NewObject*)self)->name;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Numerics.c
--- a/Base/Foundation/src/Numerics.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Numerics.c Tue Jan 12 14:38:16 2010 +1100
@@ -45,3 +45,5 @@ Bool Num_InRange( double var, double low
Bool Num_InRange( double var, double low, double upp ) {
return (var >= low - Num_Epsilon && var <= upp + Num_Epsilon);
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Numerics.h
--- a/Base/Foundation/src/Numerics.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Numerics.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,12 +38,12 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Foundation_Numerics_h__
-#define __Base_Foundation_Numerics_h__
+#ifndef __StGermain_Base_Foundation_Numerics_h__
+#define __StGermain_Base_Foundation_Numerics_h__
extern const double Num_Epsilon;
Bool Num_Approx( double var, double val );
Bool Num_InRange( double var, double low, double upp );
-#endif /* __Base_Foundation_Numerics_h__ */
+#endif /* __StGermain_Base_Foundation_Numerics_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Object.c
--- a/Base/Foundation/src/Object.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Object.c Tue Jan 12 14:38:16 2010 +1100
@@ -50,20 +50,13 @@ Index _Stg_Object_Counter = 0;
Index _Stg_Object_Counter = 0;
static const char _Stg_Object_Unnamed[] = "Unnamed";
-Stg_Object* _Stg_Object_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- AllocationType nameAllocationType )
+Stg_Object* _Stg_Object_New( STG_OBJECT_DEFARGS )
{
Stg_Object* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(Stg_Object) );
- self = (Stg_Object*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (Stg_Object*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -187,3 +180,5 @@ Name Stg_Object_AppendSuffix( void* obje
return name;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/Object.h
--- a/Base/Foundation/src/Object.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/Object.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation_Object_h__
-#define __Base_Foundation_Object_h__
+#ifndef __StGermain_Base_Foundation_Object_h__
+#define __StGermain_Base_Foundation_Object_h__
/** Textual name for Stg_Object class. */
extern const Type Stg_Object_Type;
@@ -62,14 +62,22 @@
/** Constructor interface. */
- Stg_Object* _Stg_Object_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- AllocationType nameAllocationType );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STG_OBJECT_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ Name name, \
+ AllocationType nameAllocationType
+
+ #define STG_OBJECT_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ name, \
+ nameAllocationType
+
+ Stg_Object* _Stg_Object_New( STG_OBJECT_DEFARGS );
/** Init interface. */
void _Stg_Object_Init( Stg_Object* self, Name name, AllocationType nameAllocationType );
@@ -106,4 +114,5 @@
Name Stg_Object_AppendSuffix( void* object, Name suffix ) ;
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#endif /* __Base_Foundation_Object_h__ */
+#endif /* __StGermain_Base_Foundation_Object_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/ObjectAdaptor.c
--- a/Base/Foundation/src/ObjectAdaptor.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/ObjectAdaptor.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,20 +51,21 @@ const Type Stg_ObjectAdaptor_Type = "Stg
Stg_ObjectAdaptor* Stg_ObjectAdaptor_NewOfClass( void* dataPtr, Name name, Bool iOwn, Bool isGlobal ) {
- return _Stg_ObjectAdaptor_New(
- sizeof(Stg_ObjectAdaptor),
- Stg_ObjectAdaptor_Type,
- _Stg_ObjectAdaptor_Delete,
- _Stg_ObjectAdaptor_Print,
- _Stg_ObjectAdaptor_Copy,
- name,
- dataPtr,
- iOwn,
- isGlobal,
- True,
- NULL,
- NULL,
- NULL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Stg_ObjectAdaptor);
+ Type type = Stg_ObjectAdaptor_Type;
+ Stg_Class_DeleteFunction* _delete = _Stg_ObjectAdaptor_Delete;
+ Stg_Class_PrintFunction* _print = _Stg_ObjectAdaptor_Print;
+ Stg_Class_CopyFunction* _copy = _Stg_ObjectAdaptor_Copy;
+ Bool isStgClass = True;
+ Stg_ObjectAdaptor_DeletePointerFunction* ptrDelete = NULL;
+ Stg_ObjectAdaptor_PrintPointerFunction* ptrPrint = NULL;
+ Stg_ObjectAdaptor_CopyPointerFunction* ptrCopy = NULL;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _Stg_ObjectAdaptor_New( STG_OBJECTADAPTOR_PASSARGS );
}
@@ -95,20 +96,18 @@ Stg_ObjectAdaptor* Stg_ObjectAdaptor_New
Stg_ObjectAdaptor_PrintPointerFunction* ptrPrint,
Stg_ObjectAdaptor_CopyPointerFunction* ptrCopy )
{
- return _Stg_ObjectAdaptor_New(
- sizeof(Stg_ObjectAdaptor),
- Stg_ObjectAdaptor_Type,
- _Stg_ObjectAdaptor_Delete,
- _Stg_ObjectAdaptor_Print,
- _Stg_ObjectAdaptor_Copy,
- name,
- dataPtr,
- iOwn,
- isGlobal,
- False,
- ptrDelete,
- ptrPrint,
- ptrCopy );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Stg_ObjectAdaptor);
+ Type type = Stg_ObjectAdaptor_Type;
+ Stg_Class_DeleteFunction* _delete = _Stg_ObjectAdaptor_Delete;
+ Stg_Class_PrintFunction* _print = _Stg_ObjectAdaptor_Print;
+ Stg_Class_CopyFunction* _copy = _Stg_ObjectAdaptor_Copy;
+ Bool isStgClass = False;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ AllocationType nameAllocationType = NON_GLOBAL /* default value NON_GLOBAL */;
+
+ return _Stg_ObjectAdaptor_New( STG_OBJECTADAPTOR_PASSARGS );
}
@@ -139,26 +138,18 @@ void Stg_ObjectAdaptor_InitOfPointer(
}
-Stg_ObjectAdaptor* _Stg_ObjectAdaptor_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- void* dataPtr,
- Bool iOwn,
- Bool isGlobal,
- Bool isStgClass,
- Stg_ObjectAdaptor_DeletePointerFunction* ptrDelete,
- Stg_ObjectAdaptor_PrintPointerFunction* ptrPrint,
- Stg_ObjectAdaptor_CopyPointerFunction* ptrCopy )
+Stg_ObjectAdaptor* _Stg_ObjectAdaptor_New( STG_OBJECTADAPTOR_DEFARGS )
{
Stg_ObjectAdaptor* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(Stg_ObjectAdaptor) );
- self = (Stg_ObjectAdaptor*)_Stg_Object_New( _sizeOfSelf, type, _delete, _print, _copy, name, GLOBAL );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ nameAllocationType = GLOBAL;
+
+ self = (Stg_ObjectAdaptor*)_Stg_Object_New( STG_OBJECT_PASSARGS );
/* General info */
@@ -338,3 +329,5 @@ Bool Stg_ObjectAdaptor_IsStgClassFunc( v
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/ObjectAdaptor.h
--- a/Base/Foundation/src/ObjectAdaptor.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/ObjectAdaptor.h Tue Jan 12 14:38:16 2010 +1100
@@ -49,8 +49,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Automation_ObjectAdaptor_h__
-#define __Base_Automation_ObjectAdaptor_h__
+#ifndef __StGermain_Base_Automation_ObjectAdaptor_h__
+#define __StGermain_Base_Automation_ObjectAdaptor_h__
/** Delete/Print/Copy function prototypes for attached pointers (not StGermain classes) */
/** *Note*: this function should only delete extra memory allocated by the object, _not
@@ -119,20 +119,32 @@
/* Creation implementation */
- Stg_ObjectAdaptor* _Stg_ObjectAdaptor_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- void* dataPtr,
- Bool iOwn,
- Bool isGlobal,
- Bool isStgClass,
- Stg_ObjectAdaptor_DeletePointerFunction* ptrDelete,
- Stg_ObjectAdaptor_PrintPointerFunction* ptrPrint,
- Stg_ObjectAdaptor_CopyPointerFunction* ptrCopy );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STG_OBJECTADAPTOR_DEFARGS \
+ STG_OBJECT_DEFARGS, \
+ void* dataPtr, \
+ Bool iOwn, \
+ Bool isGlobal, \
+ Bool isStgClass, \
+ Stg_ObjectAdaptor_DeletePointerFunction* ptrDelete, \
+ Stg_ObjectAdaptor_PrintPointerFunction* ptrPrint, \
+ Stg_ObjectAdaptor_CopyPointerFunction* ptrCopy
+
+ #define STG_OBJECTADAPTOR_PASSARGS \
+ STG_OBJECT_PASSARGS, \
+ dataPtr, \
+ iOwn, \
+ isGlobal, \
+ isStgClass, \
+ ptrDelete, \
+ ptrPrint, \
+ ptrCopy
+
+ Stg_ObjectAdaptor* _Stg_ObjectAdaptor_New( STG_OBJECTADAPTOR_DEFARGS );
/* Initialisation implementation */
void _Stg_ObjectAdaptor_Init(
@@ -211,4 +223,5 @@
#endif
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#endif /* __Base_Automation_ObjectAdaptor_h__ */
+#endif /* __StGermain_Base_Automation_ObjectAdaptor_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/ObjectList.c
--- a/Base/Foundation/src/ObjectList.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/ObjectList.c Tue Jan 12 14:38:16 2010 +1100
@@ -52,27 +52,27 @@ const Type Stg_ObjectList_Type = "Stg_Ob
Stg_ObjectList* Stg_ObjectList_New2( Index initialSize, Index delta ) {
- return _Stg_ObjectList_New(
- sizeof(Stg_ObjectList),
- Stg_ObjectList_Type,
- _Stg_ObjectList_Delete,
- _Stg_ObjectList_Print,
- _Stg_ObjectList_Copy,
- _Stg_ObjectList_Append,
- _Stg_ObjectList_Prepend,
- _Stg_ObjectList_ReplaceAll,
- _Stg_ObjectList_Replace,
- _Stg_ObjectList_InsertBefore,
- _Stg_ObjectList_InsertAfter,
- _Stg_ObjectList_Remove,
- _Stg_ObjectList_GetIndex,
- _Stg_ObjectList_Get,
- _Stg_ObjectList_AllocMoreMemory,
- _Stg_ObjectList_InsertAtIndex,
- _Stg_ObjectList_RemoveByIndex,
- _Stg_ObjectList_DeleteAllObjects,
- initialSize,
- delta );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Stg_ObjectList);
+ Type type = Stg_ObjectList_Type;
+ Stg_Class_DeleteFunction* _delete = _Stg_ObjectList_Delete;
+ Stg_Class_PrintFunction* _print = _Stg_ObjectList_Print;
+ Stg_Class_CopyFunction* _copy = _Stg_ObjectList_Copy;
+ Stg_ObjectList_AppendFunction* _append = _Stg_ObjectList_Append;
+ Stg_ObjectList_PrependFunction* _prepend = _Stg_ObjectList_Prepend;
+ Stg_ObjectList_ReplaceAllFunction* _replaceAll = _Stg_ObjectList_ReplaceAll;
+ Stg_ObjectList_ReplaceFunction* _replace = _Stg_ObjectList_Replace;
+ Stg_ObjectList_InsertBeforeFunction* _insertBefore = _Stg_ObjectList_InsertBefore;
+ Stg_ObjectList_InsertAfterFunction* _insertAfter = _Stg_ObjectList_InsertAfter;
+ Stg_ObjectList_RemoveFunction* _remove = _Stg_ObjectList_Remove;
+ Stg_ObjectList_GetIndexFunction* _getIndex = _Stg_ObjectList_GetIndex;
+ Stg_ObjectList_GetFunction* _get = _Stg_ObjectList_Get;
+ Stg_ObjectList_AllocMoreMemoryFunction* _allocMoreMemory = _Stg_ObjectList_AllocMoreMemory;
+ Stg_ObjectList_InsertAtIndexFunction* _insertAtIndex = _Stg_ObjectList_InsertAtIndex;
+ Stg_ObjectList_RemoveByIndexFunction* _removeByIndex = _Stg_ObjectList_RemoveByIndex;
+ Stg_ObjectList_DeleteAllObjectsFunction* _deleteAllObjects = _Stg_ObjectList_DeleteAllObjects;
+
+ return _Stg_ObjectList_New( STG_OBJECTLIST_PASSARGS );
}
@@ -106,33 +106,13 @@ void Stg_ObjectList_Init2( Stg_ObjectLis
/* Creation implementation */
-Stg_ObjectList* _Stg_ObjectList_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_ObjectList_AppendFunction* _append,
- Stg_ObjectList_PrependFunction* _prepend,
- Stg_ObjectList_ReplaceAllFunction* _replaceAll,
- Stg_ObjectList_ReplaceFunction* _replace,
- Stg_ObjectList_InsertBeforeFunction* _insertBefore,
- Stg_ObjectList_InsertAfterFunction* _insertAfter,
- Stg_ObjectList_RemoveFunction* _remove,
- Stg_ObjectList_GetIndexFunction* _getIndex,
- Stg_ObjectList_GetFunction* _get,
- Stg_ObjectList_AllocMoreMemoryFunction* _allocMoreMemory,
- Stg_ObjectList_InsertAtIndexFunction* _insertAtIndex,
- Stg_ObjectList_RemoveByIndexFunction* _removeByIndex,
- Stg_ObjectList_DeleteAllObjectsFunction* _deleteAllObjects,
- Index initialSize,
- Index delta )
+Stg_ObjectList* _Stg_ObjectList_New( STG_OBJECTLIST_DEFARGS )
{
Stg_ObjectList* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(Stg_ObjectList) );
- self = (Stg_ObjectList*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (Stg_ObjectList*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* Virtual functions */
self->_append = _append;
@@ -532,14 +512,14 @@ Index Stg_ObjectList_Remove( void* objec
return self->_remove( self, reference, option );
}
-Index Stg_ObjectList_GetIndex( void* objectList, const Name const toGet ) {
+Index Stg_ObjectList_GetIndex( void* objectList, const Name toGet ) {
Stg_ObjectList* self = (Stg_ObjectList*) objectList;
return self->_getIndex( self, toGet );
}
-void* Stg_ObjectList_Get( void* objectList, const Name const objectName ) {
+void* Stg_ObjectList_Get( void* objectList, const Name objectName ) {
Stg_ObjectList* self = (Stg_ObjectList*) objectList;
return self->_get( self, objectName );
@@ -748,7 +728,7 @@ Index _Stg_ObjectList_Remove( void* name
}
-Index _Stg_ObjectList_GetIndex( void* namedObjectList, const Name const toGet ) {
+Index _Stg_ObjectList_GetIndex( void* namedObjectList, const Name toGet ) {
Stg_ObjectList* self = (Stg_ObjectList*) namedObjectList;
Index objectIndex;
@@ -764,7 +744,7 @@ Index _Stg_ObjectList_GetIndex( void* na
}
-void* _Stg_ObjectList_Get( void* objectList, const Name const toGet ) {
+void* _Stg_ObjectList_Get( void* objectList, const Name toGet ) {
Stg_ObjectList* self = (Stg_ObjectList*) objectList;
Index objectIndex;
@@ -803,6 +783,7 @@ void _Stg_ObjectList_DeleteAllObjects( v
self->data[objectIndex] = 0;
}
}
+ self->count = 0;
}
@@ -889,3 +870,5 @@ void Stg_ObjectList_PrintSimilar( void*
Memory_Free( similarityArray );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/ObjectList.h
--- a/Base/Foundation/src/ObjectList.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/ObjectList.h Tue Jan 12 14:38:16 2010 +1100
@@ -62,8 +62,8 @@
**
**/
-#ifndef __Base_Foundation_Stg_ObjectList_h__
-#define __Base_Foundation_Stg_ObjectList_h__
+#ifndef __StGermain_Base_Foundation_Stg_ObjectList_h__
+#define __StGermain_Base_Foundation_Stg_ObjectList_h__
/* function prototype interface */
typedef Index (Stg_ObjectList_AppendFunction) ( void* objects, void* objectPtr );
@@ -73,8 +73,8 @@
typedef Index (Stg_ObjectList_InsertBeforeFunction) ( void* objects, Name reference, void* objectPtr );
typedef Index (Stg_ObjectList_InsertAfterFunction) ( void* objects, Name reference, void* objectPtr );
typedef Index (Stg_ObjectList_RemoveFunction) ( void* objects, Name reference, ReplacementOption option );
- typedef Index (Stg_ObjectList_GetIndexFunction) ( void* objects, const Name const toGet );
- typedef void* (Stg_ObjectList_GetFunction) ( void* objects, const Name const toGet );
+ typedef Index (Stg_ObjectList_GetIndexFunction) ( void* objects, const Name toGet );
+ typedef void* (Stg_ObjectList_GetFunction) ( void* objects, const Name toGet );
typedef void (Stg_ObjectList_AllocMoreMemoryFunction) ( void* objects );
typedef void (Stg_ObjectList_InsertAtIndexFunction) ( void* objects, Index index, void* objectPtr );
typedef void (Stg_ObjectList_RemoveByIndexFunction) ( void* objects, Index index, ReplacementOption option );
@@ -82,7 +82,7 @@
/** Textual name of this class */
extern const Type Stg_ObjectList_Type;
-
+
extern const int DEFAULT_LIST_INITIAL_SIZE;
extern const int DEFAULT_LIST_DELTA;
@@ -132,27 +132,48 @@
void Stg_ObjectList_Init2( Stg_ObjectList* self, Index initialSize, Index delta );
/** Creation implementation */
- Stg_ObjectList* _Stg_ObjectList_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_ObjectList_AppendFunction* _append,
- Stg_ObjectList_PrependFunction* _prepend,
- Stg_ObjectList_ReplaceAllFunction* _replaceAll,
- Stg_ObjectList_ReplaceFunction* _replace,
- Stg_ObjectList_InsertBeforeFunction* _insertBefore,
- Stg_ObjectList_InsertAfterFunction* _insertAfter,
- Stg_ObjectList_RemoveFunction* _remove,
- Stg_ObjectList_GetIndexFunction* _getIndex,
- Stg_ObjectList_GetFunction* _get,
- Stg_ObjectList_AllocMoreMemoryFunction* _allocMoreMemory,
- Stg_ObjectList_InsertAtIndexFunction* _insertAtIndex,
- Stg_ObjectList_RemoveByIndexFunction* _removeByIndex,
- Stg_ObjectList_DeleteAllObjectsFunction* _deleteAllObjects,
- Index initialSize,
- Index delta );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STG_OBJECTLIST_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ Stg_ObjectList_AppendFunction* _append, \
+ Stg_ObjectList_PrependFunction* _prepend, \
+ Stg_ObjectList_ReplaceAllFunction* _replaceAll, \
+ Stg_ObjectList_ReplaceFunction* _replace, \
+ Stg_ObjectList_InsertBeforeFunction* _insertBefore, \
+ Stg_ObjectList_InsertAfterFunction* _insertAfter, \
+ Stg_ObjectList_RemoveFunction* _remove, \
+ Stg_ObjectList_GetIndexFunction* _getIndex, \
+ Stg_ObjectList_GetFunction* _get, \
+ Stg_ObjectList_AllocMoreMemoryFunction* _allocMoreMemory, \
+ Stg_ObjectList_InsertAtIndexFunction* _insertAtIndex, \
+ Stg_ObjectList_RemoveByIndexFunction* _removeByIndex, \
+ Stg_ObjectList_DeleteAllObjectsFunction* _deleteAllObjects, \
+ Index initialSize, \
+ Index delta
+
+ #define STG_OBJECTLIST_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ _append, \
+ _prepend, \
+ _replaceAll, \
+ _replace, \
+ _insertBefore, \
+ _insertAfter, \
+ _remove, \
+ _getIndex, \
+ _get, \
+ _allocMoreMemory, \
+ _insertAtIndex, \
+ _removeByIndex, \
+ _deleteAllObjects, \
+ initialSize, \
+ delta
+
+ Stg_ObjectList* _Stg_ObjectList_New( STG_OBJECTLIST_DEFARGS );
/** Initialisation implementation */
void _Stg_ObjectList_Init( Stg_ObjectList* self, Index initialSize, Index delta );
@@ -310,10 +331,10 @@
Index Stg_ObjectList_Remove( void* objectList, Name reference, ReplacementOption option ) ;
/** Find an object's index in the list, by name. Returns (unsigned)-1 if not found. */
- Index Stg_ObjectList_GetIndex( void* objectList, const Name const toGet );
+ Index Stg_ObjectList_GetIndex( void* objectList, const Name toGet );
/** Get an object's ptr from the list, by name. Returns NULL if not found. */
- void* Stg_ObjectList_Get( void* objectList, const Name const toGet );
+ void* Stg_ObjectList_Get( void* objectList, const Name toGet );
/** Deletes all the objects in the list. */
void Stg_ObjectList_DeleteAllObjects( void* objectList );
@@ -400,4 +421,5 @@
/** Prints the first 'number' of names of objects in list which are most similar to 'name' */
void Stg_ObjectList_PrintSimilar( void* objectList, Name name, void* _stream, unsigned int number ) ;
-#endif /* __Base_Foundation_Stg_ObjectList_h__ */
+#endif /* __StGermain_Base_Foundation_Stg_ObjectList_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/PrimitiveObject.c
--- a/Base/Foundation/src/PrimitiveObject.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/PrimitiveObject.c Tue Jan 12 14:38:16 2010 +1100
@@ -46,72 +46,212 @@
const Type Stg_PrimitiveObject_Type = "Stg_PrimitiveObject";
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_UnsignedChar( unsigned char value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_UnsignedChar( unsigned char value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_UnsignedChar;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asUnsignedChar = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_UnsignedChar, v, name );
+ v.asUnsignedChar = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_UnsignedShort( unsigned short value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_UnsignedShort( unsigned short value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_UnsignedShort;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asUnsignedShort = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_UnsignedShort, v, name );
+ v.asUnsignedShort = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_UnsignedInt( unsigned int value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_UnsignedInt( unsigned int value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_UnsignedInt;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asUnsignedInt = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_UnsignedInt, v, name );
+ v.asUnsignedInt = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_UnsignedLong( unsigned long value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_UnsignedLong( unsigned long value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_UnsignedLong;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asUnsignedLong = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_UnsignedLong, v, name );
+ v.asUnsignedLong = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_Char( char value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_Char( char value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_Char;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asChar = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_Char, v, name );
+ v.asChar = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_Short( short value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_Short( short value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_Short;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asShort = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_Short, v, name );
+ v.asShort = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_Int( int value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_Int( int value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_Int;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asInt = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_Int, v, name );
+ v.asInt = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_Long( long value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_Long( long value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_Long;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asLong = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_Long, v, name );
+ v.asLong = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_Float( float value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_Float( float value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_Float;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asFloat = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_Float, v, name );
+ v.asFloat = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* Stg_PrimitiveObject_New_Double( double value, Name name ) {
+Stg_PrimitiveObject* Stg_PrimitiveObject_New_Double( double value_renamed, Name name ) {
+ /* Variables set in this function */
+ Stg_C_Primitive_Type dataType = Stg_C_Primitive_Type_Double;
+
+ /* Variables that are set to ZERO are variables that will be set either by the current _New function or another parent _New function further up the hierachy */
+ SizeT _sizeOfSelf = ZERO;
+ Type type = ZERO;
+ Stg_Class_DeleteFunction* _delete = ZERO;
+ Stg_Class_PrintFunction* _print = ZERO;
+ Stg_Class_CopyFunction* _copy = ZERO;
+ AllocationType nameAllocationType = ZERO;
+
Stg_C_Primitive v;
- v.asDouble = value;
- return _Stg_PrimitiveObject_New( Stg_C_Primitive_Type_Double, v, name );
+ v.asDouble = value_renamed;
+ /* The following terms are parameters that have been passed into or defined in this function but are being set before being passed onto the parent */
+ Stg_C_Primitive value = v;
+
+ return _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_PASSARGS );
}
-Stg_PrimitiveObject* _Stg_PrimitiveObject_New(
- Stg_C_Primitive_Type dataType,
- Stg_C_Primitive value,
- Name name )
+Stg_PrimitiveObject* _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_DEFARGS )
{
Stg_PrimitiveObject* result;
- result = (Stg_PrimitiveObject*)_Stg_Object_New(
- sizeof(Stg_PrimitiveObject),
- Stg_PrimitiveObject_Type,
- _Stg_PrimitiveObject_Delete,
- _Stg_PrimitiveObject_Print,
- _Stg_PrimitiveObject_Copy,
- name,
- NON_GLOBAL );
+ /* The following terms are parameters that have been passed into this function but are being set before being passed onto the parent */
+ /* This means that any values of these parameters that are passed into this function are not passed onto the parent function
+ and so should be set to ZERO in any children of this class. */
+ _sizeOfSelf = sizeof(Stg_PrimitiveObject);
+ type = Stg_PrimitiveObject_Type;
+ _delete = _Stg_PrimitiveObject_Delete;
+ _print = _Stg_PrimitiveObject_Print;
+ _copy = _Stg_PrimitiveObject_Copy;
+ nameAllocationType = NON_GLOBAL;
+
+ result = (Stg_PrimitiveObject*)_Stg_Object_New( STG_OBJECT_PASSARGS );
_Stg_PrimitiveObject_Init( result, dataType, value );
@@ -227,3 +367,5 @@ void* _Stg_PrimitiveObject_Copy( void* p
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/PrimitiveObject.h
--- a/Base/Foundation/src/PrimitiveObject.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/PrimitiveObject.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Foundation_PrimitiveObject_h__
-#define __Base_Foundation_PrimitiveObject_h__
+#ifndef __StGermain_Base_Foundation_PrimitiveObject_h__
+#define __StGermain_Base_Foundation_PrimitiveObject_h__
extern const Type Stg_PrimitiveObject_Type;
@@ -92,10 +92,22 @@
Stg_PrimitiveObject* Stg_PrimitiveObject_New_Float( float value, Name name );
Stg_PrimitiveObject* Stg_PrimitiveObject_New_Double( double value, Name name );
- Stg_PrimitiveObject* _Stg_PrimitiveObject_New(
- Stg_C_Primitive_Type dataType,
- Stg_C_Primitive value,
- Name name );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STG_PRIMITIVEOBJECT_DEFARGS \
+ STG_OBJECT_DEFARGS, \
+ Stg_C_Primitive_Type dataType, \
+ Stg_C_Primitive value
+
+ #define STG_PRIMITIVEOBJECT_PASSARGS \
+ STG_OBJECT_PASSARGS, \
+ dataType, \
+ value
+
+ Stg_PrimitiveObject* _Stg_PrimitiveObject_New( STG_PRIMITIVEOBJECT_DEFARGS );
void _Stg_PrimitiveObject_Init(
@@ -114,5 +126,6 @@
void* _Stg_PrimitiveObject_Copy( void* objectAdaptor, void* dest, Bool deep, Name nameExt, struct PtrMap* ptrMap );
-#endif /* __Base_Foundation_PrimitiveObject_h__ */
+#endif /* __StGermain_Base_Foundation_PrimitiveObject_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/TestSuite.c
--- a/Base/Foundation/src/TestSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/TestSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -52,19 +52,22 @@ const Type TestSuite_Type = "TestSuite";
*/
TestSuite* TestSuite_New() {
- return _TestSuite_New( sizeof(TestSuite),
- TestSuite_Type,
- _TestSuite_Delete,
- _TestSuite_Print,
- _TestSuite_Copy );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(TestSuite);
+ Type type = TestSuite_Type;
+ Stg_Class_DeleteFunction* _delete = _TestSuite_Delete;
+ Stg_Class_PrintFunction* _print = _TestSuite_Print;
+ Stg_Class_CopyFunction* _copy = _TestSuite_Copy;
+
+ return _TestSuite_New( TESTSUITE_PASSARGS );
}
-TestSuite* _TestSuite_New( TESTSUITE_DEFARGS ) {
+TestSuite* _TestSuite_New( TESTSUITE_DEFARGS ) {
TestSuite* self;
/* Allocate memory */
- assert( sizeOfSelf >= sizeof(TestSuite) );
- self = (TestSuite*)_Stg_Class_New( STG_CLASS_PASSARGS );
+ assert( _sizeOfSelf >= sizeof(TestSuite) );
+ self = (TestSuite*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* Virtual info */
@@ -194,3 +197,5 @@ void TestSuite_Destruct( TestSuite* self
self->nTests = 0;
KillArray( self->tests );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/TestSuite.h
--- a/Base/Foundation/src/TestSuite.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/TestSuite.h Tue Jan 12 14:38:16 2010 +1100
@@ -76,14 +76,21 @@
** Constructors
*/
+
+
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
#define TESTSUITE_DEFARGS \
- STG_CLASS_DEFARGS
+ STG_CLASS_DEFARGS
#define TESTSUITE_PASSARGS \
- STG_CLASS_PASSARGS
+ STG_CLASS_PASSARGS
TestSuite* TestSuite_New();
- TestSuite* _TestSuite_New( TESTSUITE_DEFARGS );
+ TestSuite* _TestSuite_New( TESTSUITE_DEFARGS );
void _TestSuite_Init( TestSuite* self );
/*--------------------------------------------------------------------------------------------------------------------------
@@ -113,3 +120,4 @@
void TestSuite_Destruct( TestSuite* self );
#endif /* __StGermain_Base_Foundation_TestSuite_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/TimeMonitor.c
--- a/Base/Foundation/src/TimeMonitor.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/TimeMonitor.c Tue Jan 12 14:38:16 2010 +1100
@@ -169,3 +169,5 @@ double Stg_TimeMonitor_End( Stg_TimeMoni
return tmData->aveProcDt;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/TimeMonitor.h
--- a/Base/Foundation/src/TimeMonitor.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/TimeMonitor.h Tue Jan 12 14:38:16 2010 +1100
@@ -28,8 +28,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_Foundation_TimeMonitor_h__
-#define __Base_Foundation_TimeMonitor_h__
+#ifndef __StGermain_Base_Foundation_TimeMonitor_h__
+#define __StGermain_Base_Foundation_TimeMonitor_h__
extern double Stg_TimeMonitor_t0;
extern double Stg_TimerWatchCriteria;
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/debug.c
--- a/Base/Foundation/src/debug.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/debug.c Tue Jan 12 14:38:16 2010 +1100
@@ -33,3 +33,5 @@
Bool assert_jmpEnabled = False;
jmp_buf assert_env;
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/forwardDecl.h
--- a/Base/Foundation/src/forwardDecl.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/forwardDecl.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
* the StGermain framework.
*/
-#ifndef __Base_Foundation_forwardDecl_h__
-#define __Base_Foundation_forwardDecl_h__
+#ifndef __StGermain_Base_Foundation_forwardDecl_h__
+#define __StGermain_Base_Foundation_forwardDecl_h__
/* Forward Declaration of Stream ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/shortcuts.h
--- a/Base/Foundation/src/shortcuts.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/shortcuts.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation_shortcuts_h__
-#define __Base_Foundation_shortcuts_h__
+#ifndef __StGermain_Base_Foundation_shortcuts_h__
+#define __StGermain_Base_Foundation_shortcuts_h__
/* If the system does not have these macros, define it here */
#ifndef MAX
@@ -160,7 +160,7 @@
} while( 0 )
#define FreeObject( obj ) \
- if( obj ) Stg_Class_Delete( obj )
+ if( obj ) (Stg_Class_Delete( obj ), (obj) = NULL)
#define KillObject( obj ) \
if( obj ) (Stg_Class_Delete( obj ), (obj) = NULL)
@@ -172,4 +172,4 @@
#define insist( stmnt, expr ) stmnt
#endif
-#endif /* __Base_Foundation_shortcuts_h__ */
+#endif /* __StGermain_Base_Foundation_shortcuts_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/src/types.h
--- a/Base/Foundation/src/types.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/src/types.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_Foundation_types_h__
-#define __Base_Foundation_types_h__
+#ifndef __StGermain_Base_Foundation_types_h__
+#define __StGermain_Base_Foundation_types_h__
/*
* #ifdef barrier for Bool type. Added 07-Sep-2004 -- Alan
@@ -125,4 +125,4 @@ typedef struct NewObject NewObject;
DELETE
} ReplacementOption;
-#endif /* __Base_Foundation_types_h__ */
+#endif /* __StGermain_Base_Foundation_types_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/CommonRoutinesSuite.c
--- a/Base/Foundation/tests/CommonRoutinesSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/tests/CommonRoutinesSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -71,7 +71,7 @@ void CommonRoutinesSuite_Teardown( Commo
}
-CommonRoutinesSuite_TestLMS( CommonRoutinesSuiteData* data ) {
+void CommonRoutinesSuite_TestLMS( CommonRoutinesSuiteData* data ) {
pcu_check_true( 1 == Stg_LongestMatchingSubsequenceLength( "Acrobat", "BOAT", True ) );
pcu_check_true( 6 == Stg_LongestMatchingSubsequenceLength( "Abracadabra", "Yabbadabbadoo", True ) );
pcu_check_true( 7 == Stg_LongestMatchingSubsequenceLength( "Abracadabra", "Yabbadabbadoo", False ) );
@@ -79,7 +79,7 @@ CommonRoutinesSuite_TestLMS( CommonRouti
}
-CommonRoutinesSuite_TestStringIsNumeric( CommonRoutinesSuiteData* data ) {
+void CommonRoutinesSuite_TestStringIsNumeric( CommonRoutinesSuiteData* data ) {
pcu_check_true( False == Stg_StringIsNumeric( "nan" ) );
pcu_check_true( True == Stg_StringIsNumeric( "567" ) );
pcu_check_true( True == Stg_StringIsNumeric( "1.0e90" ) );
@@ -90,7 +90,7 @@ CommonRoutinesSuite_TestStringIsNumeric(
}
-CommonRoutinesSuite_TestStringIsEmpty( CommonRoutinesSuiteData* data ) {
+void CommonRoutinesSuite_TestStringIsEmpty( CommonRoutinesSuiteData* data ) {
pcu_check_true( True == Stg_StringIsEmpty( "\t \n" ) );
pcu_check_true( False == Stg_StringIsEmpty( "asdf" ) );
pcu_check_true( True == Stg_StringIsEmpty( " " ) );
@@ -99,7 +99,7 @@ CommonRoutinesSuite_TestStringIsEmpty( C
}
-CommonRoutinesSuite_TestStG_RoundDoubleToNDecimalPlaces( CommonRoutinesSuiteData* data ) {
+void CommonRoutinesSuite_TestStG_RoundDoubleToNDecimalPlaces( CommonRoutinesSuiteData* data ) {
double roundedValue;
double errorMargin;
Index testValue_I;
@@ -126,7 +126,7 @@ CommonRoutinesSuite_TestStG_RoundDoubleT
}
-CommonRoutinesSuite_TestStG_RoundDoubleToNSigFigs( CommonRoutinesSuiteData* data ) {
+void CommonRoutinesSuite_TestStG_RoundDoubleToNSigFigs( CommonRoutinesSuiteData* data ) {
double roundedValue;
double errorMargin;
Index testValue_I;
@@ -161,3 +161,5 @@ void CommonRoutinesSuite( pcu_suite_t* s
pcu_suite_addTest( suite, CommonRoutinesSuite_TestStG_RoundDoubleToNDecimalPlaces );
pcu_suite_addTest( suite, CommonRoutinesSuite_TestStG_RoundDoubleToNSigFigs );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/MemMonitorSuite.c
--- a/Base/Foundation/tests/MemMonitorSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/tests/MemMonitorSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -43,8 +43,8 @@
typedef struct {
- Stg_MemMonitor* mm;
- unsigned int rank;
+ Stg_MemMonitor* mm;
+ int rank;
} MemMonitorSuiteData;
@@ -167,3 +167,5 @@ void MemMonitorSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, MemMonitorSuite_TestMonitor );
#endif
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/MemoryReportSuite.c
--- a/Base/Foundation/tests/MemoryReportSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/tests/MemoryReportSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -64,7 +64,7 @@ typedef struct {
typedef struct {
Memory* savedStgMemory;
MemoryReport* report;
- unsigned int rank;
+ int rank;
void* bytesObj;
void* bytesArray;
StructA* object;
@@ -570,3 +570,5 @@ void MemoryReportSuite( pcu_suite_t* sui
pcu_suite_addTest( suite, MemoryReportSuite_TestReportPrintsFour );
#endif
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/MemorySuite.c
--- a/Base/Foundation/tests/MemorySuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/tests/MemorySuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -61,7 +61,9 @@ void MemorySuite_Test2DArray( MemorySuit
double** array2d = NULL;
Index ii = 0;
Index jj = 0;
+ #ifdef MEMORY_STATS
MemoryPointer* memoryPtr;
+ #endif
array2d = Memory_Alloc_2DArray_Unnamed( double, 2, 3 );
pcu_check_true( NULL != array2d );
@@ -454,3 +456,5 @@ void MemorySuite( pcu_suite_t* suite ) {
pcu_suite_addTest( suite, MemorySuite_Test2DComplexArray );
pcu_suite_addTest( suite, MemorySuite_Test3DComplexArray );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/NamedObject_Register2Suite.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Foundation/tests/NamedObject_Register2Suite.c Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,115 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: testFieldVariable_Register.c 2432 2004-12-16 23:01:59Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+
+#include "pcu/pcu.h"
+#include "StGermain/Base/Foundation/Foundation.h"
+#include "StGermain/Base/Foundation/forwardDecl.h" /* For Journal stuff */
+#include "NamedObject_RegisterSuite.h"
+#include "NamedObject_Register2Suite.h"
+
+typedef struct {
+ __Stg_Object
+} TestObject2;
+
+Stg_Object* TestObject2_New( Name name ) {
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( TestObject2 );
+ Type type = "TestObject";
+ Stg_Class_DeleteFunction* _delete = _Stg_Object_Delete;
+ Stg_Class_PrintFunction* _print = _Stg_Object_Print;
+ Stg_Class_CopyFunction* _copy = _Stg_Object_Copy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+
+ return _Stg_Object_New( STG_OBJECT_PASSARGS );
+}
+
+typedef struct {
+ NamedObject_Register* reg;
+ Stg_Object** testObjects;
+ char** testObjectNames;
+ Index testObjectsCount;
+} NamedObject_RegisterSuite2Data;
+
+void NamedObject_RegisterSuite2_Setup( NamedObject_RegisterSuite2Data* data ) {
+ Index ii=0;
+ char letter='0';
+
+ data->reg = NamedObject_Register_New();
+ data->testObjectsCount = 5;
+ data->testObjectNames = malloc(sizeof(char*) * data->testObjectsCount);
+ data->testObjects = malloc(sizeof(Stg_Object*) * data->testObjectsCount);
+
+ letter='a';
+ for (ii=0; ii < data->testObjectsCount; ii++ ) {
+ data->testObjectNames[ii] = malloc(sizeof(char) * 2 );
+ sprintf( data->testObjectNames[ii], "%c", letter );
+ letter++;
+ data->testObjects[ii] = TestObject2_New( data->testObjectNames[ii] );
+ }
+}
+
+void NamedObject_RegisterSuite2_Teardown( NamedObject_RegisterSuite2Data* data ) {
+ Index ii;
+
+ for (ii=0; ii < data->testObjectsCount; ii++ ) {
+ free( data->testObjectNames[ii] );
+ }
+ free( data->testObjects );
+ free( data->testObjectNames );
+}
+
+void NamedObject_RegisterSuite2_TestDeleteAll( NamedObject_RegisterSuite2Data* data ) {
+ Index ii;
+
+ pcu_docstring( "Tests a series of new objects can be added to a register, and the register's data "
+ "fields are updated correctly" );
+
+ for (ii=0; ii < data->testObjectsCount; ii++ ) {
+ NamedObject_Register_Add( data->reg, data->testObjects[ii] );
+ }
+
+ pcu_check_true( data->testObjectsCount == data->reg->objects->count );
+ for (ii=0; ii < data->testObjectsCount; ii++ ) {
+ pcu_check_true( data->testObjects[ii] == data->reg->objects->data[ii] );
+ }
+
+ NamedObject_Register_DeleteAll( data->reg );
+}
+
+
+void NamedObject_Register2Suite( pcu_suite_t* suite ) {
+ pcu_suite_setData( suite, NamedObject_RegisterSuite2Data );
+ pcu_suite_setFixtures( suite, NamedObject_RegisterSuite2_Setup, NamedObject_RegisterSuite2_Teardown );
+ pcu_suite_addTest( suite, NamedObject_RegisterSuite2_TestDeleteAll );
+}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/NamedObject_Register2Suite.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Base/Foundation/tests/NamedObject_Register2Suite.h Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,6 @@
+#ifndef StGermain_NamedObject_Register2Suite_h
+#define StGermain_NamedObject_Register2Suite_h
+
+void NamedObject_Register2Suite( pcu_suite_t* suite );
+
+#endif
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/NamedObject_RegisterSuite.c
--- a/Base/Foundation/tests/NamedObject_RegisterSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/tests/NamedObject_RegisterSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -40,14 +40,15 @@ typedef struct {
} TestObject;
Stg_Object* TestObject_New( Name name ) {
- return _Stg_Object_New(
- sizeof( TestObject ),
- "TestObject",
- _Stg_Object_Delete,
- _Stg_Object_Print,
- _Stg_Object_Copy,
- name,
- NON_GLOBAL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof( TestObject );
+ Type type = "TestObject";
+ Stg_Class_DeleteFunction* _delete = _Stg_Object_Delete;
+ Stg_Class_PrintFunction* _print = _Stg_Object_Print;
+ Stg_Class_CopyFunction* _copy = _Stg_Object_Copy;
+ AllocationType nameAllocationType = NON_GLOBAL;
+
+ return _Stg_Object_New( STG_OBJECT_PASSARGS );
}
typedef struct {
@@ -116,8 +117,8 @@ void NamedObject_RegisterSuite_TestGetFu
for (ii=0; ii < data->testObjectsCount; ii++ ) {
pcu_check_true( ii == NamedObject_Register_GetIndex( data->reg,
data->testObjectNames[ii] ) );
- pcu_check_true( data->testObjects[ii] = NamedObject_Register_GetByIndex( data->reg, ii ) );
- pcu_check_true( data->testObjects[ii] = NamedObject_Register_GetByName( data->reg,
+ pcu_check_true( data->testObjects[ii] == NamedObject_Register_GetByIndex( data->reg, ii ) );
+ pcu_check_true( data->testObjects[ii] == NamedObject_Register_GetByName( data->reg,
data->testObjectNames[ii] ) );
}
}
@@ -128,3 +129,5 @@ void NamedObject_RegisterSuite( pcu_suit
pcu_suite_addTest( suite, NamedObject_RegisterSuite_TestAdd );
pcu_suite_addTest( suite, NamedObject_RegisterSuite_TestGetFunctions );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/ObjectListSuite.c
--- a/Base/Foundation/tests/ObjectListSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/tests/ObjectListSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -492,3 +492,5 @@ void ObjectListSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, ObjectListSuite_TestReplaceAll );
pcu_suite_addTest( suite, ObjectListSuite_TestCopy );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/PrimitiveObjectSuite.c
--- a/Base/Foundation/tests/PrimitiveObjectSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/tests/PrimitiveObjectSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -109,3 +109,5 @@ void PrimitiveObjectSuite( pcu_suite_t*
pcu_suite_setFixtures( suite, PrimitiveObjectSuite_Setup, PrimitiveObjectSuite_Teardown );
pcu_suite_addTest( suite, PrimitiveObjectSuite_TestPrimObjects );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/Stg_asprintfSuite.c
--- a/Base/Foundation/tests/Stg_asprintfSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/tests/Stg_asprintfSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -66,3 +66,5 @@ void Stg_asprintfSuite( pcu_suite_t* sui
pcu_suite_setFixtures( suite, Stg_asprintfSuite_Setup, Stg_asprintfSuite_Teardown );
pcu_suite_addTest( suite, Stg_asprintfSuite_TestPrint );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Foundation/tests/TimeMonitorSuite.c
--- a/Base/Foundation/tests/TimeMonitorSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Foundation/tests/TimeMonitorSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -48,10 +48,6 @@ void TimeMonitorSuite_Teardown( TimeMoni
}
void TimeMonitorSuite_TestTimingPeriod( TimeMonitorSuiteData* data ) {
- Stream* timeMonitorStream = NULL;
- char* timeMonitorOutputFilename = "./TimeMonitorSuite_TestOutput.txt";
- FILE* timeMonitorOutputFile = NULL;
- char* infoString = NULL;
#define MAXLINE 1000
TimeMonitorData tmData;
Stg_TimeMonitor* tm=NULL;
@@ -65,9 +61,9 @@ void TimeMonitorSuite_TestTimingPeriod(
sleep( 2 );
Stg_TimeMonitor_End( tm, &tmData );
- pcu_check_true( 2.95 < tmData.totalSinceInit < 3.05 );
- pcu_check_true( 1.95 < tmData.dt < 2.05 );
- pcu_check_true( 1.95 < tmData.aveProcDt < 2.05 );
+ pcu_check_true( ( 2.95 < tmData.totalSinceInit ) && ( tmData.totalSinceInit < 3.05 ) );
+ pcu_check_true( ( 1.95 < tmData.dt ) && ( tmData.dt < 2.05 ) );
+ pcu_check_true( ( 1.95 < tmData.aveProcDt ) && ( tmData.aveProcDt < 2.05 ) );
percentOfTotalCalc = tmData.aveProcDt / tmData.totalSinceInit * 100;
pcu_check_true( fabs( percentOfTotalCalc - tmData.percentTM_ofTotal ) < 0.01 );
pcu_check_true( tmData.criterionPassed == True );
@@ -75,9 +71,10 @@ void TimeMonitorSuite_TestTimingPeriod(
Stg_TimeMonitor_Delete( tm );
}
-
void TimeMonitorSuite( pcu_suite_t* suite ) {
pcu_suite_setData( suite, TimeMonitorSuiteData );
pcu_suite_setFixtures( suite, TimeMonitorSuite_Setup, TimeMonitorSuite_Teardown );
pcu_suite_addTest( suite, TimeMonitorSuite_TestTimingPeriod );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/BinaryStream.c
--- a/Base/IO/src/BinaryStream.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/BinaryStream.c Tue Jan 12 14:38:16 2010 +1100
@@ -56,28 +56,27 @@ const Type BinaryStream_Type = "BinarySt
Stream* BinaryStream_New( Name name )
{
- return (Stream*)_BinaryStream_New( sizeof(BinaryStream), BinaryStream_Type, _BinaryStream_Delete, _BinaryStream_Print, _Stream_Copy,
- name, _BinaryStream_Printf, _BinaryStream_Write, _BinaryStream_Dump, _BinaryStream_SetFile );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(BinaryStream);
+ Type type = BinaryStream_Type;
+ Stg_Class_DeleteFunction* _delete = _BinaryStream_Delete;
+ Stg_Class_PrintFunction* _print = _BinaryStream_Print;
+ Stg_Class_CopyFunction* _copy = _Stream_Copy;
+ Stream_PrintfFunction* _printf = _BinaryStream_Printf;
+ Stream_WriteFunction* _write = _BinaryStream_Write;
+ Stream_DumpFunction* _dump = _BinaryStream_Dump;
+ Stream_SetFileFunction* _setFile = _BinaryStream_SetFile;
+
+ return (Stream*)_BinaryStream_New( BINARYSTREAM_PASSARGS );
}
-BinaryStream* _BinaryStream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile )
+BinaryStream* _BinaryStream_New( BINARYSTREAM_DEFARGS )
{
BinaryStream* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(BinaryStream) );
- self = (BinaryStream*)_Stream_New( _sizeOfSelf, type, _delete, _print, _copy, name,
- _printf, _write, _dump, _setFile );
+ self = (BinaryStream*)_Stream_New( STREAM_PASSARGS );
_BinaryStream_Init( self );
@@ -165,3 +164,5 @@ SizeT BinaryStream_WriteAllProcessors( N
return;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/BinaryStream.h
--- a/Base/IO/src/BinaryStream.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/BinaryStream.h Tue Jan 12 14:38:16 2010 +1100
@@ -43,8 +43,8 @@
**
**/
-#ifndef __Base_IO_BinaryStream_h__
-#define __Base_IO_BinaryStream_h__
+#ifndef __StGermain_Base_IO_BinaryStream_h__
+#define __StGermain_Base_IO_BinaryStream_h__
/** Textual name for BinaryStream class. */
extern const Type BinaryStream_Type;
@@ -64,17 +64,18 @@
void _BinaryStream_Init( BinaryStream* self );
/** Constructor interface. */
- BinaryStream* _BinaryStream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define BINARYSTREAM_DEFARGS \
+ STREAM_DEFARGS
+
+ #define BINARYSTREAM_PASSARGS \
+ STREAM_PASSARGS
+
+ BinaryStream* _BinaryStream_New( BINARYSTREAM_DEFARGS );
/** Stg_Class_Delete interface. */
void _BinaryStream_Delete( void* cStream );
@@ -101,3 +102,4 @@
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/CFile.c
--- a/Base/IO/src/CFile.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/CFile.c Tue Jan 12 14:38:16 2010 +1100
@@ -48,12 +48,28 @@ const Type CFile_Type = "CFile";
JournalFile* CFile_New()
{
- return (JournalFile*)_CFile_New( sizeof(CFile), CFile_Type, _CFile_Delete, _CFile_Print, NULL, False );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(CFile);
+ Type type = CFile_Type;
+ Stg_Class_DeleteFunction* _delete = _CFile_Delete;
+ Stg_Class_PrintFunction* _print = _CFile_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ Bool binary = False;
+
+ return (JournalFile*)_CFile_New( CFILE_PASSARGS );
}
JournalFile* CFileBinary_New()
{
- return (JournalFile*)_CFile_New( sizeof(CFile), CFile_Type, _CFile_Delete, _CFile_Print, NULL, True );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(CFile);
+ Type type = CFile_Type;
+ Stg_Class_DeleteFunction* _delete = _CFile_Delete;
+ Stg_Class_PrintFunction* _print = _CFile_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ Bool binary = True;
+
+ return (JournalFile*)_CFile_New( CFILE_PASSARGS );
}
@@ -71,17 +87,11 @@ JournalFile* CFile_New2( char* fileName
return result;
}
-CFile* _CFile_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Bool binary)
+CFile* _CFile_New( CFILE_DEFARGS )
{
CFile* self;
- self = (CFile*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (CFile*)_Stg_Class_New( STG_CLASS_PASSARGS );
self->binary = binary;
_CFile_Init( self );
@@ -103,7 +113,8 @@ void CFile_Init( CFile* self )
void _CFile_Init( CFile* self )
{
- _JournalFile_Init( (JournalFile*)self, _CFile_Open, _CFile_Append, _CFile_Close, _CFile_Flush );
+ _JournalFile_Init( (JournalFile*)self, (JournalFile_OpenFunction*)_CFile_Open,
+ (JournalFile_AppendFunction*)_CFile_Append, _CFile_Close, _CFile_Flush );
}
void _CFile_Delete( void* cfile )
@@ -179,3 +190,5 @@ Bool _CFile_Flush( void* file )
return False;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/CFile.h
--- a/Base/IO/src/CFile.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/CFile.h Tue Jan 12 14:38:16 2010 +1100
@@ -44,8 +44,8 @@
**
**/
-#ifndef __Base_IO_CFile_h__
-#define __Base_IO_CFile_h__
+#ifndef __StGermain_Base_IO_CFile_h__
+#define __StGermain_Base_IO_CFile_h__
/** Textual name for CFile class. */
extern const Type CFile_Type;
@@ -73,13 +73,20 @@
/** Constructor interface. */
- CFile* _CFile_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Bool binary);
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define CFILE_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ Bool binary
+
+ #define CFILE_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ binary
+
+ CFile* _CFile_New( CFILE_DEFARGS );
/** Init interface. */
void _CFile_Init( CFile* self );
@@ -104,6 +111,7 @@
Bool _CFile_Flush( void* file );
-#endif /* __Base_IO_CFile_h__ */
+#endif /* __StGermain_Base_IO_CFile_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/CStream.c
--- a/Base/IO/src/CStream.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/CStream.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,8 +51,18 @@ const Type CStream_Type = "CStream";
Stream* CStream_New( Name name )
{
- return (Stream*)_CStream_New( sizeof(CStream), CStream_Type, _CStream_Delete, _CStream_Print, _Stream_Copy,
- name, _CStream_Printf, _CStream_Write, _CStream_Dump, _CStream_SetFile );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(CStream);
+ Type type = CStream_Type;
+ Stg_Class_DeleteFunction* _delete = _CStream_Delete;
+ Stg_Class_PrintFunction* _print = _CStream_Print;
+ Stg_Class_CopyFunction* _copy = _Stream_Copy;
+ Stream_PrintfFunction* _printf = _CStream_Printf;
+ Stream_WriteFunction* _write = _CStream_Write;
+ Stream_DumpFunction* _dump = _CStream_Dump;
+ Stream_SetFileFunction* _setFile = _CStream_SetFile;
+
+ return (Stream*)_CStream_New( CSTREAM_PASSARGS );
}
void CStream_Init( CStream* self, Name name )
@@ -61,24 +71,13 @@ void CStream_Init( CStream* self, Name n
}
-CStream* _CStream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile )
+CStream* _CStream_New( CSTREAM_DEFARGS )
{
CStream* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(CStream) );
- self = (CStream*)_Stream_New( _sizeOfSelf, type, _delete, _print, _copy, name,
- _printf, _write, _dump, _setFile );
+ self = (CStream*)_Stream_New( STREAM_PASSARGS );
_CStream_Init( self );
@@ -149,3 +148,5 @@ Bool _CStream_SetFile( Stream* stream, J
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/CStream.h
--- a/Base/IO/src/CStream.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/CStream.h Tue Jan 12 14:38:16 2010 +1100
@@ -43,8 +43,8 @@
**
**/
-#ifndef __Base_IO_CStream_h__
-#define __Base_IO_CStream_h__
+#ifndef __StGermain_Base_IO_CStream_h__
+#define __StGermain_Base_IO_CStream_h__
/** Textual name for CStream class. */
extern const Type CStream_Type;
@@ -64,17 +64,18 @@
void CStream_Init( CStream* self, Name name );
/** Constructor interface. */
- CStream* _CStream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define CSTREAM_DEFARGS \
+ STREAM_DEFARGS
+
+ #define CSTREAM_PASSARGS \
+ STREAM_PASSARGS
+
+ CStream* _CStream_New( CSTREAM_DEFARGS );
/** Init interface. */
void _CStream_Init( CStream *self );
@@ -103,3 +104,4 @@
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/CmdLineArgs.c
--- a/Base/IO/src/CmdLineArgs.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/CmdLineArgs.c Tue Jan 12 14:38:16 2010 +1100
@@ -142,3 +142,5 @@ char* stgParseListAllCmdLineArg( int* ar
return 0;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/CmdLineArgs.h
--- a/Base/IO/src/CmdLineArgs.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/CmdLineArgs.h Tue Jan 12 14:38:16 2010 +1100
@@ -23,12 +23,12 @@
** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_IO_CmdLineArgs_h__
-#define __Base_IO_CmdLineArgs_h__
+#ifndef __StGermain_Base_IO_CmdLineArgs_h__
+#define __StGermain_Base_IO_CmdLineArgs_h__
void stgRemoveCmdLineArg( int* argc, char** argv[], int index );
char* stgParseHelpCmdLineArg( int* argc, char** argv[] );
char* stgParseListCmdLineArg( int* argc, char** argv[] );
char* stgParseListAllCmdLineArg( int* argc, char** argv[] );
-#endif /* __Base_IO_CmdLineArgs_h__ */
+#endif /* __StGermain_Base_IO_CmdLineArgs_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Dictionary.c
--- a/Base/IO/src/Dictionary.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Dictionary.c Tue Jan 12 14:38:16 2010 +1100
@@ -54,28 +54,29 @@ static const int STRUCT_DELTA = 2;
static const int STRUCT_DELTA = 2;
Dictionary* Dictionary_New( void ) {
- return _Dictionary_New( sizeof(Dictionary), Dictionary_Type, _Dictionary_Delete, _Dictionary_Print, _Dictionary_Copy,
- _Dictionary_Add, _Dictionary_AddWithSource, _Dictionary_Set, _Dictionary_SetWithSource, _Dictionary_Get, _Dictionary_GetSource );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Dictionary);
+ Type type = Dictionary_Type;
+ Stg_Class_DeleteFunction* _delete = _Dictionary_Delete;
+ Stg_Class_PrintFunction* _print = _Dictionary_Print;
+ Stg_Class_CopyFunction* _copy = _Dictionary_Copy;
+ Dictionary_AddFunction* add = _Dictionary_Add;
+ Dictionary_AddWithSourceFunction* addWithSource = _Dictionary_AddWithSource;
+ Dictionary_SetFunction* set = _Dictionary_Set;
+ Dictionary_SetWithSourceFunction* setWithSource = _Dictionary_SetWithSource;
+ Dictionary_GetFunction* get = _Dictionary_Get;
+ Dictionary_GetSourceFunction* getSource = _Dictionary_GetSource;
+
+ return _Dictionary_New( DICTIONARY_PASSARGS );
}
-Dictionary* _Dictionary_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Dictionary_AddFunction* add,
- Dictionary_AddWithSourceFunction* addWithSource,
- Dictionary_SetFunction* set,
- Dictionary_SetWithSourceFunction* setWithSource,
- Dictionary_GetFunction* get,
- Dictionary_GetSourceFunction getSource)
-{
+Dictionary* _Dictionary_New( DICTIONARY_DEFARGS )
+{
Dictionary* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(Dictionary) );
- self = (Dictionary*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (Dictionary*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -93,38 +94,15 @@ Dictionary* _Dictionary_New(
return self;
}
+void _Dictionary_Init( void* dictionary ) {
+ Dictionary* self = (Dictionary*) dictionary;
-void Dictionary_Init( Dictionary* self ) {
- /* General info */
- self->_sizeOfSelf = sizeof( Dictionary );
- self->type = Dictionary_Type;
- self->_deleteSelf = False;
-
- /* Virtual info */
- _Stg_Class_Init( (Stg_Class*)self );
- self->_print = _Dictionary_Print;
- self->_delete = _Dictionary_Delete;
- self->_copy = _Dictionary_Copy;
- self->add = _Dictionary_Add;
- self->addWithSource = _Dictionary_AddWithSource;
- self->set = _Dictionary_Set;
- self->setWithSource = _Dictionary_SetWithSource;
- self->get = _Dictionary_Get;
- self->getSource = _Dictionary_GetSource;
-
- /* Dictionary info */
- _Dictionary_Init( self );
-}
-
-void _Dictionary_Init( Dictionary* self ) {
self->size = DEFAULT_INIT_SIZE;
self->delta = DEFAULT_DELTA;
self->count = 0;
self->entryPtr = Memory_Alloc_Array( Dictionary_Entry*, self->size, "Dictionary->entryPtr" );
-
self->debugStream = Journal_Register( Debug_Type, "DictionaryWarning" );
}
-
void _Dictionary_Delete( void* dictionary ) {
Dictionary* self = (Dictionary*) dictionary;
@@ -139,7 +117,6 @@ void _Dictionary_Delete( void* dictionar
_Stg_Class_Delete( self );
}
-
void _Dictionary_Print( void* dictionary, Stream* stream ) {
Dictionary* self = (Dictionary*) dictionary;
Dictionary_Index index;
@@ -154,6 +131,7 @@ void _Dictionary_Print( void* dictionary
Journal_Printf( (void*)stream, "\tentryPtr[0-%u]: {\n", self->count );
Stream_Indent( stream );
Stream_Indent( stream );
+
for( index = 0; index < self->count; index++ ) {
/*Journal_Printf( (void*)stream, "\t\t" );*/
Dictionary_Entry_Print( self->entryPtr[index], stream );
@@ -893,3 +871,7 @@ Bool Dictionary_CompareAllEntriesFull( v
return retValue;
}
+
+
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Dictionary.h
--- a/Base/IO/src/Dictionary.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Dictionary.h Tue Jan 12 14:38:16 2010 +1100
@@ -48,8 +48,8 @@
**
**/
-#ifndef __Base_IO_Dictionary_h__
-#define __Base_IO_Dictionary_h__
+#ifndef __StGermain_Base_IO_Dictionary_h__
+#define __StGermain_Base_IO_Dictionary_h__
typedef Index Dictionary_Index; /**< Index type for Dictionary, */
@@ -80,21 +80,21 @@
__Stg_Class \
\
/* Virtual info */ \
- Dictionary_AddFunction* add; \
+ Dictionary_AddFunction* add; \
Dictionary_AddWithSourceFunction* addWithSource; \
- Dictionary_SetFunction* set; \
+ Dictionary_SetFunction* set; \
Dictionary_SetWithSourceFunction* setWithSource; \
- Dictionary_GetFunction* get; \
- Dictionary_GetSourceFunction* getSource; \
+ Dictionary_GetFunction* get; \
+ Dictionary_GetSourceFunction* getSource; \
\
/* Dictionary info */ \
- Dictionary_Index size; \
- Dictionary_Index delta; \
+ Dictionary_Index size; \
+ Dictionary_Index delta; \
\
- Dictionary_Index count; \
- Dictionary_Entry** entryPtr; \
+ Dictionary_Index count; \
+ Dictionary_Entry** entryPtr; \
\
- Stream* debugStream;
+ Stream* debugStream;
struct _Dictionary { __Dictionary };
/*--------------------------------------------------------------------------------------------------------------------------
@@ -105,24 +105,33 @@
Dictionary* Dictionary_New( void );
/** Constructor interface. */
- Dictionary* _Dictionary_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Dictionary_AddFunction* add,
- Dictionary_AddWithSourceFunction* addWithSource,
- Dictionary_SetFunction* set,
- Dictionary_SetWithSourceFunction* setWithSource,
- Dictionary_GetFunction* get,
- Dictionary_GetSourceFunction* getSource);
- /** Initialises a Dictionary. */
- void Dictionary_Init( Dictionary* self );
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define DICTIONARY_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ Dictionary_AddFunction* add, \
+ Dictionary_AddWithSourceFunction* addWithSource, \
+ Dictionary_SetFunction* set, \
+ Dictionary_SetWithSourceFunction* setWithSource, \
+ Dictionary_GetFunction* get, \
+ Dictionary_GetSourceFunction* getSource
+
+ #define DICTIONARY_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ add, \
+ addWithSource, \
+ set, \
+ setWithSource, \
+ get, \
+ getSource
+
+ Dictionary* _Dictionary_New( DICTIONARY_DEFARGS );
/** Init interface. */
- void _Dictionary_Init( Dictionary* self );
+ void _Dictionary_Init( void* dictionary );
/** Stg_Class_Delete dictionary implementation */
void _Dictionary_Delete( void* dictionary );
@@ -145,30 +154,28 @@
void Dictionary_Add( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
/** Add an entry to the dictionary... orignal implementation... appends keys, with source file */
- void Dictionary_AddWithSource( void* dictionary, Dictionary_Entry_Key key,
- Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+ void Dictionary_AddWithSource( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
/** Add an entry to the dictionary... specifying how the entry values are merged if key present already */
Dictionary_Entry_Value* Dictionary_AddMerge(
- void* dictionary,
- Dictionary_Entry_Key key,
- Dictionary_Entry_Value* value,
- Dictionary_MergeType mergeType );
+ void* dictionary,
+ Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value,
+ Dictionary_MergeType mergeType );
/** Add an entry to the dictionary... specifying how the entry values are merged if key present already */
Dictionary_Entry_Value* Dictionary_AddMergeWithSource(
- void* dictionary,
- Dictionary_Entry_Key key,
- Dictionary_Entry_Value* value,
- Dictionary_MergeType mergeType,
- Dictionary_Entry_Source source );
+ void* dictionary,
+ Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value,
+ Dictionary_MergeType mergeType,
+ Dictionary_Entry_Source source );
/** Set a value in the dictionary */
Bool Dictionary_Set( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
/** Set a value in the dictionary */
- Bool Dictionary_SetWithSource( void* dictionary, Dictionary_Entry_Key key,
- Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+ Bool Dictionary_SetWithSource( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
/** Get a value from the dictionary */
Dictionary_Entry_Value* Dictionary_Get( void* dictionary, Dictionary_Entry_Key key );
@@ -182,20 +189,17 @@
/** Get a value from the dictionary */
Dictionary_Entry_Value* Dictionary_GetDefault( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
-
/** Add an entry to the dictionary implementation */
void _Dictionary_Add( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
/** Add an entry to the dictionary implementation */
- void _Dictionary_AddWithSource( void* dictionary, Dictionary_Entry_Key key,
- Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+ void _Dictionary_AddWithSource( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
/** Set a value in the dictionary implementation */
Bool _Dictionary_Set( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
/** Set a value in the dictionary implementation */
- Bool _Dictionary_SetWithSource( void* dictionary, Dictionary_Entry_Key key,
- Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+ Bool _Dictionary_SetWithSource( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
/** Get a value from the dictionary implementation */
Dictionary_Entry_Value* _Dictionary_Get( void* dictionary, Dictionary_Entry_Key key );
@@ -225,4 +229,5 @@
/** Compares two dictionaries, returns True if all entries are identical */
Bool Dictionary_CompareAllEntriesFull( void* dictionary1, void* dictionary2, Bool strictTypeCheck );
-#endif /* __Base_IO_Dictionary_h__ */
+#endif /* __StGermain_Base_IO_Dictionary_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Dictionary_Entry.c
--- a/Base/IO/src/Dictionary_Entry.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Dictionary_Entry.c Tue Jan 12 14:38:16 2010 +1100
@@ -153,3 +153,5 @@ Dictionary_Entry_Source Dictionary_Entry
{
return self->source;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Dictionary_Entry.h
--- a/Base/IO/src/Dictionary_Entry.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Dictionary_Entry.h Tue Jan 12 14:38:16 2010 +1100
@@ -44,8 +44,8 @@
**
**/
-#ifndef __Base_IO_Dictionary_Entry_h__
-#define __Base_IO_Dictionary_Entry_h__
+#ifndef __StGermain_Base_IO_Dictionary_Entry_h__
+#define __StGermain_Base_IO_Dictionary_Entry_h__
/** \def __Dictionary_Entry See Dictionary_Entry */
#define __Dictionary_Entry \
@@ -96,6 +96,6 @@
/** Get an entry's originalSource */
Dictionary_Entry_Source Dictionary_Entry_GetSource( Dictionary_Entry* self );
-#endif /* __Base_IO_Dictionary_Entry_h__ */
+#endif /* __StGermain_Base_IO_Dictionary_Entry_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Dictionary_Entry_Value.c
--- a/Base/IO/src/Dictionary_Entry_Value.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Dictionary_Entry_Value.c Tue Jan 12 14:38:16 2010 +1100
@@ -1208,3 +1208,5 @@ Dictionary_Entry_Value* Dictionary_Entry
return copy;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Dictionary_Entry_Value.h
--- a/Base/IO/src/Dictionary_Entry_Value.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Dictionary_Entry_Value.h Tue Jan 12 14:38:16 2010 +1100
@@ -42,8 +42,8 @@
**
**/
-#ifndef __Base_IO_Dictionary_Entry_Value_h__
-#define __Base_IO_Dictionary_Entry_Value_h__
+#ifndef __StGermain_Base_IO_Dictionary_Entry_Value_h__
+#define __StGermain_Base_IO_Dictionary_Entry_Value_h__
/** The available formats which a dictionary can be written to output. */
@@ -255,4 +255,4 @@
Dictionary_Entry_Value* self,
Bool deep );
-#endif /* __Base_IO_Dictionary_Entry_Value_h__ */
+#endif /* __StGermain_Base_IO_Dictionary_Entry_Value_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Finalise.c
--- a/Base/IO/src/Finalise.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Finalise.c Tue Jan 12 14:38:16 2010 +1100
@@ -55,3 +55,5 @@ Bool BaseIO_Finalise( void )
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Finalise.h
--- a/Base/IO/src/Finalise.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Finalise.h Tue Jan 12 14:38:16 2010 +1100
@@ -41,12 +41,12 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_BaseIO_Finalise_h__
-#define __Base_BaseIO_Finalise_h__
+#ifndef __StGermain_Base_IO_Finalise_h__
+#define __StGermain_Base_IO_Finalise_h__
- Bool BaseIO_Finalise( void );
+ Bool IO_Finalise( void );
-#endif /* __Base_BaseIO_Finalise_h__ */
+#endif /* __StGermain_Base_IO_Finalise_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/IO.h
--- a/Base/IO/src/IO.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/IO.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_IO_h__
-#define __Base_IO_h__
+#ifndef __StGermain_Base_IO_h__
+#define __StGermain_Base_IO_h__
#include "types.h"
#include "shortcuts.h"
@@ -67,5 +67,5 @@
#include "StGermain/Base/IO/mpirecord/mpimessaging.h"
-#endif /* __Base_IO_h__ */
+#endif /* __StGermain_Base_IO_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/IO_Handler.c
--- a/Base/IO/src/IO_Handler.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/IO_Handler.c Tue Jan 12 14:38:16 2010 +1100
@@ -53,22 +53,13 @@ const Dictionary_MergeType IO_Handler_De
/* TODO: register with IO_Handler registry */
-IO_Handler* _IO_Handler_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- IO_Handler_ReadAllFromFileFunction* _readAllFromFile,
- IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource,
- IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer,
- IO_Handler_WriteAllToFileFunction* _writeAllToFile )
+IO_Handler* _IO_Handler_New( IO_HANDLER_DEFARGS )
{
IO_Handler* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(IO_Handler) );
- self = (IO_Handler*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (IO_Handler*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* General info */
@@ -458,9 +449,8 @@ void _get_XML(void* ioHandler, char* arg
Index IO_Handler_ReadAllFromCommandLine( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) {
- Index filesRead = 0;
- Index arg_I;
- IO_Handler* self;
+ Index filesRead = 0;
+
_get_XML( ioHandler, argv, argc );
filesRead = IO_Handler_ReadAllFilesFromCommandLine( ioHandler, argc, argv, dictionary );
Dictionary_ReadAllParamFromCommandLine( dictionary, argc, argv );
@@ -470,9 +460,12 @@ Index IO_Handler_ReadAllFromCommandLine(
Index IO_Handler_ReadAllFromCommandLineForceSource( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) {
- Index filesRead = 0;
+ Index filesRead = 0;
+
filesRead = IO_Handler_ReadAllFilesFromCommandLineForceSource( ioHandler, argc, argv, dictionary );
Dictionary_ReadAllParamFromCommandLine( dictionary, argc, argv );
return filesRead;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/IO_Handler.h
--- a/Base/IO/src/IO_Handler.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/IO_Handler.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,15 +38,14 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_IO_IO_Handler_h__
-#define __Base_IO_IO_Handler_h__
+#ifndef __StGermain_Base_IO_IO_Handler_h__
+#define __StGermain_Base_IO_IO_Handler_h__
/* Function pointer interface for inherited classes to use */
typedef void (IO_Handler_DeleteFunction) (void* io_handler);
typedef void (IO_Handler_PrintFunction) (void* io_handler);
typedef Bool (IO_Handler_ReadAllFromFileFunction) (void* io_handler, const char* filename, Dictionary* dictionary );
- typedef Bool (IO_Handler_ReadAllFromFileForceSourceFunction) (void* io_handler, const char* filename,
- Dictionary* dictionary );
+ typedef Bool (IO_Handler_ReadAllFromFileForceSourceFunction) (void* io_handler, const char* filename, Dictionary* dictionary );
typedef Bool (IO_Handler_ReadAllFromBufferFunction) (void* io_handler, const char* buffer, Dictionary* dictionary );
typedef Bool (IO_Handler_WriteAllToFileFunction) (void* io_handler, const char* filename, Dictionary* dictionary );
typedef Bool (IO_Handler_DictSetAddValueFunction)
@@ -67,32 +66,42 @@
__Stg_Class \
\
/* Virtual info */ \
- IO_Handler_ReadAllFromFileFunction* _readAllFromFile; \
+ IO_Handler_ReadAllFromFileFunction* _readAllFromFile; \
IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource; \
- IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer; \
- IO_Handler_WriteAllToFileFunction* _writeAllToFile; \
+ IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer; \
+ IO_Handler_WriteAllToFileFunction* _writeAllToFile; \
\
/* IO_Handler info */ \
- Dictionary* currDictionary; \
- char* resource; \
- char* currPath; \
- char* schema; \
- int validate;
+ Dictionary* currDictionary; \
+ char* resource; \
+ char* currPath; \
+ char* schema; \
+ int validate;
struct _IO_Handler { __IO_Handler };
/* No "IO_Handler_New" and "IO_Handler_Init" as this is an abstract class */
/** Creation implementation */
- IO_Handler* _IO_Handler_New(
- SizeT sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- IO_Handler_ReadAllFromFileFunction* _readAllFromFile,
- IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource,
- IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer,
- IO_Handler_WriteAllToFileFunction* _writeAllToFile );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define IO_HANDLER_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ IO_Handler_ReadAllFromFileFunction* _readAllFromFile, \
+ IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource, \
+ IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer, \
+ IO_Handler_WriteAllToFileFunction* _writeAllToFile
+
+ #define IO_HANDLER_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ _readAllFromFile, \
+ _readAllFromFileForceSource, \
+ _readAllFromBuffer, \
+ _writeAllToFile
+
+ IO_Handler* _IO_Handler_New( IO_HANDLER_DEFARGS );
/** Initialisation implementation */
void _IO_Handler_Init( IO_Handler* self );
@@ -151,4 +160,5 @@
Returns the number of files successfully read. */
Index IO_Handler_ReadAllFromCommandLineForceSource( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) ;
-#endif /* __Base_IO_IO_Handler_h__ */
+#endif /* __StGermain_Base_IO_IO_Handler_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/IndentFormatter.c
--- a/Base/IO/src/IndentFormatter.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/IndentFormatter.c Tue Jan 12 14:38:16 2010 +1100
@@ -53,16 +53,29 @@ void IndentFormatter_MakeTag( IndentForm
StreamFormatter* IndentFormatter_New()
{
- return (StreamFormatter*)_IndentFormatter_New( sizeof(IndentFormatter), IndentFormatter_Type,
- _IndentFormatter_Delete, _IndentFormatter_Print, _IndentFormatter_Copy, _LineFormatter_Format,
- IndentFormatter_IndentChar );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(IndentFormatter);
+ Type type = IndentFormatter_Type;
+ Stg_Class_DeleteFunction* _delete = _IndentFormatter_Delete;
+ Stg_Class_PrintFunction* _print = _IndentFormatter_Print;
+ Stg_Class_CopyFunction* _copy = _IndentFormatter_Copy;
+ StreamFormatter_FormatFunction* _format = _LineFormatter_Format;
+ char _character = IndentFormatter_IndentChar;
+
+ return (StreamFormatter*)_IndentFormatter_New( INDENTFORMATTER_PASSARGS );
}
StreamFormatter* IndentFormatter_New2( char _character )
{
- return (StreamFormatter*)_IndentFormatter_New( sizeof(IndentFormatter), IndentFormatter_Type,
- _IndentFormatter_Delete, _IndentFormatter_Print, _IndentFormatter_Copy, _LineFormatter_Format,
- _character );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(IndentFormatter);
+ Type type = IndentFormatter_Type;
+ Stg_Class_DeleteFunction* _delete = _IndentFormatter_Delete;
+ Stg_Class_PrintFunction* _print = _IndentFormatter_Print;
+ Stg_Class_CopyFunction* _copy = _IndentFormatter_Copy;
+ StreamFormatter_FormatFunction* _format = _LineFormatter_Format;
+
+ return (StreamFormatter*)_IndentFormatter_New( INDENTFORMATTER_PASSARGS );
}
void IndentFormatter_Init( IndentFormatter* self )
@@ -76,20 +89,13 @@ void IndentFormatter_Init( IndentFormatt
_IndentFormatter_Init( self, _LineFormatter_Format, IndentFormatter_IndentChar );
}
-IndentFormatter* _IndentFormatter_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- StreamFormatter_FormatFunction* _format,
- char _character )
+IndentFormatter* _IndentFormatter_New( INDENTFORMATTER_DEFARGS )
{
IndentFormatter* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(IndentFormatter) );
- self = (IndentFormatter*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (IndentFormatter*)_Stg_Class_New( STG_CLASS_PASSARGS );
_IndentFormatter_Init( self, _format, _character );
@@ -204,3 +210,5 @@ void IndentFormatter_MakeTag( IndentForm
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/IndentFormatter.h
--- a/Base/IO/src/IndentFormatter.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/IndentFormatter.h Tue Jan 12 14:38:16 2010 +1100
@@ -40,8 +40,8 @@
**
**/
-#ifndef __Base_IO_IndentFormatter_h__
-#define __Base_IO_IndentFormatter_h__
+#ifndef __StGermain_Base_IO_IndentFormatter_h__
+#define __StGermain_Base_IO_IndentFormatter_h__
/** Textual name for IndentFormatter class. */
@@ -67,14 +67,22 @@
/** Constructor interface. */
- IndentFormatter* _IndentFormatter_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- StreamFormatter_FormatFunction* _format,
- char _character );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define INDENTFORMATTER_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ StreamFormatter_FormatFunction* _format, \
+ char _character
+
+ #define INDENTFORMATTER_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ _format, \
+ _character
+
+ IndentFormatter* _IndentFormatter_New( INDENTFORMATTER_DEFARGS );
/** Init interface. */
void _IndentFormatter_Init(
@@ -108,4 +116,5 @@
void IndentFormatter_SetCharacter( char _character );
-#endif /* __Base_IO_IndentFormatter_h__ */
+#endif /* __StGermain_Base_IO_IndentFormatter_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Init.c
--- a/Base/IO/src/Init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Init.c Tue Jan 12 14:38:16 2010 +1100
@@ -103,3 +103,5 @@ Bool BaseIO_Init( int* argc, char** argv
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Init.h
--- a/Base/IO/src/Init.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Init.h Tue Jan 12 14:38:16 2010 +1100
@@ -40,8 +40,8 @@
**
**/
-#ifndef __Base_BaseIO_Init_h__
-#define __Base_BaseIO_Init_h__
+#ifndef __StGermain_Base_IO_Init_h__
+#define __StGermain_Base_IO_Init_h__
extern const Name LiveDebugName;
/** A global stream for interactive debugging through GDB. Note that the
@@ -50,9 +50,9 @@
extern Stream* stgErrorStream;
- Bool BaseIO_Init( int* argc, char** argv[] );
+ Bool IO_Init( int* argc, char** argv[] );
-#endif /* __Base_BaseIO_Init_h__ */
+#endif /* __StGermain_Base_IO_Init_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Journal.c
--- a/Base/IO/src/Journal.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Journal.c Tue Jan 12 14:38:16 2010 +1100
@@ -126,28 +126,28 @@ Journal* Journal_New()
return self;
}
-void Journal_Delete( )
-{
- int i;
-
+void Journal_Delete() {
Stg_Class_Delete( stJournal->stdOut );
Stg_Class_Delete( stJournal->stdErr );
+ Journal_Purge();
+ Stg_Class_Delete( stJournal->_typedStreams );
+ Stg_Class_Delete( stJournal->_files );
+
+ Memory_Free( stJournal );
+}
+
+void Journal_Purge() {
+ int i;
+
Stg_ObjectList_DeleteAllObjects( stJournal->_typedStreams );
- Stg_Class_Delete( stJournal->_typedStreams );
-
- for ( i = 0; i < stJournal->_files->count; ++i )
- {
- if ( !JournalFile_Close( (JournalFile*) stJournal->_files->data[i] ) )
- {
+
+ for ( i = 0; i < stJournal->_files->count; ++i ) {
+ if ( !JournalFile_Close( (JournalFile*) stJournal->_files->data[i] ) ) {
/* TODO: warning can't close */
}
}
Stg_ObjectList_DeleteAllObjects( stJournal->_files );
- Stg_Class_Delete( stJournal->_files );
-
- Memory_Free( stJournal );
-
}
void Journal_ReadFromDictionary( Dictionary* dictionary )
@@ -394,6 +394,7 @@ void Journal_RegisterTypedStream( Stream
/* check exists and update */
Stg_ObjectList_Append( stJournal->_typedStreams, typedStream );
}
+
Stream* Journal_GetTypedStream( const Type type )
{
Stream* typedStream = NULL;
@@ -412,6 +413,7 @@ Stream* Journal_GetTypedStream( const Ty
return typedStream;
}
+
Stream* Journal_GetNamedStream( Stream* typedStream, const Name name )
{
Stream* currentStream ;
@@ -447,9 +449,9 @@ Stream* Journal_Register( const Type typ
typedStream = Journal_GetTypedStream( type );
namedStream = Journal_GetNamedStream( typedStream, name );
-
return namedStream;
}
+
Stream* Journal_Register2( const Type streamType, const Type componentType, const Name componentName ) {
Stream* componentStream;
Stream* instanceStream;
@@ -487,6 +489,14 @@ void Journal_Enable_TypedStream( const T
{
Stream* typedStream = Journal_GetTypedStream( type );
Stream_Enable( typedStream, enable );
+}
+
+void Journal_Enable_AllTypedStream( Bool enable )
+{
+ Journal_Enable_TypedStream( Info_Type, enable );
+ Journal_Enable_TypedStream( Debug_Type, enable );
+ Journal_Enable_TypedStream( Dump_Type, enable );
+ Journal_Enable_TypedStream( Error_Type, enable );
}
void Journal_Enable_NamedStream( const Type type, const Name name, Bool enable )
@@ -751,3 +761,5 @@ void Journal_SetupDefaultTypedStreams()
Stream_SetLevel( typedStream, 1 );
Journal_RegisterTypedStream( typedStream );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Journal.h
--- a/Base/IO/src/Journal.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Journal.h Tue Jan 12 14:38:16 2010 +1100
@@ -49,8 +49,8 @@
**
**/
-#ifndef __Base_IO_Journal_h__
-#define __Base_IO_Journal_h__
+#ifndef __StGermain_Base_IO_Journal_h__
+#define __StGermain_Base_IO_Journal_h__
#include <stdarg.h>
@@ -103,6 +103,8 @@
/** Deallocates the Journal singleton. */
void Journal_Delete( );
+ /** Purge all the streams */
+ void Journal_Purge();
/** Reads entries from the the given dictionary object to create/configure streams in Journal. */
void Journal_ReadFromDictionary( Dictionary* dictionary );
@@ -146,10 +148,11 @@
** If the argument is NULL, no operation is performed. */
void Journal_DeregisterFile( JournalFile* file );
-
-
/** Enables/Disables the specified typed stream. */
void Journal_Enable_TypedStream( const Type type, Bool enable );
+
+ /** Enables/Disables all defined typed streams */
+ void Journal_Enable_AllTypedStream( Bool enable );
/** Enables/Disables the given named stream.
**
@@ -158,11 +161,8 @@
**/
void Journal_Enable_NamedStream( const Type type, const Name name, Bool enable );
-
/** Prints a summary of the status of each stream in Journal */
void Journal_PrintConcise();
-
-
/** Performs a printf() with the given stream. */
int Journal_Printf( void* _stream, const char* const fmt, ... );
@@ -252,4 +252,4 @@
/** Set up the default type streams expected throughout StGermain */
void Journal_SetupDefaultTypedStreams();
-#endif /* __Base_IO_Journal_h__ */
+#endif /* __StGermain_Base_IO_Journal_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/JournalFile.c
--- a/Base/IO/src/JournalFile.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/JournalFile.c Tue Jan 12 14:38:16 2010 +1100
@@ -44,21 +44,12 @@ const Type JournalFile_Type = "JournalFi
const Type JournalFile_Type = "JournalFile";
-JournalFile* _JournalFile_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- JournalFile_OpenFunction* _open,
- JournalFile_AppendFunction* _append,
- JournalFile_CloseFunction* _close,
- JournalFile_FlushFunction* _flush )
+JournalFile* _JournalFile_New( JOURNALFILE_DEFARGS )
{
JournalFile* self;
assert( _sizeOfSelf >= sizeof(JournalFile) );
- self = (JournalFile*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (JournalFile*)_Stg_Class_New( STG_CLASS_PASSARGS );
_JournalFile_Init( self, _open, _append, _close, _flush );
@@ -85,6 +76,8 @@ void _JournalFile_Init(
void _JournalFile_Delete( void* journalFile )
{
+ /* Close if opened */
+ JournalFile_Close( journalFile );
_Stg_Object_Delete( journalFile );
}
void _JournalFile_Print( void* journalFile, Stream* stream )
@@ -165,3 +158,5 @@ Bool JournalFile_Flush( void* file )
stJournal->flushCount++;
return self->_flush( self );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/JournalFile.h
--- a/Base/IO/src/JournalFile.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/JournalFile.h Tue Jan 12 14:38:16 2010 +1100
@@ -52,8 +52,8 @@
**
**/
-#ifndef __Base_IO_JournalFile_h__
-#define __Base_IO_JournalFile_h__
+#ifndef __StGermain_Base_IO_JournalFile_h__
+#define __StGermain_Base_IO_JournalFile_h__
/** Textual name for JournalFile class. */
extern const Type JournalFile_Type;
@@ -81,16 +81,26 @@
/** Constructor interface. */
- JournalFile* _JournalFile_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- JournalFile_OpenFunction* _open,
- JournalFile_AppendFunction* _append,
- JournalFile_CloseFunction* _close,
- JournalFile_FlushFunction* _flush );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define JOURNALFILE_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ JournalFile_OpenFunction* _open, \
+ JournalFile_AppendFunction* _append, \
+ JournalFile_CloseFunction* _close, \
+ JournalFile_FlushFunction* _flush
+
+ #define JOURNALFILE_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ _open, \
+ _append, \
+ _close, \
+ _flush
+
+ JournalFile* _JournalFile_New( JOURNALFILE_DEFARGS );
/** Init interface. */
void _JournalFile_Init(
@@ -149,4 +159,5 @@
Bool JournalFile_Flush( void* journalFile );
-#endif /* __Base_IO_JournalFile_h__ */
+#endif /* __StGermain_Base_IO_JournalFile_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/LineFormatter.c
--- a/Base/IO/src/LineFormatter.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/LineFormatter.c Tue Jan 12 14:38:16 2010 +1100
@@ -46,19 +46,13 @@
const Type LineFormatter_Type = "LineFormatter";
-LineFormatter* _LineFormatter_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- StreamFormatter_FormatFunction* _format )
+LineFormatter* _LineFormatter_New( LINEFORMATTER_DEFARGS )
{
LineFormatter* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(LineFormatter) );
- self = (LineFormatter*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (LineFormatter*)_Stg_Class_New( STG_CLASS_PASSARGS );
_LineFormatter_Init( self, _format );
@@ -224,3 +218,5 @@ char* _LineFormatter_Format( void* forma
return result;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/LineFormatter.h
--- a/Base/IO/src/LineFormatter.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/LineFormatter.h Tue Jan 12 14:38:16 2010 +1100
@@ -43,8 +43,8 @@
**/
-#ifndef __Base_IO_LineFormatter_h__
-#define __Base_IO_LineFormatter_h__
+#ifndef __StGermain_Base_IO_LineFormatter_h__
+#define __StGermain_Base_IO_LineFormatter_h__
/** Textual name for LineFormatter class. */
extern const Type LineFormatter_Type;
@@ -60,13 +60,20 @@
/** Constructor interface. */
- LineFormatter* _LineFormatter_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- StreamFormatter_FormatFunction* _format );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define LINEFORMATTER_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ StreamFormatter_FormatFunction* _format
+
+ #define LINEFORMATTER_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ _format
+
+ LineFormatter* _LineFormatter_New( LINEFORMATTER_DEFARGS );
/** Init interface. */
void _LineFormatter_Init(
@@ -92,7 +99,8 @@
char* _LineFormatter_Format( void* formatter, const char* const fmt );
-#endif /* __Base_IO_LineFormatter_h__ */
+#endif /* __StGermain_Base_IO_LineFormatter_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/MPIFile.c
--- a/Base/IO/src/MPIFile.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/MPIFile.c Tue Jan 12 14:38:16 2010 +1100
@@ -50,7 +50,14 @@ const Type MPIFile_Type = "MPIFile";
JournalFile* MPIFile_New()
{
- return (JournalFile*)_MPIFile_New( sizeof(MPIFile), MPIFile_Type, _MPIFile_Delete, _MPIFile_Print, NULL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(MPIFile);
+ Type type = MPIFile_Type;
+ Stg_Class_DeleteFunction* _delete = _MPIFile_Delete;
+ Stg_Class_PrintFunction* _print = _MPIFile_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ return (JournalFile*)_MPIFile_New( MPIFILE_PASSARGS );
}
JournalFile* MPIFile_New2( const char* const fileName )
@@ -67,16 +74,11 @@ JournalFile* MPIFile_New2( const char* c
return result;
}
-MPIFile* _MPIFile_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy )
+MPIFile* _MPIFile_New( MPIFILE_DEFARGS )
{
MPIFile* self;
- self = (MPIFile*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (MPIFile*)_Stg_Class_New( STG_CLASS_PASSARGS );
_MPIFile_Init( self );
@@ -183,3 +185,5 @@ Bool _MPIFile_Flush( void* file )
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/MPIFile.h
--- a/Base/IO/src/MPIFile.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/MPIFile.h Tue Jan 12 14:38:16 2010 +1100
@@ -40,8 +40,8 @@
**
**/
-#ifndef __Base_IO_MPIFile_h__
-#define __Base_IO_MPIFile_h__
+#ifndef __StGermain_Base_IO_MPIFile_h__
+#define __StGermain_Base_IO_MPIFile_h__
#include <mpi.h>
@@ -67,12 +67,18 @@
/** Constructor interface. */
- MPIFile* _MPIFile_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define MPIFILE_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define MPIFILE_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ MPIFile* _MPIFile_New( MPIFILE_DEFARGS );
/** Init interface. */
void _MPIFile_Init( MPIFile* self );
@@ -97,4 +103,5 @@
Bool _MPIFile_Flush( void* file );
-#endif /* __Base_IO_MPIFile_h__ */
+#endif /* __StGermain_Base_IO_MPIFile_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/MPIStream.c
--- a/Base/IO/src/MPIStream.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/MPIStream.c Tue Jan 12 14:38:16 2010 +1100
@@ -56,8 +56,18 @@ const Type MPIStream_Type = "MPIStream";
Stream* MPIStream_New( Name name )
{
- return (Stream*)_MPIStream_New( sizeof(MPIStream), MPIStream_Type, _MPIStream_Delete, _MPIStream_Print, _Stream_Copy,
- name, _MPIStream_Printf, _MPIStream_Write, _MPIStream_Dump, _MPIStream_SetFile );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(MPIStream);
+ Type type = MPIStream_Type;
+ Stg_Class_DeleteFunction* _delete = _MPIStream_Delete;
+ Stg_Class_PrintFunction* _print = _MPIStream_Print;
+ Stg_Class_CopyFunction* _copy = _Stream_Copy;
+ Stream_PrintfFunction* _printf = _MPIStream_Printf;
+ Stream_WriteFunction* _write = _MPIStream_Write;
+ Stream_DumpFunction* _dump = _MPIStream_Dump;
+ Stream_SetFileFunction* _setFile = _MPIStream_SetFile;
+
+ return (Stream*)_MPIStream_New( MPISTREAM_PASSARGS );
}
void MPIStream_Init( MPIStream* self, Name name )
@@ -66,24 +76,13 @@ void MPIStream_Init( MPIStream* self, Na
}
-MPIStream* _MPIStream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile )
+MPIStream* _MPIStream_New( MPISTREAM_DEFARGS )
{
MPIStream* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(MPIStream) );
- self = (MPIStream*)_Stream_New( _sizeOfSelf, type, _delete, _print, _copy, name,
- _printf, _write, _dump, _setFile );
+ self = (MPIStream*)_Stream_New( STREAM_PASSARGS );
_MPIStream_Init( self );
@@ -195,7 +194,6 @@ Bool _MPIStream_SetFile( Stream* stream,
Bool MPIStream_SetOffset( Stream* stream, SizeT sizeToWrite, MPI_Comm communicator ) {
MPI_Offset offset = 0;
- MPI_Status status;
int rank;
int nproc;
unsigned int localSizeToWrite;
@@ -230,3 +228,5 @@ SizeT MPIStream_WriteAllProcessors( Stre
return Stream_Write( stream, data, elem_size, num_elems );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/MPIStream.h
--- a/Base/IO/src/MPIStream.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/MPIStream.h Tue Jan 12 14:38:16 2010 +1100
@@ -43,8 +43,8 @@
**
**/
-#ifndef __Base_IO_MPIStream_h__
-#define __Base_IO_MPIStream_h__
+#ifndef __StGermain_Base_IO_MPIStream_h__
+#define __StGermain_Base_IO_MPIStream_h__
/** Textual name for MPIStream class. */
extern const Type MPIStream_Type;
@@ -64,17 +64,18 @@
void MPIStream_Init( MPIStream* self, Name name );
/** Constructor interface. */
- MPIStream* _MPIStream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define MPISTREAM_DEFARGS \
+ STREAM_DEFARGS
+
+ #define MPISTREAM_PASSARGS \
+ STREAM_PASSARGS
+
+ MPIStream* _MPIStream_New( MPISTREAM_DEFARGS );
/** Init interface. */
void _MPIStream_Init( MPIStream *self );
@@ -106,3 +107,4 @@
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/PathUtils.c
--- a/Base/IO/src/PathUtils.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/PathUtils.c Tue Jan 12 14:38:16 2010 +1100
@@ -345,3 +345,5 @@ Bool Stg_DirectoryExists( const char* pa
}
return (info.st_mode & S_IFDIR);
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/PathUtils.h
--- a/Base/IO/src/PathUtils.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/PathUtils.h Tue Jan 12 14:38:16 2010 +1100
@@ -28,8 +28,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_IO_PathUtils_h__
-#define __Base_IO_PathUtils_h__
+#ifndef __StGermain_Base_IO_PathUtils_h__
+#define __StGermain_Base_IO_PathUtils_h__
/** Note that this function is designed as call-by-reference to modify fullPath to the found
@@ -54,4 +54,4 @@ Bool Stg_FileExists( const char* path );
Bool Stg_DirectoryExists( const char* path );
-#endif /* __Base_IO_PathUtils_h__ */
+#endif /* __StGermain_Base_IO_PathUtils_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/RankFormatter.c
--- a/Base/IO/src/RankFormatter.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/RankFormatter.c Tue Jan 12 14:38:16 2010 +1100
@@ -51,8 +51,15 @@ const char* PREPEND = ": ";
StreamFormatter* RankFormatter_New()
{
- return (StreamFormatter*)_RankFormatter_New( sizeof(RankFormatter), RankFormatter_Type,
- _RankFormatter_Delete, _RankFormatter_Print, _LineFormatter_Copy, _LineFormatter_Format );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(RankFormatter);
+ Type type = RankFormatter_Type;
+ Stg_Class_DeleteFunction* _delete = _RankFormatter_Delete;
+ Stg_Class_PrintFunction* _print = _RankFormatter_Print;
+ Stg_Class_CopyFunction* _copy = _LineFormatter_Copy;
+ StreamFormatter_FormatFunction* _format = _LineFormatter_Format;
+
+ return (StreamFormatter*)_RankFormatter_New( RANKFORMATTER_PASSARGS );
}
void RankFormatter_Init( RankFormatter* self )
@@ -67,19 +74,13 @@ void RankFormatter_Init( RankFormatter*
_RankFormatter_Init( self, _LineFormatter_Format );
}
-RankFormatter* _RankFormatter_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- StreamFormatter_FormatFunction* _format )
+RankFormatter* _RankFormatter_New( RANKFORMATTER_DEFARGS )
{
RankFormatter* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(RankFormatter) );
- self = (RankFormatter*)_LineFormatter_New( _sizeOfSelf, type, _delete, _print, _copy, _format );
+ self = (RankFormatter*)_LineFormatter_New( LINEFORMATTER_PASSARGS );
_RankFormatter_Init( self, _format );
@@ -146,3 +147,5 @@ void _RankFormatter_Print( void* formatt
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/RankFormatter.h
--- a/Base/IO/src/RankFormatter.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/RankFormatter.h Tue Jan 12 14:38:16 2010 +1100
@@ -42,8 +42,8 @@
**
**/
-#ifndef __Base_IO_RankFormatter_h__
-#define __Base_IO_RankFormatter_h__
+#ifndef __StGermain_Base_IO_RankFormatter_h__
+#define __StGermain_Base_IO_RankFormatter_h__
/** Textual name for RankFormatter class. */
@@ -63,13 +63,18 @@
/** Constructor interface. */
- RankFormatter* _RankFormatter_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- StreamFormatter_FormatFunction* _format );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define RANKFORMATTER_DEFARGS \
+ LINEFORMATTER_DEFARGS
+
+ #define RANKFORMATTER_PASSARGS \
+ LINEFORMATTER_PASSARGS
+
+ RankFormatter* _RankFormatter_New( RANKFORMATTER_DEFARGS );
/** Init interface. */
void _RankFormatter_Init(
@@ -83,7 +88,8 @@
void _RankFormatter_Print( void* formatter, Stream* stream );
-#endif /* __Base_IO_RankFormatter_h__ */
+#endif /* __StGermain_Base_IO_RankFormatter_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Stream.c
--- a/Base/IO/src/Stream.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Stream.c Tue Jan 12 14:38:16 2010 +1100
@@ -60,23 +60,13 @@ static const int STREAM_CHILDREN_DELTA =
/** Returns True if the current process is allowed to print. */
Bool _Stream_IsPrintingRank( Stream* stream );
-Stream* _Stream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile )
+Stream* _Stream_New( STREAM_DEFARGS )
{
Stream* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(Stream) );
- self = (Stream*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (Stream*)_Stg_Class_New( STG_CLASS_PASSARGS );
_Stream_Init( self, name, _printf, _write, _dump, _setFile );
@@ -324,6 +314,7 @@ SizeT Stream_Write( Stream *stream, void
}
return result;
}
+
Bool Stream_Dump( Stream *stream, void *data )
{
Bool result;
@@ -364,6 +355,39 @@ Bool Stream_RedirectFile( Stream* stream
return Stream_SetFile( stream, file );
}
+Bool Stream_RedirectAllToFile( const char* const fileName ) {
+ char* infoStreamFilename;
+ char* debugStreamFilename;
+ char* dumpStreamFilename;
+ char* errorStreamFilename;
+
+ Stg_asprintf( &infoStreamFilename, "%s.info", fileName );
+ Stg_asprintf( &debugStreamFilename, "%s.debug", fileName );
+ Stg_asprintf( &dumpStreamFilename, "%s.dump", fileName );
+ Stg_asprintf( &errorStreamFilename, "%s.error", fileName );
+
+ if( Stream_RedirectFile( Journal_GetTypedStream( Info_Type ), infoStreamFilename ) &&
+ Stream_RedirectFile( Journal_GetTypedStream( Debug_Type ), debugStreamFilename ) &&
+ Stream_RedirectFile( Journal_GetTypedStream( Dump_Type ), dumpStreamFilename ) &&
+ Stream_RedirectFile( Journal_GetTypedStream( Error_Type ), errorStreamFilename ) ) {
+
+ Stream_ClearCustomFormatters( Journal_GetTypedStream( Info_Type ) );
+ Stream_ClearCustomFormatters( Journal_GetTypedStream( Debug_Type ) );
+ Stream_ClearCustomFormatters( Journal_GetTypedStream( Dump_Type ) );
+ Stream_ClearCustomFormatters( Journal_GetTypedStream( Error_Type ) );
+
+ return True;
+ }
+ else
+ return False;
+}
+
+void Stream_PurgeAllRedirectedFiles( void ) {
+ Stream_CloseAndFreeFile( Journal_GetTypedStream( Info_Type ) );
+ Stream_CloseAndFreeFile( Journal_GetTypedStream( Debug_Type ) );
+ Stream_CloseAndFreeFile( Journal_GetTypedStream( Dump_Type ) );
+ Stream_CloseAndFreeFile( Journal_GetTypedStream( Error_Type ) );
+}
Bool Stream_RedirectFileBranch( Stream* stream, const char* const fileName ) {
JournalFile* file;
@@ -717,3 +741,5 @@ Bool _Stream_IsPrintingRank( Stream* str
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/Stream.h
--- a/Base/IO/src/Stream.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/Stream.h Tue Jan 12 14:38:16 2010 +1100
@@ -43,8 +43,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_IO_Stream_h__
-#define __Base_IO_Stream_h__
+#ifndef __StGermain_Base_IO_Stream_h__
+#define __StGermain_Base_IO_Stream_h__
#include <stdarg.h>
@@ -90,17 +90,28 @@
struct Stream { __Stream };
/** Constructor interface. */
- Stream* _Stream_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Name name,
- Stream_PrintfFunction* _printf,
- Stream_WriteFunction* _write,
- Stream_DumpFunction* _dump,
- Stream_SetFileFunction* _setFile );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STREAM_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ Name name, \
+ Stream_PrintfFunction* _printf, \
+ Stream_WriteFunction* _write, \
+ Stream_DumpFunction* _dump, \
+ Stream_SetFileFunction* _setFile
+
+ #define STREAM_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ name, \
+ _printf, \
+ _write, \
+ _dump, \
+ _setFile
+
+ Stream* _Stream_New( STREAM_DEFARGS );
/** Init interface. */
void _Stream_Init(
@@ -136,6 +147,13 @@
Defaults CFile for now. TODO for next io commit */
Bool Stream_RedirectFile( Stream* stream, const char* const fileName );
+ /** Opens a registers a file for all the stream if not already opened and assigns it for output
+ Defaults CFile for now. TODO for next io commit */
+ Bool Stream_RedirectAllToFile( const char* const fileName );
+
+ /** Purges all redirected stream files */
+ void Stream_PurgeAllRedirectedFiles( void );
+
/** Opens a registers a file for this stream if not already opened and assigns it for output for whole branch */
Bool Stream_RedirectFileBranch( Stream* stream, const char* const fileName );
@@ -262,4 +280,5 @@
/* Closes, deregisters and deletes the JournalFile associated with this stream */
void Stream_CloseAndFreeFile( void* stream ) ;
-#endif /* __Base_IO_Stream_h__ */
+#endif /* __StGermain_Base_IO_Stream_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/StreamFormatter.c
--- a/Base/IO/src/StreamFormatter.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/StreamFormatter.c Tue Jan 12 14:38:16 2010 +1100
@@ -42,19 +42,13 @@
const Type StreamFormatter_Type = "StreamFormatter";
-StreamFormatter* _StreamFormatter_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- StreamFormatter_FormatFunction* _format )
+StreamFormatter* _StreamFormatter_New( STREAMFORMATTER_DEFARGS )
{
StreamFormatter* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(StreamFormatter) );
- self = (StreamFormatter*)_Stg_Class_New( _sizeOfSelf, type, _delete, _print, _copy );
+ self = (StreamFormatter*)_Stg_Class_New( STG_CLASS_PASSARGS );
_StreamFormatter_Init( self, _format );
@@ -169,3 +163,5 @@ char* StreamFormatter_Buffer_AllocNext(
return *stgStreamFormatter_Buffer->current;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/StreamFormatter.h
--- a/Base/IO/src/StreamFormatter.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/StreamFormatter.h Tue Jan 12 14:38:16 2010 +1100
@@ -42,8 +42,8 @@
**
**/
-#ifndef __Base_IO_StreamFormatter_h__
-#define __Base_IO_StreamFormatter_h__
+#ifndef __StGermain_Base_IO_StreamFormatter_h__
+#define __StGermain_Base_IO_StreamFormatter_h__
/** Textual name for StreamFormatter class. */
@@ -64,13 +64,20 @@
/** Constructor interface. */
- StreamFormatter* _StreamFormatter_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- StreamFormatter_FormatFunction* _format );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define STREAMFORMATTER_DEFARGS \
+ STG_CLASS_DEFARGS, \
+ StreamFormatter_FormatFunction* _format
+
+ #define STREAMFORMATTER_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ _format
+
+ StreamFormatter* _StreamFormatter_New( STREAMFORMATTER_DEFARGS );
/** Init interface. */
void _StreamFormatter_Init(
@@ -107,4 +114,5 @@
void StreamFormatter_Buffer_Delete( StreamFormatter_Buffer* buffer );
char* StreamFormatter_Buffer_AllocNext( Index size );
-#endif /* __Base_IO_StreamFormatter_h__ */
+#endif /* __StGermain_Base_IO_StreamFormatter_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/XML_IO_Handler.c
--- a/Base/IO/src/XML_IO_Handler.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/XML_IO_Handler.c Tue Jan 12 14:38:16 2010 +1100
@@ -35,6 +35,8 @@
#include "Dictionary_Entry_Value.h"
#include "IO_Handler.h"
#include "Journal.h"
+#include "JournalFile.h"
+#include "Stream.h"
#include "PathUtils.h"
#include <libxml/tree.h>
#include "XML_IO_Handler.h"
@@ -162,9 +164,22 @@ static void _XML_IO_Handler_WriteParamet
XML_IO_Handler* XML_IO_Handler_New( void ) {
- return _XML_IO_Handler_New( sizeof(XML_IO_Handler), XML_IO_Handler_Type, _XML_IO_Handler_Delete, _XML_IO_Handler_Print,
- NULL, _XML_IO_Handler_ReadAllFromFile, _XML_IO_Handler_ReadAllFromFileForceSource, _XML_IO_Handler_ReadAllFromBuffer, _XML_IO_Handler_WriteAllToFile, _XML_IO_Handler_WriteEntryToFile,
- _XML_IO_Handler_SetListEncoding, _XML_IO_Handler_SetWritingPrecision, _XML_IO_Handler_SetWriteExplicitTypes );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(XML_IO_Handler);
+ Type type = XML_IO_Handler_Type;
+ Stg_Class_DeleteFunction* _delete = _XML_IO_Handler_Delete;
+ Stg_Class_PrintFunction* _print = _XML_IO_Handler_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+ IO_Handler_ReadAllFromFileFunction* _readAllFromFile = _XML_IO_Handler_ReadAllFromFile;
+ IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource = _XML_IO_Handler_ReadAllFromFileForceSource;
+ IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer = _XML_IO_Handler_ReadAllFromBuffer;
+ IO_Handler_WriteAllToFileFunction* _writeAllToFile = _XML_IO_Handler_WriteAllToFile;
+ XML_IO_Handler_WriteEntryToFileFunction* _writeEntryToFile = _XML_IO_Handler_WriteEntryToFile;
+ XML_IO_Handler_SetListEncodingFunction* _setListEncoding = _XML_IO_Handler_SetListEncoding;
+ XML_IO_Handler_SetWritingPrecisionFunction* _setWritingPrecision = _XML_IO_Handler_SetWritingPrecision;
+ XML_IO_Handler_SetWriteExplicitTypesFunction* _setWriteExplicitTypes = _XML_IO_Handler_SetWriteExplicitTypes;
+
+ return _XML_IO_Handler_New( XML_IO_HANDLER_PASSARGS );
}
XML_IO_Handler* XML_IO_Handler_New_Schema( XML_IO_Handler* old );
@@ -189,35 +204,13 @@ void XML_IO_Handler_Init( XML_IO_Handler
_XML_IO_Handler_Init( self );
}
-XML_IO_Handler* _XML_IO_Handler_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- IO_Handler_ReadAllFromFileFunction* _readAllFromFile,
- IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource,
- IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer,
- IO_Handler_WriteAllToFileFunction* _writeAllToFile,
- XML_IO_Handler_WriteEntryToFileFunction* _writeEntryToFile,
- XML_IO_Handler_SetListEncodingFunction* _setListEncoding,
- XML_IO_Handler_SetWritingPrecisionFunction* _setWritingPrecision,
- XML_IO_Handler_SetWriteExplicitTypesFunction* _setWriteExplicitTypes )
+XML_IO_Handler* _XML_IO_Handler_New( XML_IO_HANDLER_DEFARGS )
{
XML_IO_Handler* self;
/* Allocate memory */
assert( _sizeOfSelf >= sizeof(XML_IO_Handler) );
- self = (XML_IO_Handler*)_IO_Handler_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _readAllFromFile,
- _readAllFromFileForceSource,
- _readAllFromBuffer,
- _writeAllToFile );
+ self = (XML_IO_Handler*)_IO_Handler_New( IO_HANDLER_PASSARGS );
/* General info */
@@ -534,11 +527,6 @@ void _XML_IO_Handler_AddSearchPath( void
self->searchPaths[ self->searchPathsSize - 1 ] = StG_Strdup( path );
}
-
-
-
-
-
/** Read all parameters from a file implementation. See IO_Handler_ReadAllFromFile(). It will first check if the file
* exists, and contains valid XML. */
Bool _XML_IO_Handler_ReadAllFromFile( void* xml_io_handler, const char* filename, Dictionary* dictionary ) {
@@ -613,10 +601,10 @@ Bool _XML_IO_Handler_ReadAllFromFile( vo
_XML_IO_Handler_AddSearchPath( self, STG_INCLUDE_PATH );
#endif
-
-
/* open the file and check syntax */
if ( !(rootElement = _XML_IO_Handler_OpenCheckFile( self, filename )) ) {
+ if( self->currDoc )
+ xmlFreeDoc( self->currDoc );
return False;
}
@@ -627,7 +615,8 @@ Bool _XML_IO_Handler_ReadAllFromFile( vo
_XML_IO_Handler_ParseNodes( self, firstElement, NULL, IO_Handler_DefaultMergeType, NULL );
/* free memory */
- xmlFreeDoc( self->currDoc );
+ if( self->currDoc )
+ xmlFreeDoc( self->currDoc );
xmlCleanupParser();
return True;
@@ -667,7 +656,8 @@ Bool _XML_IO_Handler_ReadAllFromFileForc
_XML_IO_Handler_ParseNodes( self, firstElement, NULL, Dictionary_MergeType_Replace, (char*) rootElement->doc->URL );
/* free memory */
- xmlFreeDoc( self->currDoc );
+ if( self->currDoc )
+ xmlFreeDoc( self->currDoc );
xmlCleanupParser();
return True;
@@ -692,7 +682,8 @@ Bool _XML_IO_Handler_ReadAllFromBuffer(
_XML_IO_Handler_ParseNodes( self, rootElement, NULL, Dictionary_MergeType_Replace, NULL );
/* free memory */
- xmlFreeDoc( self->currDoc );
+ if( self->currDoc )
+ xmlFreeDoc( self->currDoc );
xmlCleanupParser();
return True;
@@ -702,31 +693,46 @@ Bool _XML_IO_Handler_ReadAllFromBuffer(
* \return a pointer to the root node if the file is valid, NULL otherwise. */
static xmlNodePtr _XML_IO_Handler_OpenCheckFile( XML_IO_Handler* self, const char* filename )
{
- xmlChar absolute[1024];
- xmlNodePtr cur = NULL;
+ xmlChar absolute[1024];
+ xmlNodePtr cur = NULL;
+ Bool status = False;
- if ( FindFileInPathList(
- (char*)absolute,
- (char*)filename,
- self->searchPaths,
- self->searchPathsSize ) )
- {
- _XML_IO_Handler_OpenFile( self, (char*)absolute );
- }
+ if ( !FindFileInPathList(
+ (char*)absolute,
+ (char*)filename,
+ self->searchPaths,
+ self->searchPathsSize ) )
+ {
+ Journal_RPrintf( Journal_Register( Error_Type, XML_IO_Handler_Type ),
+ "Error: File %s doesn't exist, not readable, or not valid.\n", filename );
+ exit(EXIT_FAILURE);
+ }
- Journal_Firewall( self->currDoc != NULL,
- Journal_Register( Error_Type, XML_IO_Handler_Type ),
- "Error: File %s doesn't exist, not readable, or not valid.\n",
- filename );
+ _XML_IO_Handler_OpenFile( self, (char*)absolute );
- cur = xmlDocGetRootElement( self->currDoc );
- Journal_Firewall( _XML_IO_Handler_Check( self, self->currDoc ),
- Journal_Register( Error_Type, XML_IO_Handler_Type ),
- "Error: File %s not valid/readable.\n",
- filename );
+ if( self->currDoc == NULL ) {
+ Journal_RPrintf( Journal_Register( Error_Type, XML_IO_Handler_Type ),
+ "Error: File %s doesn't exist, not readable, or not valid.\n", filename );
+ exit(EXIT_FAILURE);
+ }
- return cur;
-
+ if( self->currDoc != NULL ) {
+ cur = xmlDocGetRootElement( self->currDoc );
+ status = _XML_IO_Handler_Check( self, self->currDoc );
+
+ if( !status ) {
+ Journal_RPrintf( Journal_Register( Error_Type, XML_IO_Handler_Type ),
+ "Error: File %s not valid/readable.\n", filename );
+ exit(EXIT_FAILURE);
+ }
+
+ if( status == True )
+ return cur;
+ else
+ return NULL;
+ }
+ else
+ return NULL;
}
static xmlNodePtr _XML_IO_Handler_OpenCheckBuffer( XML_IO_Handler* self, const char* buffer ) {
@@ -747,6 +753,7 @@ static xmlNodePtr _XML_IO_Handler_OpenCh
return rootElement;
}
+#if 0
static void _processNode(xmlTextReaderPtr reader) {
const xmlChar *name, *value;
@@ -771,16 +778,18 @@ static void _processNode(xmlTextReaderPt
printf(" %s\n", value);
}
}
+#endif
static void _XML_IO_Handler_ValidateFile( XML_IO_Handler* self, const char* filename ) {
+ #ifdef LIBXML_VERSION
+ #if LIBXML_VERSION == 20631
xmlTextReaderPtr reader;
- int ret, valid;
+ //int valid;
+ int ret;
reader = xmlNewTextReaderFilename( filename );
if ( reader != NULL ) {
- #ifdef LIBXML_VERSION
- #if LIBXML_VERSION == 20631
xmlNodePtr cur = NULL;
cur = xmlDocGetRootElement( self->currDoc );
@@ -822,11 +831,12 @@ static void _XML_IO_Handler_ValidateFile
if (ret !=0) {
fprintf( stderr, "%s : failed to parse\n", filename );
}
- #endif
- #endif
} else {
fprintf( stderr, "unable to open %s\n", filename );
}
+ #endif
+ #endif
+ //xmlFree ( reader );
}
static void _XML_IO_Handler_OpenFile( XML_IO_Handler* self, const char* filename ) {
@@ -853,21 +863,18 @@ static void _XML_IO_Handler_OpenBuffer(
}
Bool _XML_IO_Handler_Check( XML_IO_Handler* self, xmlDocPtr currDoc ) {
- xmlNodePtr rootElement = NULL;
- xmlNodePtr cur = NULL;
+ xmlNodePtr rootElement = NULL;
rootElement = xmlDocGetRootElement( self->currDoc );
- if (rootElement == NULL) {
+ if ( !rootElement ) {
Journal_Printf(
Journal_Register( Error_Type, XML_IO_Handler_Type ),
"Error: empty document. Not parsing.\n" );
- xmlFreeDoc( self->currDoc );
return False;
}
/* check the namespace */
- if( False == _XML_IO_Handler_CheckNameSpace( self, rootElement ) ) {
- xmlFreeDoc( self->currDoc );
+ if( _XML_IO_Handler_CheckNameSpace( self, rootElement ) == False ) {
return False;
}
@@ -879,7 +886,6 @@ Bool _XML_IO_Handler_Check( XML_IO_Handl
self->resource,
(const char*) rootElement->name,
ROOT_NODE_NAME );
- xmlFreeDoc( self->currDoc );
return False;
}
@@ -970,6 +976,7 @@ Bool _XML_IO_Handler_CheckNameSpace( XML
}
}
}
+ xmlFree( nsArray );
}
Memory_Free( correctNameSpace );
@@ -1040,7 +1047,8 @@ static void _XML_IO_Handler_ParseNodes(
_XML_IO_Handler_AddSearchPath( self, (char*)tmp );
- Memory_Free( tmp );
+ xmlFree( path );
+ //free( tmp );
}
else if ( (0 == xmlStrcmp( cur->name, (const xmlChar *) INCLUDE_TAG ) ) &&
( cur->ns == self->currNameSpace ) )
@@ -1139,23 +1147,22 @@ static void _XML_IO_Handler_ParseElement
( cur->ns == self->currNameSpace ) ) {
_XML_IO_Handler_ParseStruct( self, cur, parent, mergeType, source );
}
+ xmlFree( name );
}
static void _XML_IO_Handler_ParseComponents( XML_IO_Handler* self, xmlNodePtr cur, Dictionary_Entry_Value* parent,
Dictionary_MergeType defaultMergeType, Dictionary_Entry_Source source )
{
- xmlChar* name = (xmlChar*) "name";
- xmlNewProp( cur, (xmlChar*) NAME_ATTR, (xmlChar*) name );
- xmlSetProp( cur, (xmlChar*) NAME_ATTR, "components" );
+ xmlNewProp( cur, (xmlChar*) NAME_ATTR, (xmlChar*) "name" );
+ xmlSetProp( cur, (xmlChar*) NAME_ATTR, (xmlChar*)"components" );
_XML_IO_Handler_ParseStruct( self, cur, parent, defaultMergeType, source );
}
static void _XML_IO_Handler_ParsePlugins( XML_IO_Handler* self, xmlNodePtr cur, Dictionary_Entry_Value* parent,
Dictionary_MergeType defaultMergeType, Dictionary_Entry_Source source )
{
- xmlChar* name = (xmlChar*) "name";
- xmlNewProp( cur, (xmlChar*) NAME_ATTR, (xmlChar*) name );
- xmlSetProp( cur, (xmlChar*) NAME_ATTR, "plugins" );
+ xmlNewProp( cur, (xmlChar*) NAME_ATTR, (xmlChar*) "name" );
+ xmlSetProp( cur, (xmlChar*) NAME_ATTR, (xmlChar*)"plugins" );
_XML_IO_Handler_ParseList( self, cur, parent, defaultMergeType, source );
}
@@ -1168,9 +1175,8 @@ static void _XML_IO_Handler_ParseImport(
static void _XML_IO_Handler_ParseImport( XML_IO_Handler* self, xmlNodePtr cur, Dictionary_Entry_Value* parent,
Dictionary_MergeType defaultMergeType, Dictionary_Entry_Source source )
{
- xmlChar* name = (xmlChar*) "name";
- xmlNewProp( cur, (xmlChar*) NAME_ATTR, (xmlChar*) name );
- xmlSetProp( cur, (xmlChar*) NAME_ATTR, "import" );
+ xmlNewProp( cur, (xmlChar*) NAME_ATTR, (xmlChar*) "name" );
+ xmlSetProp( cur, (xmlChar*) NAME_ATTR, (xmlChar*)"import" );
_XML_IO_Handler_ParseList( self, cur, parent, defaultMergeType, source );
}
@@ -1191,8 +1197,6 @@ static void _XML_IO_Handler_ParseList( X
xmlChar* childrenMergeTypeStr = xmlGetProp( cur, CHILDRENMERGETYPE_ATTR );
xmlChar* spaceStrippedName = NULL;
xmlChar* spaceStrippedSourceFile = NULL;
- xmlChar* spaceStrippedMergeType = NULL;
- xmlChar* spaceStrippedChildrenMergeType = NULL;
Dictionary_Entry_Value* newList = NULL;
Dictionary_MergeType mergeType = defaultMergeType;
Dictionary_MergeType childrenMergeType = Dictionary_MergeType_Append;
@@ -1382,6 +1386,7 @@ static void _XML_IO_Handler_ParseColumnD
ColumnInfo columnInfo[MAX_COLUMNS], int* const numColumnsPtr )
{
char* stringPtr;
+
/* read any column definitions */
while ( (XML_ELEMENT_NODE == cur->type) &&
(0 == xmlStrcmp( cur->name, (const xmlChar *) COLUMN_DEFINITION_TAG ) ) &&
@@ -1438,11 +1443,11 @@ static char* _XML_IO_Handler_GetNextAsci
/** parses a node containing struct info. */
static void _XML_IO_Handler_ParseStruct(
- XML_IO_Handler* self,
- xmlNodePtr cur,
- Dictionary_Entry_Value* parent,
- Dictionary_MergeType defaultMergeType,
- Dictionary_Entry_Source source )
+ XML_IO_Handler* self,
+ xmlNodePtr cur,
+ Dictionary_Entry_Value* parent,
+ Dictionary_MergeType defaultMergeType,
+ Dictionary_Entry_Source source )
{
xmlChar* name = xmlGetProp( cur, NAME_ATTR );
xmlChar* sourceFile = xmlGetProp( cur, SOURCEFILE_ATTR );
@@ -1450,8 +1455,6 @@ static void _XML_IO_Handler_ParseStruct(
xmlChar* childrenMergeTypeStr = xmlGetProp( cur, CHILDRENMERGETYPE_ATTR );
xmlChar* spaceStrippedName = NULL;
xmlChar* spaceStrippedSourceFile = NULL;
- xmlChar* spaceStrippedMergeType = NULL;
- xmlChar* spaceStrippedChildrenMergeType = NULL;
Dictionary_Entry_Value* newStruct = NULL;
Dictionary_MergeType mergeType = defaultMergeType;
Dictionary_MergeType childrenMergeType = IO_Handler_DefaultChildrenMergeType;
@@ -1515,7 +1518,6 @@ static void _XML_IO_Handler_ParseParamet
Dictionary_Entry_Value_Type dictValueType = _XML_IO_Handler_GetDictValueType( self, (char*) type );
xmlChar* spaceStrippedName = NULL;
xmlChar* spaceStrippedSourceFile = NULL;
- xmlChar* spaceStrippedMergeType = NULL;
xmlChar* spaceStrippedType = NULL;
xmlChar* strippedVal = NULL;
Dictionary_MergeType mergeType = defaultMergeType;
@@ -1792,7 +1794,8 @@ Bool _XML_IO_Handler_WriteAllToFile( voi
}
/* Memory_Free memory */
- xmlFreeDoc( self->currDoc );
+ if( self->currDoc )
+ xmlFreeDoc( self->currDoc );
/*xmlCleanupParser(); */
/* TODO if updating, xmlCleanupParser(); */
self->currDoc = NULL;
@@ -1863,16 +1866,16 @@ Bool _XML_IO_Handler_WriteEntryToFile( v
/* write result to file */
if ( 0 < (fileSize = xmlSaveFormatFile( filename, self->currDoc, 1 )) ) {
Journal_Printf( stream, "Writing dictionary entry %s to file %s successfully concluded.\n", name, filename );
- } else
- {
+ }
+ else {
Journal_Printf(
Journal_Register( Error_Type, XML_IO_Handler_Type ),
"Warning: failed to write dictionary entry %s to file %s.\n",
name,
filename );
}
-
- xmlFreeDoc( self->currDoc );
+ if( self->currDoc )
+ xmlFreeDoc( self->currDoc );
/*xmlCleanupParser();*/
/* TODO if updating, xmlCleanupParser(); */
self->currDoc = NULL;
@@ -1896,7 +1899,7 @@ static void _XML_IO_Handler_WriteDiction
for (index=0; index < dict->count; index++) {
Dictionary_Entry* currEntryPtr = dict->entryPtr[index];
- if ( strcmp(currEntryPtr->key, IMPORT_TAG) == 0 )
+ if ( strcmp(currEntryPtr->key, (const char*)IMPORT_TAG) == 0 )
_XML_IO_Handler_WriteNode( self, currEntryPtr->key, currEntryPtr->value, currEntryPtr->source, parent );
}
@@ -1904,7 +1907,7 @@ static void _XML_IO_Handler_WriteDiction
for (index=0; index < dict->count; index++) {
Dictionary_Entry* currEntryPtr = dict->entryPtr[index];
- if ( strcmp(currEntryPtr->key, PLUGINS_TAG) == 0 )
+ if ( strcmp(currEntryPtr->key, (const char*)PLUGINS_TAG) == 0 )
_XML_IO_Handler_WriteNode( self, currEntryPtr->key, currEntryPtr->value, currEntryPtr->source, parent );
}
@@ -1912,7 +1915,7 @@ static void _XML_IO_Handler_WriteDiction
for (index=0; index < dict->count; index++) {
Dictionary_Entry* currEntryPtr = dict->entryPtr[index];
- if ( ( strcmp(currEntryPtr->key, IMPORT_TAG) != 0 ) && ( strcmp(currEntryPtr->key, PLUGINS_TAG) != 0 ) )
+ if ( ( strcmp(currEntryPtr->key, (const char*)IMPORT_TAG) != 0 ) && ( strcmp(currEntryPtr->key, (const char*)PLUGINS_TAG) != 0 ) )
_XML_IO_Handler_WriteNode( self, currEntryPtr->key, currEntryPtr->value, currEntryPtr->source, parent );
}
}
@@ -1947,10 +1950,10 @@ static void _XML_IO_Handler_WriteList( X
/* create and add list child node */
if ( NULL != name ) {
- if ( strcmp(name, PLUGINS_TAG) == 0 ) {
+ if ( strcmp(name, (const char*)PLUGINS_TAG) == 0 ) {
newNode = xmlNewTextChild( parent, self->currNameSpace, PLUGINS_TAG, NULL );
}
- else if ( strcmp(name, IMPORT_TAG) == 0 ) {
+ else if ( strcmp(name, (const char*)IMPORT_TAG) == 0 ) {
newNode = xmlNewTextChild( parent, self->currNameSpace, IMPORT_TAG, NULL );
}
else
@@ -2236,7 +2239,7 @@ static void _XML_IO_Handler_WriteStruct(
/* create and add struct child node*/
if ( NULL != name ) {
- if ( strcmp(name, COMPONENTS_TAG) == 0 ) {
+ if ( strcmp(name, (const char*)COMPONENTS_TAG) == 0 ) {
newNode = xmlNewTextChild( parent, self->currNameSpace, COMPONENTS_TAG, NULL );
}
else
@@ -2275,10 +2278,10 @@ static void _XML_IO_Handler_WriteParamet
"_XML_IO_Handler_WriteParameter called.\n");
/* add new child to parent, with correct value*/
- if ( strcmp((char *)parent->name, PLUGINS_TAG) == 0 ) {
+ if ( strcmp((char *)parent->name, (const char*)PLUGINS_TAG) == 0 ) {
newNode = xmlNewTextChild( parent, self->currNameSpace, PLUGIN_TAG, (xmlChar*) Dictionary_Entry_Value_AsString( value ) );
}
- else if ( strcmp((char *)parent->name, IMPORT_TAG) == 0 ) {
+ else if ( strcmp((char *)parent->name, (const char*)IMPORT_TAG) == 0 ) {
newNode = xmlNewTextChild( parent, self->currNameSpace, TOOLBOX_TAG, (xmlChar*) Dictionary_Entry_Value_AsString( value ) );
}
else {
@@ -2328,6 +2331,7 @@ static Dictionary_MergeType _XML_IO_Hand
XML_IO_Handler_MergeTypeMap[defaultMergeType] );
mergeType = defaultMergeType;
}
+ Memory_Free( spaceStrippedMergeType );
}
else {
mergeType = defaultMergeType;
@@ -2343,3 +2347,5 @@ void XML_IO_Handler_LibXMLErrorHandler(
Stream_Printf( Journal_Register( Error_Type, XML_IO_Handler_Type ), msg, ap );
va_end(ap);
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/XML_IO_Handler.h
--- a/Base/IO/src/XML_IO_Handler.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/XML_IO_Handler.h Tue Jan 12 14:38:16 2010 +1100
@@ -40,8 +40,8 @@
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Base_IO_XML_IO_Handler_h__
-#define __Base_IO_XML_IO_Handler_h__
+#ifndef __StGermain_Base_IO_XML_IO_Handler_h__
+#define __StGermain_Base_IO_XML_IO_Handler_h__
#include <libxml/tree.h>
@@ -81,26 +81,26 @@
__IO_Handler \
\
/* Virtual info */ \
- XML_IO_Handler_WriteEntryToFileFunction* _writeEntryToFile; \
- XML_IO_Handler_SetListEncodingFunction* _setListEncoding; \
- XML_IO_Handler_SetWritingPrecisionFunction* _setWritingPrecision; \
+ XML_IO_Handler_WriteEntryToFileFunction* _writeEntryToFile; \
+ XML_IO_Handler_SetListEncodingFunction* _setListEncoding; \
+ XML_IO_Handler_SetWritingPrecisionFunction* _setWritingPrecision; \
XML_IO_Handler_SetWriteExplicitTypesFunction* _setWriteExplicitTypes; \
\
/* XML_IO_Handler */ \
- NameSpaceInfo* nameSpacesList; /**< Allows chain of namespaces. */\
- xmlDocPtr currDoc; \
- xmlNsPtr currNameSpace; \
- int tokeniserCalls; \
- ListEncoding listEncoding; \
- Stg_ObjectList* typeKeywords; /**< Maps strings to dictionary types. */\
- char* TYPE_KEYWORDS[Dictionary_Entry_Value_Num_Types + 1]; \
- unsigned int writingPrecision[Dictionary_Entry_Value_Num_Types + 1]; \
- unsigned int writingFieldWidth[Dictionary_Entry_Value_Num_Types + 1]; \
- unsigned int WRITING_FIELD_EXTRAS[Dictionary_Entry_Value_Num_Types + 1]; \
- Bool writeExplicitTypes; \
+ NameSpaceInfo* nameSpacesList; /**< Allows chain of namespaces. */\
+ xmlDocPtr currDoc; \
+ xmlNsPtr currNameSpace; \
+ int tokeniserCalls; \
+ ListEncoding listEncoding; \
+ Stg_ObjectList* typeKeywords; /**< Maps strings to dictionary types. */\
+ char* TYPE_KEYWORDS[Dictionary_Entry_Value_Num_Types + 1]; \
+ unsigned int writingPrecision[Dictionary_Entry_Value_Num_Types + 1]; \
+ unsigned int writingFieldWidth[Dictionary_Entry_Value_Num_Types + 1]; \
+ unsigned int WRITING_FIELD_EXTRAS[Dictionary_Entry_Value_Num_Types + 1]; \
+ Bool writeExplicitTypes; \
\
- unsigned searchPathsSize; \
- char** searchPaths;
+ unsigned searchPathsSize; \
+ char** searchPaths;
struct _XML_IO_Handler { __XML_IO_Handler };
@@ -108,20 +108,26 @@
XML_IO_Handler* XML_IO_Handler_New( void );
/** Creation implementation */
- XML_IO_Handler* _XML_IO_Handler_New(
- SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- IO_Handler_ReadAllFromFileFunction* _readAllFromFile,
- IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource,
- IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer,
- IO_Handler_WriteAllToFileFunction* _writeAllToFile,
- XML_IO_Handler_WriteEntryToFileFunction* _writeEntryToFile,
- XML_IO_Handler_SetListEncodingFunction* _setListEncoding,
- XML_IO_Handler_SetWritingPrecisionFunction* _setWritingPrecision,
- XML_IO_Handler_SetWriteExplicitTypesFunction* _setWriteExplicitTypes );
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define XML_IO_HANDLER_DEFARGS \
+ IO_HANDLER_DEFARGS, \
+ XML_IO_Handler_WriteEntryToFileFunction* _writeEntryToFile, \
+ XML_IO_Handler_SetListEncodingFunction* _setListEncoding, \
+ XML_IO_Handler_SetWritingPrecisionFunction* _setWritingPrecision, \
+ XML_IO_Handler_SetWriteExplicitTypesFunction* _setWriteExplicitTypes
+
+ #define XML_IO_HANDLER_PASSARGS \
+ IO_HANDLER_PASSARGS, \
+ _writeEntryToFile, \
+ _setListEncoding, \
+ _setWritingPrecision, \
+ _setWriteExplicitTypes
+
+ XML_IO_Handler* _XML_IO_Handler_New( XML_IO_HANDLER_DEFARGS );
/** Initialise a XML_IO_Handler construct */
void XML_IO_Handler_Init( XML_IO_Handler* self );
@@ -179,4 +185,5 @@
* up using xmlSetGenericErrorFunc(), e.g. at the Init() stage. */
void XML_IO_Handler_LibXMLErrorHandler( void* ctx, const char* msg, ... );
-#endif /* __Base_IO_XML_IO_Handler_h__ */
+#endif /* __StGermain_Base_IO_XML_IO_Handler_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/forwardDecl.h
--- a/Base/IO/src/forwardDecl.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/forwardDecl.h Tue Jan 12 14:38:16 2010 +1100
@@ -39,8 +39,8 @@
* the StGermain framework.
*/
-#ifndef __Base_IO_forwardDecl_h__
-#define __Base_IO_forwardDecl_h__
+#ifndef __StGermain_Base_IO_forwardDecl_h__
+#define __StGermain_Base_IO_forwardDecl_h__
/* Forward Declaration of PtrMap ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/shortcuts.c
--- a/Base/IO/src/shortcuts.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/shortcuts.c Tue Jan 12 14:38:16 2010 +1100
@@ -177,3 +177,5 @@ void Journal_PrintString_WithLength( Str
Journal_Printf( stream, string );
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/shortcuts.h
--- a/Base/IO/src/shortcuts.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/shortcuts.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_IO_shortcuts_h__
-#define __Base_IO_shortcuts_h__
+#ifndef __StGermain_Base_IO_shortcuts_h__
+#define __StGermain_Base_IO_shortcuts_h__
#define Printf Journal_Printf
#define Write Journal_Write
@@ -144,4 +144,4 @@
Journal_Printf( stream, "%.5g }\n", (double)array[ journalPrintArray_array_I ] ); \
} while(0)
-#endif /* __Base_IO_shortcuts_h__ */
+#endif /* __StGermain_Base_IO_shortcuts_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/stgmessaging.c
--- a/Base/IO/src/stgmessaging.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/stgmessaging.c Tue Jan 12 14:38:16 2010 +1100
@@ -127,3 +127,5 @@ int Stg_MPI_Test ( char* file, int line,
return result;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/src/types.h
--- a/Base/IO/src/types.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/src/types.h Tue Jan 12 14:38:16 2010 +1100
@@ -38,8 +38,8 @@
**
**/
-#ifndef __Base_IO_types_h__
-#define __Base_IO_types_h__
+#ifndef __StGermain_Base_IO_types_h__
+#define __StGermain_Base_IO_types_h__
/* Dicitonary internal types */
typedef char* Dictionary_Entry_Key;
@@ -86,4 +86,4 @@
typedef struct RankFormatter RankFormatter;
typedef struct IndentFormatter IndentFormatter;
-#endif /* __Base_IO_types_h__ */
+#endif /* __StGermain_Base_IO_types_h__ */
diff -r 71b60b1562af -r 767daf30b22b Base/IO/tests/DictionarySuite.c
--- a/Base/IO/tests/DictionarySuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/tests/DictionarySuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -110,22 +110,16 @@ void DictionarySuite_SetupTestDictData(
testStruct = Dictionary_Entry_Value_NewStruct();
Stg_asprintf( &testDD->testKeys[++iter], "test_struct" );
testDD->testValues[iter] = testStruct;
- Dictionary_Entry_Value_AddMember( testStruct, "height",
- Dictionary_Entry_Value_FromDouble( testDD->testStruct->height ) );
- Dictionary_Entry_Value_AddMember( testStruct, "anisotropic",
- Dictionary_Entry_Value_FromBool( testDD->testStruct->anisotropic ) );
- Dictionary_Entry_Value_AddMember( testStruct, "person",
- Dictionary_Entry_Value_FromString( testDD->testStruct->person ) );
+ Dictionary_Entry_Value_AddMember( testStruct, "height", Dictionary_Entry_Value_FromDouble( testDD->testStruct->height ) );
+ Dictionary_Entry_Value_AddMember( testStruct, "anisotropic", Dictionary_Entry_Value_FromBool( testDD->testStruct->anisotropic ) );
+ Dictionary_Entry_Value_AddMember( testStruct, "person", Dictionary_Entry_Value_FromString( testDD->testStruct->person ) );
/* Adding a 2nd struct within the first struct */
testStruct2 = Dictionary_Entry_Value_NewStruct();
Dictionary_Entry_Value_AddMember( testStruct, "geom", testStruct2 );
- Dictionary_Entry_Value_AddMember( testStruct2, "startx",
- Dictionary_Entry_Value_FromUnsignedInt( testDD->testStruct->geom.startx ) );
- Dictionary_Entry_Value_AddMember( testStruct2, "starty",
- Dictionary_Entry_Value_FromUnsignedInt( testDD->testStruct->geom.starty ) );
- Dictionary_Entry_Value_AddMember( testStruct2, "startz",
- Dictionary_Entry_Value_FromUnsignedInt( testDD->testStruct->geom.startz ) );
+ Dictionary_Entry_Value_AddMember( testStruct2, "startx", Dictionary_Entry_Value_FromUnsignedInt( testDD->testStruct->geom.startx ) );
+ Dictionary_Entry_Value_AddMember( testStruct2, "starty", Dictionary_Entry_Value_FromUnsignedInt( testDD->testStruct->geom.starty ) );
+ Dictionary_Entry_Value_AddMember( testStruct2, "startz", Dictionary_Entry_Value_FromUnsignedInt( testDD->testStruct->geom.startz ) );
}
void DictionarySuite_Setup( DictionarySuiteData* data ) {
@@ -206,14 +200,12 @@ void DictionarySuite_TestCopyCompare( Di
for( ii = 0; ii < data->dict->count; ii++ ) {
copiedDev = Dictionary_Entry_Value_Copy( data->testDD->testValues[ii], True );
- pcu_check_true( Dictionary_Entry_Value_Compare( data->testDD->testValues[ii],
- copiedDev ) );
+ pcu_check_true( Dictionary_Entry_Value_Compare( data->testDD->testValues[ii], copiedDev ) );
Dictionary_Entry_Value_Delete( copiedDev );
for( jj = 0; jj < data->dict->count; jj++ ) {
if ( ii == jj ) continue;
- pcu_check_true( False == Dictionary_Entry_Value_Compare( data->testDD->testValues[ii],
- data->testDD->testValues[jj] ) );
+ pcu_check_true( False == Dictionary_Entry_Value_Compare( data->testDD->testValues[ii], data->testDD->testValues[jj] ) );
}
}
}
@@ -247,8 +239,7 @@ void DictionarySuite_TestGet( Dictionary
DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD );
testStruct = Dictionary_Get( data->dict, "test_struct" );
- yValue = Dictionary_Entry_Value_GetMember(
- Dictionary_Entry_Value_GetMember(testStruct, "geom"), "starty");
+ yValue = Dictionary_Entry_Value_GetMember( Dictionary_Entry_Value_GetMember(testStruct, "geom"), "starty");
pcu_check_true( data->testDD->testStruct->geom.starty == Dictionary_Entry_Value_AsDouble( yValue ) );
}
@@ -257,8 +248,6 @@ void DictionarySuite_TestSet( Dictionary
Dictionary_Entry_Value* currValue;
Dictionary_Entry_Value* listValue;
double newVal1 = 34.3, newVal2 = 38.9;
- Dictionary_Entry_Value* yValue;
- Dictionary_Entry_Value* testStruct;
Index ii=0;
DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD );
@@ -296,8 +285,7 @@ void DictionarySuite_TestAddElement( Dic
/* turning the starty value into a list using add element */
testStruct = Dictionary_Get( data->dict, "test_struct" );
- yValue = Dictionary_Entry_Value_GetMember(
- Dictionary_Entry_Value_GetMember(testStruct, "geom"), "starty");
+ yValue = Dictionary_Entry_Value_GetMember( Dictionary_Entry_Value_GetMember(testStruct, "geom"), "starty");
Dictionary_Entry_Value_AddElement( yValue, Dictionary_Entry_Value_FromDouble(newVal) );
pcu_check_true( Dictionary_Entry_Value_Type_List == yValue->type );
@@ -321,36 +309,24 @@ void DictionarySuite_TestShortcuts( Dict
pcu_check_streq( data->testDD->testString, Dictionary_GetString_WithDefault( data->dict, "test_cstring", "heya" ) );
pcu_check_streq( "heya", Dictionary_GetString_WithDefault( data->dict, "test_cstring2", "heya" ) );
pcu_check_true( NULL != Dictionary_Get( data->dict, "test_cstring2" ) );
- pcu_check_true( data->testDD->testDouble =
- Dictionary_GetDouble_WithDefault( data->dict, "test_double", 2.8 ) );
- pcu_check_true( 2.8 ==
- Dictionary_GetDouble_WithDefault( data->dict, "test_double2", 2.8 ) );
+ pcu_check_true( data->testDD->testDouble = Dictionary_GetDouble_WithDefault( data->dict, "test_double", 2.8 ) );
+ pcu_check_true( 2.8 == Dictionary_GetDouble_WithDefault( data->dict, "test_double2", 2.8 ) );
pcu_check_true( NULL != Dictionary_Get( data->dict, "test_double2" ) );
- pcu_check_true( data->testDD->testUint =
- Dictionary_GetUnsignedInt_WithDefault( data->dict, "test_uint", 33 ) );
- pcu_check_true( 33 ==
- Dictionary_GetUnsignedInt_WithDefault( data->dict, "test_uint2", 33 ) );
+ pcu_check_true( data->testDD->testUint = Dictionary_GetUnsignedInt_WithDefault( data->dict, "test_uint", 33 ) );
+ pcu_check_true( 33 == Dictionary_GetUnsignedInt_WithDefault( data->dict, "test_uint2", 33 ) );
pcu_check_true( NULL != Dictionary_Get( data->dict, "test_uint2" ) );
- pcu_check_true( data->testDD->testInt =
- Dictionary_GetInt_WithDefault( data->dict, "test_int", -24 ) );
- pcu_check_true( -24 ==
- Dictionary_GetInt_WithDefault( data->dict, "test_int2", -24 ) );
+ pcu_check_true( data->testDD->testInt = Dictionary_GetInt_WithDefault( data->dict, "test_int", -24 ) );
+ pcu_check_true( -24 == Dictionary_GetInt_WithDefault( data->dict, "test_int2", -24 ) );
pcu_check_true( NULL != Dictionary_Get( data->dict, "test_int2" ) );
- pcu_check_true( data->testDD->testUnsignedlong =
- Dictionary_GetUnsignedLong_WithDefault( data->dict, "test_unsignedlong", 32433 ) );
- pcu_check_true( 32433 ==
- Dictionary_GetUnsignedLong_WithDefault( data->dict, "test_unsignedlong2", 32433 ) );
+ pcu_check_true( data->testDD->testUnsignedlong = Dictionary_GetUnsignedLong_WithDefault( data->dict, "test_unsignedlong", 32433 ) );
+ pcu_check_true( 32433 == Dictionary_GetUnsignedLong_WithDefault( data->dict, "test_unsignedlong2", 32433 ) );
pcu_check_true( NULL != Dictionary_Get( data->dict, "test_unsignedlong2" ) );
- pcu_check_true( data->testDD->testBool =
- Dictionary_GetBool_WithDefault( data->dict, "test_bool", False ) );
- pcu_check_true( False ==
- Dictionary_GetBool_WithDefault( data->dict, "test_bool2", False ) );
+ pcu_check_true( data->testDD->testBool = Dictionary_GetBool_WithDefault( data->dict, "test_bool", False ) );
+ pcu_check_true( False == Dictionary_GetBool_WithDefault( data->dict, "test_bool2", False ) );
pcu_check_true( NULL != Dictionary_Get( data->dict, "test_bool2" ) );
- pcu_check_streq( data->testDD->testString,
- Dictionary_GetString_WithPrintfDefault( data->dict, "test_cstring", "heya%s%u", "hey", 3 ) );
- pcu_check_streq( "heyahey3",
- Dictionary_GetString_WithPrintfDefault( data->dict, "test_cstring3", "heya%s%u", "hey", 3 ) );
+ pcu_check_streq( data->testDD->testString, Dictionary_GetString_WithPrintfDefault( data->dict, "test_cstring", "heya%s%u", "hey", 3 ) );
+ pcu_check_streq( "heyahey3", Dictionary_GetString_WithPrintfDefault( data->dict, "test_cstring3", "heya%s%u", "hey", 3 ) );
pcu_check_true( NULL != Dictionary_Get( data->dict, "test_cstring3" ) );
}
@@ -362,31 +338,23 @@ void DictionarySuite_TestMerge( Dictiona
Dictionary_Entry_Value* expectedMergedStruct=NULL;
testStruct2 = Dictionary_Entry_Value_NewStruct();
- Dictionary_Entry_Value_AddMember( testStruct2, "height",
- Dictionary_Entry_Value_FromDouble( data->testDD->testStruct->height ) );
- Dictionary_Entry_Value_AddMember( testStruct2, "anisotropic",
- Dictionary_Entry_Value_FromBool( False ) );
- Dictionary_Entry_Value_AddMember( testStruct2, "new_person",
- Dictionary_Entry_Value_FromString( "Luke" ) );
+ Dictionary_Entry_Value_AddMember( testStruct2, "height", Dictionary_Entry_Value_FromDouble( data->testDD->testStruct->height ) );
+ Dictionary_Entry_Value_AddMember( testStruct2, "anisotropic", Dictionary_Entry_Value_FromBool( False ) );
+ Dictionary_Entry_Value_AddMember( testStruct2, "new_person", Dictionary_Entry_Value_FromString( "Luke" ) );
testGeomStruct2 = Dictionary_Entry_Value_NewStruct();
Dictionary_Entry_Value_AddMember( testStruct2, "geom", testGeomStruct2 );
- Dictionary_Entry_Value_AddMember( testGeomStruct2, "startx",
- Dictionary_Entry_Value_FromUnsignedInt( data->testDD->testStruct->geom.startx ) );
- Dictionary_Entry_Value_AddMember( testGeomStruct2, "startz",
- Dictionary_Entry_Value_FromUnsignedInt( 222 ) );
+ Dictionary_Entry_Value_AddMember( testGeomStruct2, "startx", Dictionary_Entry_Value_FromUnsignedInt( data->testDD->testStruct->geom.startx ) );
+ Dictionary_Entry_Value_AddMember( testGeomStruct2, "startz", Dictionary_Entry_Value_FromUnsignedInt( 222 ) );
/* Testing Merge_Append */
DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD );
/* Do a copy of the DEV during merge, since we don't want it being deleted */
- Dictionary_AddMerge( data->dict, "test_struct",
- Dictionary_Entry_Value_Copy( testStruct2, True ), Dictionary_MergeType_Append );
+ Dictionary_AddMerge( data->dict, "test_struct", Dictionary_Entry_Value_Copy( testStruct2, True ), Dictionary_MergeType_Append );
/* OK: since this was an append, we expect _two_ entries called "test_struct",
* one preceding the other, one with the orig data, one with new data */
pcu_check_true( (data->testDD->testEntriesCount+1) == data->dict->count );
- pcu_check_true( Dictionary_Entry_Value_Compare( data->testDD->testValues[7],
- Dictionary_Get( data->dict, "test_struct" ) ) );
- pcu_check_true( Dictionary_Entry_Value_Compare( testStruct2,
- data->dict->entryPtr[8]->value ) );
+ pcu_check_true( Dictionary_Entry_Value_Compare( data->testDD->testValues[7], Dictionary_Get( data->dict, "test_struct" ) ) );
+ pcu_check_true( Dictionary_Entry_Value_Compare( testStruct2, data->dict->entryPtr[8]->value ) );
Dictionary_Empty( data->dict );
/* Testing Merge_Merge */
@@ -395,30 +363,23 @@ void DictionarySuite_TestMerge( Dictiona
/* The nicest way for this test I think is to manually build a merged struct
* to compare against */
expectedMergedStruct = Dictionary_Entry_Value_Copy( data->testDD->testValues[7], True );
- Dictionary_Set( expectedMergedStruct->as.typeStruct, "anisotropic",
- Dictionary_Entry_Value_FromBool( False ) );
- Dictionary_Add( expectedMergedStruct->as.typeStruct, "new_person",
- Dictionary_Entry_Value_FromString( "Luke" ) );
- Dictionary_Set( (Dictionary_Get( expectedMergedStruct->as.typeStruct, "geom" ))->as.typeStruct, "startz",
- Dictionary_Entry_Value_FromUnsignedInt( 222 ) );
+ Dictionary_Set( expectedMergedStruct->as.typeStruct, "anisotropic", Dictionary_Entry_Value_FromBool( False ) );
+ Dictionary_Add( expectedMergedStruct->as.typeStruct, "new_person", Dictionary_Entry_Value_FromString( "Luke" ) );
+ Dictionary_Set( (Dictionary_Get( expectedMergedStruct->as.typeStruct, "geom" ))->as.typeStruct, "startz", Dictionary_Entry_Value_FromUnsignedInt( 222 ) );
- Dictionary_AddMerge( data->dict, "test_struct",
- Dictionary_Entry_Value_Copy( testStruct2, True ), Dictionary_MergeType_Merge );
+ Dictionary_AddMerge( data->dict, "test_struct", Dictionary_Entry_Value_Copy( testStruct2, True ), Dictionary_MergeType_Merge );
/* This time, the new struct should be merged into the existing one */
pcu_check_true( data->testDD->testEntriesCount == data->dict->count );
mergedStruct = Dictionary_Get( data->dict, "test_struct" );
- pcu_check_true( Dictionary_Entry_Value_Compare( mergedStruct,
- expectedMergedStruct ) );
+ pcu_check_true( Dictionary_Entry_Value_Compare( mergedStruct, expectedMergedStruct ) );
Dictionary_Empty( data->dict );
Dictionary_Entry_Value_Delete( expectedMergedStruct );
/* Testing Merge_Replace */
DictionarySuite_PopulateDictWithTestValues( data->dict, data->testDD );
- Dictionary_AddMerge( data->dict, "test_struct",
- Dictionary_Entry_Value_Copy( testStruct2, True ), Dictionary_MergeType_Replace );
+ Dictionary_AddMerge( data->dict, "test_struct", Dictionary_Entry_Value_Copy( testStruct2, True ), Dictionary_MergeType_Replace );
pcu_check_true( data->testDD->testEntriesCount == data->dict->count );
- pcu_check_true( Dictionary_Entry_Value_Compare( testStruct2,
- Dictionary_Get( data->dict, "test_struct" ) ) );
+ pcu_check_true( Dictionary_Entry_Value_Compare( testStruct2, Dictionary_Get( data->dict, "test_struct" ) ) );
Dictionary_Empty( data->dict );
Dictionary_Entry_Value_Delete( testStruct2 );
@@ -448,72 +409,60 @@ void DictionarySuite_TestReadAllParamFro
Stg_asprintf( &argv[2], "--option");
Stg_asprintf( &argv[3], "--output-dir=");
Stg_asprintf( &expectedKeys[0], "output-dir" );
+
expectedVals[0] = Dictionary_Entry_Value_FromString( "" );
Stg_asprintf( &argv[4], "--Ra=1.0e4");
Stg_asprintf( &expectedKeys[1], "Ra" );
+
expectedVals[1] = Dictionary_Entry_Value_FromDouble( 1.0e4 );
Stg_asprintf( &argv[5], "--foo.bar=5");
Stg_asprintf( &expectedKeys[2], "foo" );
+
expectedVals[2] = Dictionary_Entry_Value_NewStruct();
- Dictionary_Entry_Value_AddMember( expectedVals[2], "bar",
- Dictionary_Entry_Value_FromDouble( 5 ) );
+ Dictionary_Entry_Value_AddMember( expectedVals[2], "bar", Dictionary_Entry_Value_FromDouble( 5 ) );
Stg_asprintf( &argv[6], "--vpac.csd.steve=cool");
Stg_asprintf( &expectedKeys[3], "vpac" );
+
expectedVals[3] = Dictionary_Entry_Value_NewStruct();
- Dictionary_Entry_Value_AddMember( expectedVals[3], "csd",
- tmpStruct = Dictionary_Entry_Value_NewStruct() );
- Dictionary_Entry_Value_AddMember( tmpStruct, "steve",
- Dictionary_Entry_Value_FromString( "cool" ) );
+ Dictionary_Entry_Value_AddMember( expectedVals[3], "csd", tmpStruct = Dictionary_Entry_Value_NewStruct() );
+ Dictionary_Entry_Value_AddMember( tmpStruct, "steve", Dictionary_Entry_Value_FromString( "cool" ) );
Stg_asprintf( &argv[7], "--foo.bot=7");
- Dictionary_Entry_Value_AddMember( expectedVals[2], "bot",
- Dictionary_Entry_Value_FromDouble( 7 ) );
+ Dictionary_Entry_Value_AddMember( expectedVals[2], "bot", Dictionary_Entry_Value_FromDouble( 7 ) );
Stg_asprintf( &argv[8], "--sports[]=hockey");
Stg_asprintf( &expectedKeys[4], "sports" );
+
expectedVals[4] = Dictionary_Entry_Value_NewList();
- Dictionary_Entry_Value_AddElement( expectedVals[4],
- Dictionary_Entry_Value_FromString( "hockey" ) );
+ Dictionary_Entry_Value_AddElement( expectedVals[4], Dictionary_Entry_Value_FromString( "hockey" ) );
Stg_asprintf( &argv[9], "--sports[]=chess");
/* This should be overwritten by next entry, so ignore */
Stg_asprintf( &argv[10], "--sports[1]=tennis");
- Dictionary_Entry_Value_AddElement( expectedVals[4],
- Dictionary_Entry_Value_FromString( "tennis" ) );
+ Dictionary_Entry_Value_AddElement( expectedVals[4], Dictionary_Entry_Value_FromString( "tennis" ) );
Stg_asprintf( &argv[11], "--sles[].name=pressure");
Stg_asprintf( &expectedKeys[5], "sles" );
+
expectedVals[5] = Dictionary_Entry_Value_NewList();
- Dictionary_Entry_Value_AddElement( expectedVals[5],
- tmpStruct = Dictionary_Entry_Value_NewStruct() );
- Dictionary_Entry_Value_AddMember( tmpStruct, "name",
- Dictionary_Entry_Value_FromString( "pressure" ) );
+ Dictionary_Entry_Value_AddElement( expectedVals[5], tmpStruct = Dictionary_Entry_Value_NewStruct() );
+ Dictionary_Entry_Value_AddMember( tmpStruct, "name", Dictionary_Entry_Value_FromString( "pressure" ) );
Stg_asprintf( &argv[12], "--sles[].name=temperature");
- Dictionary_Entry_Value_AddElement( expectedVals[5],
- tmpStruct2 = Dictionary_Entry_Value_NewStruct() );
- Dictionary_Entry_Value_AddMember( tmpStruct2, "name",
- Dictionary_Entry_Value_FromString( "temperature" ) );
+ Dictionary_Entry_Value_AddElement( expectedVals[5], tmpStruct2 = Dictionary_Entry_Value_NewStruct() );
+ Dictionary_Entry_Value_AddMember( tmpStruct2, "name", Dictionary_Entry_Value_FromString( "temperature" ) );
Stg_asprintf( &argv[13], "--sles[0].solver=mg");
- Dictionary_Entry_Value_AddMember( tmpStruct, "solver",
- Dictionary_Entry_Value_FromString( "mg" ) );
+ Dictionary_Entry_Value_AddMember( tmpStruct, "solver", Dictionary_Entry_Value_FromString( "mg" ) );
Stg_asprintf( &argv[14], "--sles[1].solver=direct");
- Dictionary_Entry_Value_AddMember( tmpStruct2, "solver",
- Dictionary_Entry_Value_FromString( "direct" ) );
+ Dictionary_Entry_Value_AddMember( tmpStruct2, "solver", Dictionary_Entry_Value_FromString( "direct" ) );
Stg_asprintf( &argv[15], "--some.crazy[].shit=here");
Stg_asprintf( &expectedKeys[6], "some" );
+
expectedVals[6] = Dictionary_Entry_Value_NewStruct();
- Dictionary_Entry_Value_AddMember( expectedVals[6], "crazy",
- tmpList = Dictionary_Entry_Value_NewList() );
- Dictionary_Entry_Value_AddElement( tmpList,
- tmpStruct = Dictionary_Entry_Value_NewStruct() );
- Dictionary_Entry_Value_AddMember( tmpStruct, "shit",
- Dictionary_Entry_Value_FromString( "here" ) );
+ Dictionary_Entry_Value_AddMember( expectedVals[6], "crazy", tmpList = Dictionary_Entry_Value_NewList() );
+ Dictionary_Entry_Value_AddElement( tmpList, tmpStruct = Dictionary_Entry_Value_NewStruct() );
+ Dictionary_Entry_Value_AddMember( tmpStruct, "shit", Dictionary_Entry_Value_FromString( "here" ) );
Dictionary_ReadAllParamFromCommandLine( data->dict, argc, argv );
for (ii=0; ii < numExp; ii++) {
- pcu_check_true( Dictionary_Entry_Compare(
- data->dict->entryPtr[ii],
- expectedKeys[ii]));
- pcu_check_true( Dictionary_Entry_Value_Compare(
- expectedVals[ii],
- data->dict->entryPtr[ii]->value ));
+ pcu_check_true( Dictionary_Entry_Compare( data->dict->entryPtr[ii], expectedKeys[ii]));
+ pcu_check_true( Dictionary_Entry_Value_Compare( expectedVals[ii], data->dict->entryPtr[ii]->value ));
}
for (ii=0; ii < argc; ii++) {
@@ -543,3 +492,5 @@ void DictionarySuite( pcu_suite_t* suite
pcu_suite_addTest( suite, DictionarySuite_TestMerge );
pcu_suite_addTest( suite, DictionarySuite_TestReadAllParamFromCommandLine );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/tests/IO_HandlerSuite.c
--- a/Base/IO/tests/IO_HandlerSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/tests/IO_HandlerSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <mpi.h>
@@ -55,24 +56,19 @@ typedef struct {
Dictionary* dict1;
Dictionary* dict2;
DictionarySuite_TestDictData* testDD;
- Index rank;
- Index nProcs;
+ int rank;
+ int nProcs;
MPI_Comm comm;
} IO_HandlerSuiteData;
-void _IO_HandlerSuite_CreateTestXMLFile( const char* testXMLFilename,
- const char* entriesString )
-{
+void _IO_HandlerSuite_CreateTestXMLFile( const char* testXMLFilename, const char* entriesString ) {
FILE* testFile = NULL;
testFile = fopen(testXMLFilename, "w");
- fwrite( IO_HandlerSuite_XMLStartString1, sizeof(char),
- strlen( IO_HandlerSuite_XMLStartString1 ), testFile );
- fwrite( IO_HandlerSuite_XMLStartString2, sizeof(char),
- strlen( IO_HandlerSuite_XMLStartString2 ), testFile );
+ fwrite( IO_HandlerSuite_XMLStartString1, sizeof(char), strlen( IO_HandlerSuite_XMLStartString1 ), testFile );
+ fwrite( IO_HandlerSuite_XMLStartString2, sizeof(char), strlen( IO_HandlerSuite_XMLStartString2 ), testFile );
fwrite( entriesString, sizeof(char), strlen( entriesString ), testFile );
- fwrite( IO_HandlerSuite_XMLEndString, sizeof(char),
- strlen( IO_HandlerSuite_XMLEndString ), testFile );
+ fwrite( IO_HandlerSuite_XMLEndString, sizeof(char), strlen( IO_HandlerSuite_XMLEndString ), testFile );
fclose( testFile );
}
@@ -124,10 +120,8 @@ void IO_HandlerSuite_TestWriteReadNormal
pcu_check_true( data->dict1->count == data->dict2->count );
if ( data->dict1->count == data->dict2->count ) {
for (ii=0; ii<data->dict1->count; ii++) {
- pcu_check_true( Dictionary_Entry_Compare( data->dict1->entryPtr[ii],
- data->dict2->entryPtr[ii]->key) );
- pcu_check_true( Dictionary_Entry_Value_Compare( data->dict1->entryPtr[ii]->value,
- data->dict2->entryPtr[ii]->value) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict1->entryPtr[ii], data->dict2->entryPtr[ii]->key) );
+ pcu_check_true( Dictionary_Entry_Value_Compare( data->dict1->entryPtr[ii]->value, data->dict2->entryPtr[ii]->value) );
}
}
@@ -148,10 +142,7 @@ void IO_HandlerSuite_TestWriteReadNormal
for (ii=0; ii<data->dict1->count; ii++) {
if (data->rank == 0) {
- XML_IO_Handler_WriteEntryToFile( data->io_handler, fileName,
- data->testDD->testKeys[ii],
- data->testDD->testValues[ii],
- NULL );
+ XML_IO_Handler_WriteEntryToFile( data->io_handler, fileName, data->testDD->testKeys[ii], data->testDD->testValues[ii], NULL );
}
for ( rank_I=0; rank_I< data->nProcs; rank_I++ ) {
@@ -163,10 +154,8 @@ void IO_HandlerSuite_TestWriteReadNormal
pcu_check_true( 1 == data->dict2->count );
if ( 1 == data->dict2->count ) {
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0],
- data->testDD->testKeys[ii]) );
- pcu_check_true( Dictionary_Entry_Value_Compare( data->dict2->entryPtr[0]->value,
- data->testDD->testValues[ii] ) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0], data->testDD->testKeys[ii]) );
+ pcu_check_true( Dictionary_Entry_Value_Compare( data->dict2->entryPtr[0]->value, data->testDD->testValues[ii] ) );
}
Dictionary_Empty( data->dict2 );
@@ -180,7 +169,6 @@ void IO_HandlerSuite_TestWriteReadNormal
/* Similar to above test, except test we can write out an empty Dictionary, then read in */
void IO_HandlerSuite_TestWriteReadEmpty( IO_HandlerSuiteData* data ) {
- Index ii;
const char* xmlTestFilename = "empty.xml";
FILE* testFile = NULL;
const int MAXLINE = 1000;
@@ -236,8 +224,7 @@ void IO_HandlerSuite_TestWriteExplicitTy
IO_Handler_WriteAllToFile( data->io_handler, testFilename, data->dict1 );
}
- explicitTypesExpectedFilename = Memory_Alloc_Array_Unnamed( char,
- pcu_filename_expectedLen( "explicitTypesExpected.xml" ));
+ explicitTypesExpectedFilename = Memory_Alloc_Array_Unnamed( char, pcu_filename_expectedLen( "explicitTypesExpected.xml" ));
pcu_filename_expected( "explicitTypesExpected.xml", explicitTypesExpectedFilename );
pcu_check_fileEq( testFilename, explicitTypesExpectedFilename );
@@ -250,7 +237,6 @@ void IO_HandlerSuite_TestWriteExplicitTy
void IO_HandlerSuite_TestReadWhitespaceEntries( IO_HandlerSuiteData* data ) {
- Index ii;
const char* testFilename = "xmlTest-whitespaces.xml";
char* whiteSpacesEntry = NULL;
const char* testKey = "spacedKey";
@@ -258,8 +244,7 @@ void IO_HandlerSuite_TestReadWhitespaceE
Index rank_I;
if( data->rank==0 ) {
- Stg_asprintf( &whiteSpacesEntry, "<param name=\" %s \"> \t %s \n\t</param>\n",
- testKey, testValString );
+ Stg_asprintf( &whiteSpacesEntry, "<param name=\" %s \"> \t %s \n\t</param>\n", testKey, testValString );
_IO_HandlerSuite_CreateTestXMLFile( testFilename, whiteSpacesEntry );
Memory_Free( whiteSpacesEntry );
}
@@ -274,8 +259,7 @@ void IO_HandlerSuite_TestReadWhitespaceE
pcu_check_true( 1 == data->dict2->count );
if ( 1 == data->dict2->count ) {
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0],
- (Dictionary_Entry_Key)testKey) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0], (Dictionary_Entry_Key)testKey) );
pcu_check_streq( Dictionary_Entry_Value_AsString( data->dict2->entryPtr[0]->value ), testValString );
}
@@ -290,7 +274,6 @@ void IO_HandlerSuite_TestReadWhitespaceE
/* Note: it'd be good to use the PCU input fule capabilities, but unfortunately Scons glob doesn't seem to support
* subdirectories currently. */
void IO_HandlerSuite_TestReadIncludedFile( IO_HandlerSuiteData* data ) {
- Index ii;
const char* testFilename = "xmlTest-include.xml";
const char* testIncludedFilename = "xmlTest-included.xml";
const char* testSearchPathSubdir = "./testXML-subdir";
@@ -313,13 +296,11 @@ void IO_HandlerSuite_TestReadIncludedFil
char* searchPathLine = NULL;
char* includeLineSP = NULL;
- Stg_asprintf( &xmlEntry, "<param name=\"%s\">%s</param>\n",
- testKey, testValString );
+ Stg_asprintf( &xmlEntry, "<param name=\"%s\">%s</param>\n", testKey, testValString );
Stg_asprintf( &includeLine, "<include>%s</include>\n", testIncludedFilename );
Stg_asprintf( &searchPathLine, "<searchPath>%s</searchPath>\n", testSearchPathSubdir );
Stg_asprintf( &includeLineSP, "<include>%s</include>\n", testIncludedFilenameSP );
- Stg_asprintf( &xmlTestEntries, "%s%s%s%s", xmlEntry, includeLine, searchPathLine,
- includeLineSP );
+ Stg_asprintf( &xmlTestEntries, "%s%s%s%s", xmlEntry, includeLine, searchPathLine, includeLineSP );
_IO_HandlerSuite_CreateTestXMLFile( testFilename, xmlTestEntries );
Memory_Free( xmlEntry );
Memory_Free( includeLine );
@@ -349,14 +330,11 @@ void IO_HandlerSuite_TestReadIncludedFil
pcu_check_true( 3 == data->dict2->count );
if ( 3 == data->dict2->count ) {
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0],
- (Dictionary_Entry_Key)testKey) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0], (Dictionary_Entry_Key)testKey) );
pcu_check_streq( Dictionary_Entry_Value_AsString( data->dict2->entryPtr[0]->value ), testValString );
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[1],
- (Dictionary_Entry_Key)testKeyInc) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[1], (Dictionary_Entry_Key)testKeyInc) );
pcu_check_streq( Dictionary_Entry_Value_AsString( data->dict2->entryPtr[1]->value ), testValStringInc );
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[2],
- (Dictionary_Entry_Key)testKeyIncSP) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[2], (Dictionary_Entry_Key)testKeyIncSP) );
pcu_check_streq( Dictionary_Entry_Value_AsString( data->dict2->entryPtr[2]->value ), testValStringIncSP );
}
@@ -378,14 +356,11 @@ void IO_HandlerSuite_TestReadRawDataEntr
const int list1EntryCount = 2;
const int list1Vals[2][3] = { {1, 3, 6}, {2, 9, 14} };
const char* list2Name = "boundary_conditions2";
- const int list2CompCount = 5;
const int list2EntryCount = 3;
const char* list2CompNames[5] = {"side", "xval", "yval", "zval", "active"};
- const char* list2CompTypes[5] = {"string", "int", "int", "int", "bool"};
const char* list2StringVals[3] = {"top", "bottom", "left"};
const int list2CoordVals[3][3] = { {4,5,8}, {3,5,9}, {9,3,4} };
const Bool list2BoolVals[3] = { True, False, True };
- const char* list2BoolValStrings[3] = { "True", "False", "1" };
Index rank_I;
testFilename = Memory_Alloc_Array_Unnamed( char, pcu_filename_inputLen( "xmlTest-rawData.xml" ) );
@@ -405,10 +380,8 @@ void IO_HandlerSuite_TestReadRawDataEntr
Bool boolVal = False;
pcu_check_true( 2 == data->dict2->count );
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0],
- (Dictionary_Entry_Key)list1Name) );
- pcu_check_true( Dictionary_Entry_Value_Type_List ==
- data->dict2->entryPtr[0]->value->type );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0], (Dictionary_Entry_Key)list1Name) );
+ pcu_check_true( Dictionary_Entry_Value_Type_List == data->dict2->entryPtr[0]->value->type );
for (ii=0; ii < list1EntryCount; ii++ ) {
dev = Dictionary_Entry_Value_GetElement( data->dict2->entryPtr[0]->value, ii );
intVal = Dictionary_Entry_Value_AsInt( Dictionary_Entry_Value_GetMember( dev, "0" ) );
@@ -493,10 +466,8 @@ void IO_HandlerSuite_TestReadAllFromComm
* separate files. */
pcu_check_true( data->dict1->count == data->dict2->count );
for (ii=0; ii<data->dict1->count; ii++) {
- pcu_check_true( Dictionary_Entry_Compare( data->dict1->entryPtr[ii],
- data->dict2->entryPtr[ii]->key) );
- pcu_check_true( Dictionary_Entry_Value_Compare( data->dict1->entryPtr[ii]->value,
- data->dict2->entryPtr[ii]->value) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict1->entryPtr[ii], data->dict2->entryPtr[ii]->key) );
+ pcu_check_true( Dictionary_Entry_Value_Compare( data->dict1->entryPtr[ii]->value, data->dict2->entryPtr[ii]->value) );
}
@@ -533,11 +504,6 @@ void IO_HandlerSuite_TestReadDuplicateEn
Dictionary_Entry_Value* structDev = NULL;
Dictionary_Entry_Value* elementDev = NULL;
Dictionary* structDict = NULL;
- char struct1Entry[10000];
- char struct2Entry[10000];
- char* testEntries = NULL;
- char xmlLine[1000];
- Index rank_I;
/* Only do this test for processor 0, to avoid probs with multiple opens */
if ( data->rank != 0 ) return;
@@ -550,14 +516,12 @@ void IO_HandlerSuite_TestReadDuplicateEn
IO_Handler_ReadAllFromFile( data->io_handler, xmlTestFilename1, data->dict2 );
pcu_check_true( 1 == data->dict2->count );
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0],
- (Dictionary_Entry_Key)struct1Name) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0], (Dictionary_Entry_Key)struct1Name) );
structDev = data->dict2->entryPtr[0]->value;
pcu_check_true( Dictionary_Entry_Value_Type_Struct == structDev->type );
pcu_check_true( struct1_OrigParamCount == Dictionary_Entry_Value_GetCount( structDev ) );
for (ii=0; ii < struct1_OrigParamCount; ii++ ) {
- elementDev = Dictionary_Entry_Value_GetMember( structDev,
- (Dictionary_Entry_Key)paramNames2[ii] );
+ elementDev = Dictionary_Entry_Value_GetMember( structDev, (Dictionary_Entry_Key)paramNames2[ii] );
pcu_check_true( paramVals2[ii] == Dictionary_Entry_Value_AsUnsignedInt( elementDev ) );
}
Dictionary_Empty( data->dict2 );
@@ -568,25 +532,21 @@ void IO_HandlerSuite_TestReadDuplicateEn
pcu_check_true( 2 == data->dict2->count );
/* First entry should be unchanged */
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0],
- (Dictionary_Entry_Key)struct1Name) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0], (Dictionary_Entry_Key)struct1Name) );
structDev = data->dict2->entryPtr[0]->value;
pcu_check_true( Dictionary_Entry_Value_Type_Struct == structDev->type );
pcu_check_true( struct1_OrigParamCount == Dictionary_Entry_Value_GetCount( structDev ) );
for (ii=0; ii < struct1_OrigParamCount; ii++ ) {
- elementDev = Dictionary_Entry_Value_GetMember( structDev,
- (Dictionary_Entry_Key)paramNames[ii] );
+ elementDev = Dictionary_Entry_Value_GetMember( structDev, (Dictionary_Entry_Key)paramNames[ii] );
pcu_check_true( paramVals[ii] == Dictionary_Entry_Value_AsUnsignedInt( elementDev ) );
}
/* Second entry should be struct2 */
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[1],
- (Dictionary_Entry_Key)struct1Name) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[1], (Dictionary_Entry_Key)struct1Name) );
structDev = data->dict2->entryPtr[1]->value;
pcu_check_true( Dictionary_Entry_Value_Type_Struct == structDev->type );
pcu_check_true( struct1_OrigParamCount == Dictionary_Entry_Value_GetCount( structDev ) );
for (ii=0; ii < struct1_OrigParamCount; ii++ ) {
- elementDev = Dictionary_Entry_Value_GetMember( structDev,
- (Dictionary_Entry_Key)paramNames[ii] );
+ elementDev = Dictionary_Entry_Value_GetMember( structDev, (Dictionary_Entry_Key)paramNames[ii] );
pcu_check_true( paramVals2[ii] == Dictionary_Entry_Value_AsUnsignedInt( elementDev ) );
}
Dictionary_Empty( data->dict2 );
@@ -597,8 +557,7 @@ void IO_HandlerSuite_TestReadDuplicateEn
IO_Handler_ReadAllFromFile( data->io_handler, xmlTestFilename3_1, data->dict2 );
pcu_check_true( 1 == data->dict2->count );
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0],
- (Dictionary_Entry_Key)struct1Name) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0], (Dictionary_Entry_Key)struct1Name) );
structDev = data->dict2->entryPtr[0]->value;
structDict = structDev->as.typeStruct;
pcu_check_true( Dictionary_Entry_Value_Type_Struct == structDev->type );
@@ -623,8 +582,7 @@ void IO_HandlerSuite_TestReadDuplicateEn
IO_Handler_ReadAllFromFile( data->io_handler, xmlTestFilename3_2, data->dict2 );
pcu_check_true( 1 == data->dict2->count );
- pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0],
- (Dictionary_Entry_Key)struct1Name) );
+ pcu_check_true( Dictionary_Entry_Compare( data->dict2->entryPtr[0], (Dictionary_Entry_Key)struct1Name) );
structDev = data->dict2->entryPtr[0]->value;
structDict = structDev->as.typeStruct;
pcu_check_true( Dictionary_Entry_Value_Type_Struct == structDev->type );
@@ -642,26 +600,28 @@ void IO_HandlerSuite_TestReadDuplicateEn
void IO_HandlerSuite_TestReadNonExistent( IO_HandlerSuiteData* data ) {
- char* errorFilename;
- char* notExistFilename = "I_Dont_Exist.xml";
- FILE* errorFile;
- #define MAXLINE 1000
- char errorLine[MAXLINE];
- char expectedErrorMsg[MAXLINE];
- Index rank_I;
+ char* errorFilename;
+ char* notExistFilename = "I_Dont_Exist.xml";
+ FILE* errorFile;
+ #define MAXLINE 1000
+ char errorLine[MAXLINE];
+ char expectedErrorMsg[MAXLINE];
Stg_asprintf( &errorFilename, "./errorMsg-NonExist-%d.txt", data->rank );
Stream_RedirectFile( Journal_Register( Error_Type, XML_IO_Handler_Type ), errorFilename );
Stream_ClearCustomFormatters( Journal_Register( Error_Type, XML_IO_Handler_Type ) );
if (0 == data->rank) {
- pcu_check_assert( IO_Handler_ReadAllFromFile( data->io_handler, notExistFilename, data->dict2 ) );
+ #ifdef DEBUG
+ pcu_check_assert( IO_Handler_ReadAllFromFile( data->io_handler, notExistFilename, data->dict2 ) );
+ #else
+ IO_Handler_ReadAllFromFile( data->io_handler, notExistFilename, data->dict2 );
+ #endif
errorFile = fopen( errorFilename, "r" );
pcu_check_true( errorFile );
pcu_check_true( fgets( errorLine, MAXLINE, errorFile ) );
- sprintf( expectedErrorMsg, "Error: File %s doesn't exist, not readable, or not valid.\n",
- notExistFilename );
+ sprintf( expectedErrorMsg, "Error: File %s doesn't exist, not readable, or not valid.\n", notExistFilename );
pcu_check_streq( errorLine, expectedErrorMsg );
remove( errorFilename );
}
@@ -669,9 +629,9 @@ void IO_HandlerSuite_TestReadNonExistent
void IO_HandlerSuite_TestReadInvalid( IO_HandlerSuiteData* data ) {
- char invalidXMLFilename[PCU_PATH_MAX];
- char expectedErrorFilename[PCU_PATH_MAX];
- const char* errorFilename = "errorMsg-Invalid.txt";
+ char invalidXMLFilename[PCU_PATH_MAX];
+ char expectedErrorFilename[PCU_PATH_MAX];
+ const char* errorFilename = "errorMsg-Invalid.txt";
pcu_filename_input( "Invalid.xml", invalidXMLFilename );
pcu_filename_expected( errorFilename, expectedErrorFilename );
@@ -680,7 +640,11 @@ void IO_HandlerSuite_TestReadInvalid( IO
Stream_ClearCustomFormatters( Journal_Register( Error_Type, XML_IO_Handler_Type ) );
if ( 0 == data->rank ) {
- pcu_check_assert( IO_Handler_ReadAllFromFile( data->io_handler, invalidXMLFilename, data->dict2 ) );
+ #ifdef DEBUG
+ pcu_check_assert( IO_Handler_ReadAllFromFile( data->io_handler, invalidXMLFilename, data->dict2 ) );
+ #else
+ IO_Handler_ReadAllFromFile( data->io_handler, invalidXMLFilename, data->dict2 );
+ #endif
pcu_check_fileEq( errorFilename, expectedErrorFilename );
remove( errorFilename );
}
@@ -688,9 +652,9 @@ void IO_HandlerSuite_TestReadInvalid( IO
void IO_HandlerSuite_TestReadWrongNS( IO_HandlerSuiteData* data ) {
- char wrongNS_XMLFilename[PCU_PATH_MAX];
- char expectedErrorFilename[PCU_PATH_MAX];
- const char* errorFilename = "errorMsg-wrongNS.txt";
+ char wrongNS_XMLFilename[PCU_PATH_MAX];
+ char expectedErrorFilename[PCU_PATH_MAX];
+ const char* errorFilename = "errorMsg-wrongNS.txt";
pcu_filename_input( "WrongNS.xml", wrongNS_XMLFilename );
pcu_filename_expected( errorFilename, expectedErrorFilename );
@@ -699,7 +663,11 @@ void IO_HandlerSuite_TestReadWrongNS( IO
Stream_ClearCustomFormatters( Journal_Register( Error_Type, XML_IO_Handler_Type ) );
if ( 0 == data->rank ) {
- pcu_check_assert( IO_Handler_ReadAllFromFile( data->io_handler, wrongNS_XMLFilename, data->dict2 ) );
+ #ifdef DEBUG
+ pcu_check_assert( IO_Handler_ReadAllFromFile( data->io_handler, wrongNS_XMLFilename, data->dict2 ) );
+ #else
+ IO_Handler_ReadAllFromFile( data->io_handler, wrongNS_XMLFilename, data->dict2 );
+ #endif
pcu_check_fileEq( errorFilename, expectedErrorFilename );
remove( errorFilename );
}
@@ -707,9 +675,9 @@ void IO_HandlerSuite_TestReadWrongNS( IO
void IO_HandlerSuite_TestReadWrongRootNode( IO_HandlerSuiteData* data ) {
- char wrongRootNode_XMLFilename[PCU_PATH_MAX];
- char expectedErrorFilename[PCU_PATH_MAX];
- const char* errorFilename = "./errorMsg-wrongRootNode.txt";
+ char wrongRootNode_XMLFilename[PCU_PATH_MAX];
+ char expectedErrorFilename[PCU_PATH_MAX];
+ const char* errorFilename = "./errorMsg-wrongRootNode.txt";
pcu_filename_input( "WrongRootNode.xml", wrongRootNode_XMLFilename );
pcu_filename_expected( errorFilename, expectedErrorFilename );
@@ -718,7 +686,11 @@ void IO_HandlerSuite_TestReadWrongRootNo
Stream_ClearCustomFormatters( Journal_Register( Error_Type, XML_IO_Handler_Type ) );
if ( 0 == data->rank ) {
- pcu_check_assert( IO_Handler_ReadAllFromFile( data->io_handler, wrongRootNode_XMLFilename, data->dict2 ) );
+ #ifdef DEBUG
+ pcu_check_assert( IO_Handler_ReadAllFromFile( data->io_handler, wrongRootNode_XMLFilename, data->dict2 ) );
+ #else
+ IO_Handler_ReadAllFromFile( data->io_handler, wrongRootNode_XMLFilename, data->dict2 );
+ #endif
pcu_check_fileEq( errorFilename, expectedErrorFilename );
remove( errorFilename );
}
@@ -737,8 +709,10 @@ void IO_HandlerSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, IO_HandlerSuite_TestReadRawDataEntries );
pcu_suite_addTest( suite, IO_HandlerSuite_TestReadAllFromCommandLine );
pcu_suite_addTest( suite, IO_HandlerSuite_TestReadDuplicateEntryKeys );
- pcu_suite_addTest( suite, IO_HandlerSuite_TestReadNonExistent );
- pcu_suite_addTest( suite, IO_HandlerSuite_TestReadInvalid );
- pcu_suite_addTest( suite, IO_HandlerSuite_TestReadWrongNS );
- pcu_suite_addTest( suite, IO_HandlerSuite_TestReadWrongRootNode );
+ /* pcu_suite_addTest( suite, IO_HandlerSuite_TestReadNonExistent ); */
+ /*pcu_suite_addTest( suite, IO_HandlerSuite_TestReadInvalid );*/
+ /*pcu_suite_addTest( suite, IO_HandlerSuite_TestReadWrongNS );*/
+ /*pcu_suite_addTest( suite, IO_HandlerSuite_TestReadWrongRootNode );*/
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/tests/JournalSuite.c
--- a/Base/IO/tests/JournalSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/tests/JournalSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -56,8 +56,6 @@ void JournalSuite_Setup( JournalSuiteDat
Stg_asprintf( &data->testStdOutFilename, "./testStdOut-%d.txt", data->rank );
Stg_asprintf( &data->testStdErrFilename, "./testStdErr-%d.txt", data->rank );
- Stg_Class_Delete( stJournal->stdOut );
- Stg_Class_Delete( stJournal->stdErr );
stJournal->stdOut = CFile_New();
stJournal->stdErr = CFile_New();
JournalFile_Open( stJournal->stdOut, data->testStdOutFilename );
@@ -88,7 +86,6 @@ void JournalSuite_Teardown( JournalSuite
remove( data->testStdOutFilename );
remove( data->testStdErrFilename );
}
-
void JournalSuite_TestRegister( JournalSuiteData* data ) {
Journal* testJournal;
@@ -410,7 +407,6 @@ void JournalSuite_TestShortcuts( Journal
double floatValue = 2.173425;
int intValue = 3;
unsigned int uintValue = 3980;
- int char_I;
char charValue = 'V';
double doubleArray[] = { 10.23, 393.1, -89, 1231 };
Index uintArray[] = { 10, 2021, 231, 2, 3, 4, 55 };
@@ -467,3 +463,5 @@ void JournalSuite( pcu_suite_t* suite )
pcu_suite_addTest( suite, JournalSuite_TestShortcuts );
pcu_suite_addTest( suite, JournalSuite_TestFirewall );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/tests/JournalSuite.h
--- a/Base/IO/tests/JournalSuite.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/tests/JournalSuite.h Tue Jan 12 14:38:16 2010 +1100
@@ -12,8 +12,8 @@ typedef struct {
FILE* testStdOutFile;
FILE* testStdErrFile;
MPI_Comm comm;
- unsigned int rank;
- unsigned int nProcs;
+ int rank;
+ int nProcs;
} JournalSuiteData;
#endif
diff -r 71b60b1562af -r 767daf30b22b Base/IO/tests/MPIStreamSuite.c
--- a/Base/IO/tests/MPIStreamSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/tests/MPIStreamSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -184,3 +184,5 @@ void MPIStreamSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, MPIStreamSuite_TestWriteAllProcessors );
pcu_suite_addTest( suite, MPIStreamSuite_TestPrintWithOffset );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/tests/PathUtilsSuite.c
--- a/Base/IO/tests/PathUtilsSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/tests/PathUtilsSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -42,7 +42,7 @@
#include "PathUtilsSuite.h"
typedef struct {
- unsigned int rank;
+ int rank;
} PathUtilsSuiteData;
@@ -130,3 +130,5 @@ void PathUtilsSuite( pcu_suite_t* suite
pcu_suite_addTest( suite, PathUtilsSuite_TestPathJoin );
pcu_suite_addTest( suite, PathUtilsSuite_TestFindFile );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/IO/tests/RankFormatterSuite.c
--- a/Base/IO/tests/RankFormatterSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/IO/tests/RankFormatterSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -109,3 +109,5 @@ void RankFormatterSuite( pcu_suite_t* su
pcu_suite_setFixtures( suite, RankFormatterSuite_Setup, RankFormatterSuite_Teardown );
pcu_suite_addTest( suite, RankFormatterSuite_TestPrintWithRank );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/ListPlugins/src/main.c
--- a/Base/ListPlugins/src/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/ListPlugins/src/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -84,3 +84,5 @@ int main( int argc, char* argv[] )
return 0; /* success */
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Python/Bindings/Context/bindings.c
--- a/Base/Python/Bindings/Context/bindings.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Python/Bindings/Context/bindings.c Tue Jan 12 14:38:16 2010 +1100
@@ -39,7 +39,7 @@ struct PyMethodDef Context_Python_Method
{ Context_Python_copyright__name__, Context_Python_copyright, METH_VARARGS, Context_Python_copyright__doc__ },
{ Context_Python_Print__name__, Context_Python_Print, METH_VARARGS, Context_Python_Print__doc__ },
{ Context_Python_Delete__name__, Context_Python_Delete, METH_VARARGS, Context_Python_Delete__doc__ },
- { Context_Python_Construct__name__, Context_Python_Construct, METH_VARARGS, Context_Python_Construct__doc__ },
+ { Context_Python_AssignFromXML__name__, Context_Python_AssignFromXML, METH_VARARGS, Context_Python_AssignFromXML__doc__ },
{ Context_Python_Build__name__, Context_Python_Build, METH_VARARGS, Context_Python_Build__doc__ },
{ Context_Python_Initialise__name__, Context_Python_Initialise, METH_VARARGS, Context_Python_Initialise__doc__ },
{ Context_Python_Execute__name__, Context_Python_Execute, METH_VARARGS, Context_Python_Execute__doc__ },
@@ -99,7 +99,7 @@ PyObject* Context_Python_Delete( PyObjec
/* "Construct" member */
char Context_Python_Construct__doc__[] = "Construct the Context...";
char Context_Python_Construct__name__[] = "Construct";
-PyObject* Context_Python_Construct( PyObject* self, PyObject* args ) {
+PyObject* Context_Python_AssignFromXML( PyObject* self, PyObject* args ) {
PyObject* pyContext;
Context* context;
@@ -109,7 +109,7 @@ PyObject* Context_Python_Construct( PyOb
}
context = (Context*)( PyCObject_AsVoidPtr( pyContext ) );
- Stg_Component_Construct( context, 0 /* dummy */, &context, True );
+ Stg_Component_AssignFromXML( context, 0 /* dummy */, &context, True );
/* Return */
Py_INCREF( Py_None );
@@ -302,3 +302,5 @@ PyObject* Context_Python_SetTime( PyObje
Py_INCREF( Py_None );
return Py_None;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Python/Bindings/Context/bindings.h
--- a/Base/Python/Bindings/Context/bindings.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Python/Bindings/Context/bindings.h Tue Jan 12 14:38:16 2010 +1100
@@ -52,7 +52,7 @@
extern char Context_Python_Construct__name__[];
extern char Context_Python_Construct__doc__[];
- PyObject* Context_Python_Construct( PyObject* self, PyObject* args );
+ PyObject* Context_Python_AssignFromXML( PyObject* self, PyObject* args );
extern char Context_Python_Build__name__[];
extern char Context_Python_Build__doc__[];
diff -r 71b60b1562af -r 767daf30b22b Base/Python/Bindings/Context/init.c
--- a/Base/Python/Bindings/Context/init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Python/Bindings/Context/init.c Tue Jan 12 14:38:16 2010 +1100
@@ -41,3 +41,5 @@ void initContext() {
}
return;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Python/Bindings/Context/misc.c
--- a/Base/Python/Bindings/Context/misc.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Python/Bindings/Context/misc.c Tue Jan 12 14:38:16 2010 +1100
@@ -38,3 +38,5 @@ PyObject* Context_Python_copyright( PyOb
PyObject* Context_Python_copyright( PyObject* self, PyObject* args ) {
return Py_BuildValue( "s", "StGermain.Base.Bindings.Context Python module: Copyright (c) 2003 Victorian Partnership for Advanced Computing (VPAC) Ltd. Australia." );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Python/Bindings/Dictionary/bindings.c
--- a/Base/Python/Bindings/Dictionary/bindings.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Python/Bindings/Dictionary/bindings.c Tue Jan 12 14:38:16 2010 +1100
@@ -195,3 +195,5 @@ PyObject* Dictionary_Python_LoadFromFile
Py_INCREF( Py_None );
return Py_None;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Python/Bindings/Dictionary/init.c
--- a/Base/Python/Bindings/Dictionary/init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Python/Bindings/Dictionary/init.c Tue Jan 12 14:38:16 2010 +1100
@@ -42,3 +42,5 @@ void initDictionary() {
}
return;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/Python/Bindings/Dictionary/misc.c
--- a/Base/Python/Bindings/Dictionary/misc.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/Python/Bindings/Dictionary/misc.c Tue Jan 12 14:38:16 2010 +1100
@@ -38,3 +38,5 @@ PyObject* Dictionary_Python_copyright( P
PyObject* Dictionary_Python_copyright( PyObject* self, PyObject* args ) {
return Py_BuildValue( "s", "StGermain.Base.Bindings.Dictionary Python module: Copyright (c) 2003 Victorian Partnership for Advanced Computing (VPAC) Ltd. Australia." );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/src/Finalise.c
--- a/Base/src/Finalise.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/src/Finalise.c Tue Jan 12 14:38:16 2010 +1100
@@ -64,3 +64,5 @@ Bool StGermainBase_Finalise( void ) {
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/src/Init.c
--- a/Base/src/Init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/src/Init.c Tue Jan 12 14:38:16 2010 +1100
@@ -76,3 +76,5 @@ Bool StGermainBase_Init( int* argc, char
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Base/tests/testLibBase.c
--- a/Base/tests/testLibBase.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Base/tests/testLibBase.c Tue Jan 12 14:38:16 2010 +1100
@@ -79,3 +79,5 @@ Bool LinearAlgebra_Finalise( void ) {
Bool LinearAlgebra_Finalise( void ) {
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Regresstor/ClientPrograms/checkDiff/main.c
--- a/Regresstor/ClientPrograms/checkDiff/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Regresstor/ClientPrograms/checkDiff/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -310,3 +310,5 @@ int interpretResponse( SoapCtx* response
printf( "Regresstor: Successfully submited check.\n" );
return 1;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Regresstor/ClientPrograms/checkExecution/main.c
--- a/Regresstor/ClientPrograms/checkExecution/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Regresstor/ClientPrograms/checkExecution/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -310,3 +310,5 @@ int interpretResponse( SoapCtx* response
printf( "Regresstor: Successfully submited check.\n" );
return 1;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Regresstor/ClientPrograms/endRun/main.c
--- a/Regresstor/ClientPrograms/endRun/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Regresstor/ClientPrograms/endRun/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -243,3 +243,5 @@ int interpretResponse( SoapCtx* response
printf( "Regresstor: Successfully end run.\n" );
return 1;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Regresstor/ClientPrograms/startRun/main.c
--- a/Regresstor/ClientPrograms/startRun/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Regresstor/ClientPrograms/startRun/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -257,3 +257,5 @@ int interpretResponse( SoapCtx* response
printf( "Regresstor: Successfully begin run.\n" );
return 1;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Regresstor/ClientPrograms/submitBuild/main.c
--- a/Regresstor/ClientPrograms/submitBuild/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Regresstor/ClientPrograms/submitBuild/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -339,3 +339,5 @@ int interpretResponse( SoapCtx* response
printf( "Regresstor: Successfully submited build.\n" );
return 1;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Regresstor/libRegresstor/src/FailedSubTest.c
--- a/Regresstor/libRegresstor/src/FailedSubTest.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Regresstor/libRegresstor/src/FailedSubTest.c Tue Jan 12 14:38:16 2010 +1100
@@ -20,3 +20,5 @@ void FailedSubTest_Delete( FailedSubTest
free( self );
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Regresstor/libRegresstor/src/RegressionTest.c
--- a/Regresstor/libRegresstor/src/RegressionTest.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Regresstor/libRegresstor/src/RegressionTest.c Tue Jan 12 14:38:16 2010 +1100
@@ -152,3 +152,5 @@ void RegressionTest_CrashHandler( int si
exit( 1 );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Regresstor/libRegresstor/src/UnitTest.c
--- a/Regresstor/libRegresstor/src/UnitTest.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Regresstor/libRegresstor/src/UnitTest.c Tue Jan 12 14:38:16 2010 +1100
@@ -56,3 +56,5 @@ void UnitTest_Add_FailedSubTest( UnitTes
self->subTestCount++;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b SConscript
--- a/SConscript Wed Jan 06 13:09:34 2010 +1100
+++ b/SConscript Tue Jan 12 14:38:16 2010 +1100
@@ -10,7 +10,7 @@ env = env.Clone()
env = env.Clone()
#
-# Build the 'pcu' sub-project.
+# Build the 'pcu' sub-project.
#
SConscript('pcu/SConscript', exports='env')
diff -r 71b60b1562af -r 767daf30b22b Utils/src/Progress.c
--- a/Utils/src/Progress.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Utils/src/Progress.c Tue Jan 12 14:38:16 2010 +1100
@@ -41,23 +41,24 @@ const Type Progress_Type = "Progress";
Progress* Progress_New() {
- return _Progress_New( sizeof(Progress), Progress_Type,
- _Progress_Delete,
- _Progress_Print,
- NULL );
+ /* Variables set in this function */
+ SizeT _sizeOfSelf = sizeof(Progress);
+ Type type = Progress_Type;
+ Stg_Class_DeleteFunction* _delete = _Progress_Delete;
+ Stg_Class_PrintFunction* _print = _Progress_Print;
+ Stg_Class_CopyFunction* _copy = NULL;
+
+ return _Progress_New( PROGRESS_PASSARGS );
}
-Progress* _Progress_New( SizeT sizeOfSelf, Type type,
- Stg_Class_DeleteFunction* delete,
- Stg_Class_PrintFunction* print,
- Stg_Class_CopyFunction* copy )
+Progress* _Progress_New( PROGRESS_DEFARGS )
{
Progress* self;
/* Allocate memory */
- assert( sizeOfSelf >= sizeof(Progress) );
- self = (Progress*)_Stg_Class_New( sizeOfSelf, type, delete, print, copy );
+ assert( _sizeOfSelf >= sizeof(Progress) );
+ self = (Progress*)_Stg_Class_New( STG_CLASS_PASSARGS );
_Progress_Init( self );
return self;
@@ -206,3 +207,5 @@ Bool Progress_CalcStatus( Progress* self
return (self->perc != oldPerc || self->nBars != oldnBars);
}
+
+
diff -r 71b60b1562af -r 767daf30b22b Utils/src/Progress.h
--- a/Utils/src/Progress.h Wed Jan 06 13:09:34 2010 +1100
+++ b/Utils/src/Progress.h Tue Jan 12 14:38:16 2010 +1100
@@ -45,11 +45,19 @@
int nSpaces;
struct Progress { __Progress };
+
+ #ifndef ZERO
+ #define ZERO 0
+ #endif
+
+ #define PROGRESS_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define PROGRESS_PASSARGS \
+ STG_CLASS_PASSARGS
+
Progress* Progress_New();
-Progress* _Progress_New( SizeT sizeOfSelf, Type type,
- Stg_Class_DeleteFunction* delete,
- Stg_Class_PrintFunction* print,
- Stg_Class_CopyFunction* copy );
+Progress* _Progress_New( PROGRESS_DEFARGS );
void _Progress_Init( void* self );
void _Progress_Delete( void* self );
void _Progress_Print( void* self, Stream* stream );
@@ -63,3 +71,4 @@ void Progress_Increment( void* self );
void Progress_Increment( void* self );
#endif /* __StGermain_Utils_Progress_h__ */
+
diff -r 71b60b1562af -r 767daf30b22b Utils/tests/ProgressSuite.c
--- a/Utils/tests/ProgressSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/Utils/tests/ProgressSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -76,3 +76,5 @@ void ProgressSuite( pcu_suite_t* suite )
pcu_suite_addTest( suite, ProgressSuite_TestSetPrefix );
pcu_suite_addTest( suite, ProgressSuite_TestSetRange );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b compatibility/mpipython/main.c
--- a/compatibility/mpipython/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/compatibility/mpipython/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -49,3 +49,5 @@ int main( int argc, char **argv ) {
return status;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b doc/Doxyfile
--- a/doc/Doxyfile Wed Jan 06 13:09:34 2010 +1100
+++ b/doc/Doxyfile Tue Jan 12 14:38:16 2010 +1100
@@ -581,7 +581,8 @@ EXCLUDE_PATTERNS = */.hg/* \
*/tests/* \
*/DOC/* \
*/doc/* \
- */build/*
+ */build/* \
+ */config/scons/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
@@ -711,7 +712,7 @@ ALPHABETICAL_INDEX = YES
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
-COLS_IN_ALPHA_INDEX = 4
+COLS_IN_ALPHA_INDEX = 3
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
diff -r 71b60b1562af -r 767daf30b22b libStGermain/Python/Bindings/General/bindings.c
--- a/libStGermain/Python/Bindings/General/bindings.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/Python/Bindings/General/bindings.c Tue Jan 12 14:38:16 2010 +1100
@@ -63,3 +63,5 @@ PyObject* General_Python_Initialise( PyO
result = StGermain_Init( &argc, &argv );
return Py_BuildValue("i", result);
}
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/Python/Bindings/General/init.c
--- a/libStGermain/Python/Bindings/General/init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/Python/Bindings/General/init.c Tue Jan 12 14:38:16 2010 +1100
@@ -41,3 +41,5 @@ void initGeneral() {
}
return;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/Python/Bindings/General/misc.c
--- a/libStGermain/Python/Bindings/General/misc.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/Python/Bindings/General/misc.c Tue Jan 12 14:38:16 2010 +1100
@@ -38,3 +38,5 @@ PyObject* General_Python_copyright( PyOb
PyObject* General_Python_copyright( PyObject* self, PyObject* args ) {
return Py_BuildValue( "s", "StGermain.Bindings.General Python module: Copyright (c) 2003 Victorian Partnership for Advanced Computing (VPAC) Ltd. Australia." );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/Python/Bindings/MPI/bindings.c
--- a/libStGermain/Python/Bindings/MPI/bindings.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/Python/Bindings/MPI/bindings.c Tue Jan 12 14:38:16 2010 +1100
@@ -89,3 +89,5 @@ PyObject* MPI_Python_Comm_rank( PyObject
/* Return */
return Py_BuildValue( "i", rank );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/Python/Bindings/MPI/init.c
--- a/libStGermain/Python/Bindings/MPI/init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/Python/Bindings/MPI/init.c Tue Jan 12 14:38:16 2010 +1100
@@ -42,3 +42,5 @@ void initMPI() {
return;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/Python/Bindings/MPI/misc.c
--- a/libStGermain/Python/Bindings/MPI/misc.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/Python/Bindings/MPI/misc.c Tue Jan 12 14:38:16 2010 +1100
@@ -38,3 +38,5 @@ PyObject* MPI_Python_copyright( PyObject
PyObject* MPI_Python_copyright( PyObject* self, PyObject* args ) {
return Py_BuildValue( "s", "StGermain.Bindings.MPI Python module: Copyright (c) 2003 Victorian Partnership for Advanced Computing (VPAC) Ltd. Australia." );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/dynamic/dummy.c
--- a/libStGermain/dynamic/dummy.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/dynamic/dummy.c Tue Jan 12 14:38:16 2010 +1100
@@ -33,3 +33,5 @@
/* dummy function so that Tru64 CC doesn't complain about doing nothing */
const int StGermain_Dummy = 0;
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/src/Finalise.c
--- a/libStGermain/src/Finalise.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/src/Finalise.c Tue Jan 12 14:38:16 2010 +1100
@@ -63,3 +63,5 @@ Bool StGermain_Finalise( void ) {
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/src/Init.c
--- a/libStGermain/src/Init.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/src/Init.c Tue Jan 12 14:38:16 2010 +1100
@@ -76,3 +76,5 @@ Bool StGermain_Init( int* argc, char** a
return True;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/src/main.c
--- a/libStGermain/src/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/src/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -49,55 +49,74 @@
void stgMain( Dictionary* dictionary, MPI_Comm communicator ) {
- AbstractContext* context;
+ Stg_ComponentFactory* cf;
- context = stgMainInit( dictionary, communicator );
- stgMainLoop( context );
- stgMainDestroy( context );
+ cf = stgMainConstruct( dictionary, communicator, NULL );
+ stgMainLoop( cf );
+ stgMainDestroy( cf );
+
+ Stg_Class_Delete( cf );
}
-AbstractContext* stgMainInit( Dictionary* dictionary, MPI_Comm communicator ) {
- AbstractContext* context = NULL;
+/* TODO: need to find a way to add different communicators for different contexts */
+Stg_ComponentFactory* stgMainConstruct( Dictionary* dictionary, MPI_Comm communicator, void* _context ) {
+ Stg_ComponentFactory* cf;
+ Dictionary* componentDict;
+ Stg_Component* component;
+ AbstractContext* context;
+ unsigned component_I;
+
+ if( ( componentDict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( dictionary, "components" ) ) ) == NULL )
+ componentDict = Dictionary_New();
+ CheckDictionaryKeys( componentDict, "Component dictionary must have unique names\n" );
+ cf = Stg_ComponentFactory_New( dictionary, componentDict );
+
+ if( _context ) {
+ context = (AbstractContext*)_context;
+ context->CF = cf;
+ context->dictionary = dictionary;
+ context->communicator = communicator;
+ LiveComponentRegister_Add( cf->LCRegister, (void*)context );
+ }
+
+ /* Instantion phase -------------------------------------------------------------------------------------------------*/
+ Stg_ComponentFactory_CreateComponents( cf );
+
+ /* Assign the dictionary, componentFactory & the communicator for the contexts */
+ /* TODO: if different contexts require different communicators, then StG. components will be required for these, and
+ * they should be passed in from the XML */
+ /* Also, this is a little hacky, as nothing is known about the other layers of StG or their associated contexts here */
+ for( component_I = 0; component_I < LiveComponentRegister_GetCount( cf->LCRegister ); component_I++ ) {
+ component = LiveComponentRegister_At( cf->LCRegister, component_I );
+ if( Stg_CompareType( component, AbstractContext ) ) {
+ Journal_Firewall( dictionary->count, Journal_Register( Error_Type, "Error Stream" ),
+ "Error in %s: The dictionary is empty, meaning no input parameters have been feed into your program. Perhaps you've forgot to pass any input files ( or command-line arguments ) in.\n", __func__);
+ context = (AbstractContext*)component;
+ context->dictionary = dictionary;
+ context->CF = cf;
+ context->communicator = communicator;
+ }
+ }
/* Construction phase -----------------------------------------------------------------------------------------------*/
- context = _AbstractContext_New(
- sizeof(AbstractContext),
- AbstractContext_Type,
- _AbstractContext_Delete,
- _AbstractContext_Print,
- NULL,
- NULL,
- _AbstractContext_Construct,
- _AbstractContext_Build,
- _AbstractContext_Initialise,
- _AbstractContext_Execute,
- _AbstractContext_Destroy,
- "context",
- True,
- NULL,
- 0,
- 0,
- communicator,
- dictionary );
+ Stg_ComponentFactory_ConstructComponents( cf, NULL );
+
+ return cf;
+}
- /* Construction phase -----------------------------------------------------------------------------------------------*/
- Stg_Component_Construct( context, 0 /* dummy */, &context, True );
-
+void stgMainBuildAndInitialise( Stg_ComponentFactory* cf ) {
/* Building phase ---------------------------------------------------------------------------------------------------*/
- Stg_Component_Build( context, 0 /* dummy */, False );
+ Stg_ComponentFactory_BuildComponents( cf, NULL );
/* Initialisaton phase ----------------------------------------------------------------------------------------------*/
- Stg_Component_Initialise( context, 0 /* dummy */, False );
-
- return context;
+ Stg_ComponentFactory_InitialiseComponents( cf, NULL );
}
-
-AbstractContext* stgMainInitFromXML( char* xmlInputFilename, MPI_Comm communicator ) {
- AbstractContext* context = NULL;
- Dictionary* dictionary = NULL;
- Bool result;
- XML_IO_Handler* ioHandler;
+Stg_ComponentFactory* stgMainInitFromXML( char* xmlInputFilename, MPI_Comm communicator, void* _context ) {
+ Dictionary* dictionary = NULL;
+ Bool result;
+ XML_IO_Handler* ioHandler;
+ Stg_ComponentFactory* cf;
dictionary = Dictionary_New();
ioHandler = XML_IO_Handler_New();
@@ -105,27 +124,37 @@ AbstractContext* stgMainInitFromXML( cha
/* In case the user has put any journal configuration in the XML, read here */
Journal_ReadFromDictionary( dictionary );
- context = stgMainInit( dictionary, communicator );
+ cf = stgMainConstruct( dictionary, communicator, _context );
/* We don't need the XML IO handler again (however don't delete the dictionary as it's
* 'owned' by the context from hereon */
Stg_Class_Delete( ioHandler );
- return context;
+ return cf;
}
-void stgMainLoop( AbstractContext* context ) {
+void stgMainLoop( Stg_ComponentFactory* cf ) {
/* Run (Solve) phase ------------------------------------------------------------------------------------------------*/
- AbstractContext_Dump( context );
- Stg_Component_Execute( context, 0 /* dummy */, False );
+ /* do this by running the contexts, which manage the entry points which call the _Execute() funcs for the other components */
+ unsigned component_i;
+ Stg_Component* component;
+ AbstractContext* context;
+
+ for( component_i = 0; component_i < LiveComponentRegister_GetCount( cf->LCRegister ); component_i++ ) {
+ component = LiveComponentRegister_At( cf->LCRegister, component_i );
+ if( Stg_CompareType( component, AbstractContext ) ) {
+ context = (AbstractContext*)component;
+ AbstractContext_Dump( context );
+ Stg_Component_Execute( context, 0, True );
+ }
+ }
}
-
-void stgMainDestroy( AbstractContext* context ) {
- /* Destruct phase ---------------------------------------------------------------------------------------------------*/
- Stg_Component_Destroy( context, 0 /* dummy */, False );
- Stg_Class_Delete( context );
+void stgMainDestroy( Stg_ComponentFactory* cf ) {
+ /* Destruct phase ---------------------------------------------------------------------------------------------------*/
+ LiveComponentRegister_DestroyAll( cf->LCRegister );
+ Stg_Class_Delete( cf ); /* this will call the LCRegister Delete func */
}
void stgImportToolbox( Dictionary* dictionary, char* toolboxName ) {
@@ -138,3 +167,5 @@ void stgImportToolbox( Dictionary* dicti
Dictionary_Entry_Value_AddElement( dev, Dictionary_Entry_Value_FromString( toolboxName ) );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/src/main.h
--- a/libStGermain/src/main.h Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/src/main.h Tue Jan 12 14:38:16 2010 +1100
@@ -44,18 +44,21 @@
/** The StGermain main - the context life cycle */
void stgMain( Dictionary* dictionary, MPI_Comm CommWorld );
- /** The StGermain main initialisation */
- AbstractContext* stgMainInit( Dictionary* dictionary, MPI_Comm communicator );
+ /** The StGermain main construction */
+ Stg_ComponentFactory* stgMainConstruct( Dictionary* dictionary, MPI_Comm communicator, void* _context );
- /** Initialise the context, from a particular XML file. This saves the user manipulating
- * an IO_Handler and dictionary to get the data into the context. Useful for test code. */
- AbstractContext* stgMainInitFromXML( char* xmlInputFilename, MPI_Comm communicator );
+ /** The StGermain main building and initialisation */
+ void stgMainBuildAndInitialise( Stg_ComponentFactory* cf );
+
+ /** Initialise the context, from a particular XML file. This saves the user manipulating
+ * an IO_Handler and dictionary to get the data into the context. Useful for test code. */
+ Stg_ComponentFactory* stgMainInitFromXML( char* xmlInputFilename, MPI_Comm communicator, void* _context );
/** The StGermain main loop */
- void stgMainLoop( AbstractContext* context );
+ void stgMainLoop( Stg_ComponentFactory* cf );
/** The StGermain main destruction */
- void stgMainDestroy( AbstractContext* context );
+ void stgMainDestroy( Stg_ComponentFactory* cf );
/** Add a toolbox to the "import" list in the dictionary */
void stgImportToolbox( Dictionary* dictionary, char* toolboxName );
diff -r 71b60b1562af -r 767daf30b22b libStGermain/static/dummy.c
--- a/libStGermain/static/dummy.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/static/dummy.c Tue Jan 12 14:38:16 2010 +1100
@@ -33,3 +33,5 @@
/* dummy function so that Tru64 CC doesn't complain about doing nothing */
const int StGermain_Dummy = 0;
+
+
diff -r 71b60b1562af -r 767daf30b22b libStGermain/tests/LibStGermainSuite.c
--- a/libStGermain/tests/LibStGermainSuite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/libStGermain/tests/LibStGermainSuite.c Tue Jan 12 14:38:16 2010 +1100
@@ -60,3 +60,5 @@ void LibStGermainSuite( pcu_suite_t* sui
pcu_suite_setFixtures( suite, LibStGermainSuite_Setup, LibStGermainSuite_Teardown );
pcu_suite_addTest( suite, LibStGermainSuite_TestXMLLibraryPath );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b pcu/script/pcutest.py
--- a/pcu/script/pcutest.py Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/script/pcutest.py Tue Jan 12 14:38:16 2010 +1100
@@ -79,9 +79,12 @@ int main( int argc, char* argv[] ) {
return File(target.abspath)
def generate(env, **kw):
- env.SetDefault(PCUALL_TARGET="check")
- env.SetDefault(PCUUNIT_TARGET="unit")
- env.SetDefault(PCUSYSTEST_TARGET="systest")
+ env.SetDefault(PCUALL_TARGET="check-complete")
+ env.SetDefault(REGTEST_TARGET="check")
+ env.SetDefault(UNIT_TARGET="check-unit")
+ env.SetDefault(INTEGRATION_TARGET="check-integration")
+ env.SetDefault(CONVERGENCE_TARGET="check-convergence")
+ env.SetDefault(LOWRES_TARGET="check-lowres")
# Make the 'all' target point to everything.
def PCUSuite(env, target, source, **kw):
@@ -111,25 +114,52 @@ def generate(env, **kw):
libs = multiget([kw, env], 'LIBS', []) + ["pcu"]
test = env.Program(target[0], objs, LIBS=libs)
runner = env.Action('-' + test[0].abspath)
- env.Alias(env["PCUUNIT_TARGET"], [exps, inputs, test], runner)
- env.AlwaysBuild(env["PCUUNIT_TARGET"])
- env.Alias(env['PCUALL_TARGET'], env['PCUUNIT_TARGET'])
+ env.Alias(env["UNIT_TARGET"], [exps, inputs, test], runner)
+ env.AlwaysBuild(env["UNIT_TARGET"])
+ env.Alias(env['PCUALL_TARGET'], env['UNIT_TARGET'])
+ env.Alias(env['REGTEST_TARGET'], env['UNIT_TARGET'])
return test
- def PCUSysTest(env, target, source, **kw):
+ def IntegrationTest(env, target, source, **kw):
script = File(source[0].split()[0]).srcnode().abspath
script_dir = os.path.dirname(script)
script = os.path.basename(script)
args = source[0].split()[1:]
runner = env.Action('-./' + script + ' ' + ' '.join(args), chdir=script_dir)
- env.Alias(env["PCUSYSTEST_TARGET"], [], runner)
- env.AlwaysBuild(env["PCUSYSTEST_TARGET"])
- env.Alias(env['PCUALL_TARGET'], env['PCUSYSTEST_TARGET'])
+ env.Alias(env["INTEGRATION_TARGET"], [], runner)
+ env.AlwaysBuild(env["INTEGRATION_TARGET"])
+ env.Alias(env['PCUALL_TARGET'], env['INTEGRATION_TARGET'])
+ return None
+
+
+ def LowResTest(env, target, source, **kw):
+ script = File(source[0].split()[0]).srcnode().abspath
+ script_dir = os.path.dirname(script)
+ script = os.path.basename(script)
+ args = source[0].split()[1:]
+
+ runner = env.Action('-./' + script + ' ' + ' '.join(args), chdir=script_dir)
+ env.Alias(env["LOWRES_TARGET"], [], runner)
+ env.AlwaysBuild(env["LOWRES_TARGET"])
+ env.Alias(env['PCUALL_TARGET'], env['LOWRES_TARGET'])
+ env.Alias(env['REGTEST_TARGET'], env['LOWRES_TARGET'])
+ return None
+
+ def ConvergenceTest(env, target, source, **kw):
+ script = File(source[0].split()[0]).srcnode().abspath
+ script_dir = os.path.dirname(script)
+ script = os.path.basename(script)
+ args = source[0].split()[1:]
+
+ runner = env.Action('-./' + script + ' ' + ' '.join(args), chdir=script_dir)
+ env.Alias(env["CONVERGENCE_TARGET"], [], runner)
+ env.AlwaysBuild(env["CONVERGENCE_TARGET"])
+ env.Alias(env['PCUALL_TARGET'], env['CONVERGENCE_TARGET'])
return None
env.Append(BUILDERS={"PCUSuite": PCUSuite, "PCUTest": PCUTest,
- 'PCUSysTest': PCUSysTest})
+ "LowResTest": LowResTest, "IntegrationTest": IntegrationTest, "ConvergenceTest": ConvergenceTest})
def exists(env):
# Should probably have this search for the pcu
diff -r 71b60b1562af -r 767daf30b22b pcu/src/checks.c
--- a/pcu/src/checks.c Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/checks.c Tue Jan 12 14:38:16 2010 +1100
@@ -35,7 +35,7 @@ void _pcu_check_fileEq( const char* cons
char file1Line[MAXLINE];
char file2Line[MAXLINE];
char file2LineCopy[MAXLINE];
- unsigned int rank;
+ int rank;
char* ret1;
char* ret2;
unsigned int ii=0;
@@ -98,3 +98,5 @@ void _pcu_check_fileEq( const char* cons
fclose(testFile1);
fclose(testFile2);
}
+
+
diff -r 71b60b1562af -r 767daf30b22b pcu/src/filename.c
--- a/pcu/src/filename.c Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/filename.c Tue Jan 12 14:38:16 2010 +1100
@@ -63,3 +63,5 @@ void _pcu_filename_input( const char* co
sprintf( fullPathFileName, "./%s/%s/%s", moduleDir, fileType, inputFileName );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b pcu/src/pcuassert.c
--- a/pcu/src/pcuassert.c Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/pcuassert.c Tue Jan 12 14:38:16 2010 +1100
@@ -4,3 +4,5 @@ int pcu_jump_ready = 0;
int pcu_jump_ready = 0;
jmp_buf pcu_jump_env;
char* pcu_assert_cur = NULL;
+
+
diff -r 71b60b1562af -r 767daf30b22b pcu/src/runner.c
--- a/pcu/src/runner.c Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/runner.c Tue Jan 12 14:38:16 2010 +1100
@@ -82,9 +82,10 @@ PCU_Runner_Status pcu_runner_run( pcu_li
cur = cur->next;
}
- if ( pcu_nsuites > 1 ) {
+ if ( pcu_nsuites >= 1 ) {
printf( "-----------------------------------------------------------\n" );
- printf( "Total passes: %d/%d\n", totalPasses, totalTests );
+ printf( "[PCU] Total Passes: (%d/%d)\n", totalPasses, totalTests );
+ printf( "-----------------------------------------------------------\n" );
}
if ( totalPasses == totalTests ) {
@@ -97,10 +98,7 @@ PCU_Runner_Status pcu_runner_run( pcu_li
return returnStatus;
}
-void _pcu_runner_addSuite( const char* name,
- void (initfunc)( pcu_suite_t* ),
- const char* moduleDir )
-{
+void _pcu_runner_addSuite( const char* name, void (initfunc)( pcu_suite_t* ), const char* moduleDir ) {
pcu_suite_t* suite;
assert( initfunc );
@@ -163,3 +161,5 @@ void pcu_runner_searchHierarchy( pcu_sui
pcu_suites = suite;
pcu_nsuites++;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b pcu/src/source.c
--- a/pcu/src/source.c Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/source.c Tue Jan 12 14:38:16 2010 +1100
@@ -183,3 +183,5 @@ void pcu_source_clear( pcu_source_t* src
src->msg = NULL;
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b pcu/src/suite.c
--- a/pcu/src/suite.c Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/suite.c Tue Jan 12 14:38:16 2010 +1100
@@ -210,3 +210,5 @@ void pcu_suite_clear( pcu_suite_t* suite
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b pcu/src/suite.h
--- a/pcu/src/suite.h Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/suite.h Tue Jan 12 14:38:16 2010 +1100
@@ -21,44 +21,41 @@
#define pcu_suite_h
struct pcu_suite_t {
- char* name;
- char* moduleDir;
- int ntests;
- pcu_test_t* tests;
- int npassed;
- pcu_test_t* curtest;
- pcu_listener_t* lsnr;
- pcu_suite_t* next;
- int nsubsuites;
- pcu_suite_t* subsuites;
+ char* name;
+ char* moduleDir;
+ int ntests;
+ pcu_test_t* tests;
+ int npassed;
+ pcu_test_t* curtest;
+ pcu_listener_t* lsnr;
+ pcu_suite_t* next;
+ int nsubsuites;
+ pcu_suite_t* subsuites;
- pcu_fixture_t* setup;
- pcu_fixture_t* teardown;
- void* data;
+ pcu_fixture_t* setup;
+ pcu_fixture_t* teardown;
+ void* data;
};
void pcu_suite_run( pcu_suite_t* suite, pcu_listener_t* lsnr );
-void _pcu_suite_setFixtures( pcu_suite_t* suite,
- pcu_fixture_t* setup, pcu_fixture_t* teardown );
+void _pcu_suite_setFixtures( pcu_suite_t* suite, pcu_fixture_t* setup, pcu_fixture_t* teardown );
void _pcu_suite_addTest( pcu_suite_t* suite, pcu_testfunc_t* func, const char* name );
-void _pcu_suite_addSubSuite( pcu_suite_t* suite, const char* name,
- void (initfunc)( pcu_suite_t* ),
- const char* moduleDir );
+void _pcu_suite_addSubSuite( pcu_suite_t* suite, const char* name, void (initfunc)( pcu_suite_t* ), const char* moduleDir );
void _pcu_suite_setData( pcu_suite_t* suite, int size );
void pcu_suite_clear( pcu_suite_t* suite );
-#define pcu_suite_setFixtures( suite, setup, teardown ) \
- _pcu_suite_setFixtures( suite, (pcu_fixture_t*)setup, \
- (pcu_fixture_t*)teardown )
+#define pcu_suite_setFixtures( suite, setup, teardown ) \
+ _pcu_suite_setFixtures( suite, (pcu_fixture_t*)setup, \
+ (pcu_fixture_t*)teardown )
#define pcu_suite_addTest( suite, func ) \
- _pcu_suite_addTest( suite, (pcu_testfunc_t*)func, \
- #func )
+ _pcu_suite_addTest( suite, (pcu_testfunc_t*)func, \
+ #func )
#define pcu_suite_addSubSuite( suite, subsuite ) \
- _pcu_suite_addSubSuite( suite, #subsuite, subsuite##_init )
+ _pcu_suite_addSubSuite( suite, #subsuite, subsuite##_init )
#define pcu_suite_setData( suite, type ) \
- _pcu_suite_setData( suite, sizeof(type) )
+ _pcu_suite_setData( suite, sizeof(type) )
#endif
diff -r 71b60b1562af -r 767daf30b22b pcu/src/test.c
--- a/pcu/src/test.c Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/test.c Tue Jan 12 14:38:16 2010 +1100
@@ -186,3 +186,5 @@ void pcu_test_gathersources( pcu_test_t*
}
}
}
+
+
diff -r 71b60b1562af -r 767daf30b22b pcu/src/test.h
--- a/pcu/src/test.h Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/test.h Tue Jan 12 14:38:16 2010 +1100
@@ -21,16 +21,16 @@
#define pcu_test_h
struct pcu_test_t {
- char* name;
- pcu_suite_t* suite;
- pcu_testfunc_t* func;
- pcu_test_t* next;
+ char* name;
+ pcu_suite_t* suite;
+ pcu_testfunc_t* func;
+ pcu_test_t* next;
- int globalresult;
- int nsrcs;
- pcu_source_t* srcs;
- pcu_source_t* lastSrc;
- char* docString;
+ int globalresult;
+ int nsrcs;
+ pcu_source_t* srcs;
+ pcu_source_t* lastSrc;
+ char* docString;
};
/** Associate a documentation string with the current test (must be called from within a test function) */
diff -r 71b60b1562af -r 767daf30b22b pcu/src/textoutput.c
--- a/pcu/src/textoutput.c Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/textoutput.c Tue Jan 12 14:38:16 2010 +1100
@@ -32,18 +32,20 @@ extern int PCU_PRINT_DOCS;
extern int PCU_PRINT_DOCS;
typedef struct {
- int rank;
+ int rank;
} textoutputdata_t;
-void printstatus( pcu_listener_t* lsnr, pcu_suite_t* suite, int final );
+void printsuitestatus( pcu_listener_t* lsnr, pcu_suite_t* suite, int final );
+void printteststatus( pcu_listener_t* lsnr, pcu_suite_t* suite, char* testname, int final );
void printsources( pcu_listener_t* lsnr, pcu_suite_t* suite );
void pcu_textoutput_suitebegin( pcu_listener_t* lsnr, pcu_suite_t* suite ) {
- printstatus( lsnr, suite, 0 );
+ printsuitestatus( lsnr, suite, 0 );
+ /*printstatus( lsnr, suite, 0 );*/
}
void pcu_textoutput_suiteend( pcu_listener_t* lsnr, pcu_suite_t* suite ) {
- printstatus( lsnr, suite, 1 );
+ printsuitestatus( lsnr, suite, 1 );
printsources( lsnr, suite );
}
@@ -51,7 +53,7 @@ void pcu_textoutput_testbegin( pcu_liste
}
void pcu_textoutput_testend( pcu_listener_t* lsnr, pcu_test_t* test ) {
- printstatus( lsnr, test->suite, 0 );
+ printteststatus( lsnr, test->suite, test->name, 0 );
}
void pcu_textoutput_checkdone( pcu_listener_t* lsnr, pcu_source_t* src ) {
@@ -69,8 +71,7 @@ pcu_listener_t* pcu_textoutput_create( i
lsnr->data = malloc( sizeof(textoutputdata_t) );
assert( printdocs == 1 || printdocs == 0 );
lsnr->printdocs = printdocs;
- MPI_Comm_rank( MPI_COMM_WORLD,
- &((textoutputdata_t*)lsnr->data)->rank );
+ MPI_Comm_rank( MPI_COMM_WORLD, &((textoutputdata_t*)lsnr->data)->rank );
return lsnr;
}
@@ -81,13 +82,24 @@ void pcu_textoutput_destroy( pcu_listene
free( lsnr );
}
-void printstatus( pcu_listener_t* lsnr, pcu_suite_t* suite, int final ) {
+void printsuitestatus( pcu_listener_t* lsnr, pcu_suite_t* suite, int final ) {
if( ((textoutputdata_t*)lsnr->data)->rank )
return;
- printf( "Running suite '%s', passes: %d/%d%s",
- suite->name, suite->npassed, suite->ntests,
- final ? "\n" : "\r" );
+ if( final ) {
+ printf( "[PCU] Status: %s\n", suite->npassed == suite->ntests ? "PASSED" : "FAILED" );
+ }
+ else {
+ printf( "------------------------------------------------------------------------\n" );
+ printf( "[PCU] Testing '%s':\n", suite->name );
+ }
+}
+
+void printteststatus( pcu_listener_t* lsnr, pcu_suite_t* suite, char* testname, int final ) {
+ if( ((textoutputdata_t*)lsnr->data)->rank )
+ return;
+
+ printf( "[PCU] Test Case: '%s', Passes: (%d/%d)\n", testname, suite->npassed, suite->ntests );
}
void printsources( pcu_listener_t* lsnr, pcu_suite_t* suite ) {
@@ -117,17 +129,17 @@ void printsources( pcu_listener_t* lsnr,
}
src = test->srcs;
while( src ) {
- if( !src->result ) {
- printf( "\n\tCheck '%s' failed:\n", src->type );
- printf( "\t\tLocation: \t%s:%d\n", src->file, src->line );
- printf( "\t\tTest name: \t%s\n", src->test->name );
- printf( "\t\tExpression: \t%s\n", src->expr );
+ if( !src->result ) {
+ printf( "\n\tCheck '%s' failed:\n", src->type );
+ printf( "\t\tLocation: \t%s:%d\n", src->file, src->line );
+ printf( "\t\tTest name: \t%s\n", src->test->name );
+ printf( "\t\tExpression: \t%s\n", src->expr );
if( src->msg )
printf( "\t\tMessage: \t%s\n", src->msg );
- printf( "\t\tRank: \t\t%d\n", src->rank );
- nfails++;
- }
- src = src->next;
+ printf( "\t\tRank: \t\t%d\n", src->rank );
+ nfails++;
+ }
+ src = src->next;
}
test = test->next;
}
@@ -135,3 +147,5 @@ void printsources( pcu_listener_t* lsnr,
if( nfails )
printf( "\n" );
}
+
+
diff -r 71b60b1562af -r 767daf30b22b pcu/src/utils.c
--- a/pcu/src/utils.c Wed Jan 06 13:09:34 2010 +1100
+++ b/pcu/src/utils.c Tue Jan 12 14:38:16 2010 +1100
@@ -32,3 +32,5 @@ char* pcu_strdup( const char* str ) {
char* pcu_strdup( const char* str ) {
return str ? pcu_memdup( str, strlen( str ) + 1 ) : NULL;
}
+
+
diff -r 71b60b1562af -r 767daf30b22b script/README
--- a/script/README Wed Jan 06 13:09:34 2010 +1100
+++ b/script/README Tue Jan 12 14:38:16 2010 +1100
@@ -5,11 +5,12 @@ Running through scons:
Running through scons:
----------------------
This is the desired way to run the script, and they have been designed to run best through this method.
-To run, go to the base stgUnderworld directory and type
+
+To run, first follow the configure instructions for StGermain/Underworld project, then go to the base stgUnderworld directory and type
'scons doc'
-All the defaults have been setup to run through this method. Running this way, the script will create a directory calle 'doc' in the base directory. In this directory will be 2 sub-directories. These will be 'Codex' and 'Doxygen/html/' In each of these subdirectories will be a number of html files. The files to load are called 'index.html' eg. 'stgUnderworldE/Codex/index.html' Load these to access the created documents.
+All the defaults have been setup to run through this method. Running this way, the script will create a directory called 'doc' in the base directory. In this directory will be 2 sub-directories. These will be 'Codex' and 'Doxygen/html/' In each of these subdirectories will be a number of html files. The files to load are called 'index.html' eg. 'stgUnderworldE/Codex/index.html' Load these to access the created documents.
createDocs.py :
---------------
@@ -37,6 +38,11 @@ This is a standalone python script to be
This is a standalone python script to be run from this directory.
it creates just the Doxygen web pages. Type 'createDoxygen.py -h' for a list of available options.
+
+createCodex.py:
+---------------
+This is a standalone python script to be run from this directory. It creates the codex with the same default settings as createDocs.py. It is designed to be a quick way of creating the default codex without creating the Doxygen package as well. Type 'createCodex.py -h' for a list of available options. It is not as flexible as createHTMLDocuments.py for creating the codex.
+
createDocument.py:
------------------
This is a class for document creation, with createHTMLDocuments.py being a child of this class. It cannot be run by iteself.
@@ -47,4 +53,6 @@ These are parsing scripts for meta files
These are parsing scripts for meta files and scripts needed to accomplish this end.
-
+headerfilter.py:
+----------------
+This is the python script used by Doxygen to make Stgermain/Underworld *.h header files readable by Doxygen. It enables classes, TODO's and meta file information to be included in the html output files.
diff -r 71b60b1562af -r 767daf30b22b script/createCodex.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/createCodex.py Tue Jan 12 14:38:16 2010 +1100
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+## This is a codelet to run just the codex with standard defaults from anywhere in the code.
+import createDocs
+import createHTMLDocuments, createDocument
+import sys, os.path, os, string, subprocess, shutil
+from createDocument import createDocuments
+from createDocs import createListDictionary
+from createDocs import createCodex
+
+## Function for specific help statement for running Doxygen ONLY
+def printHelpStatement(dictionary):
+
+ print "Help for createDoxygen.py. This file is designed to be standalone."
+ print "To run, type ./createCodex.py \n"
+ print "To run with input options: "
+ print "./createCodex.py METATYPE WEBPAGES EMAIL CODEXINPUTDIR CODEXOUTPUTDIR \n"
+ print "Defaults:"
+ print "METATYPE: 'dtd' or 'xsd'"
+ print "WEBPAGES: [['http://www.underworldproject.org','Underworld Home Page']]"
+ print "EMAIL: 'underworld-users at vpac.org'\n"
+ print "CODEXINPUTDIR: Name of base directory. Default: '../../', Current: "+ dictionary['directoryPath']
+ print "CODEXOUTPUTDIR: Name of directory to which Codex will output it's files. Default: '../../doc/', Current: "+ dictionary['docPath']
+ print "DOCDATAPATH: Name of path to StGermain/doc/ directory, which has necessary files for the Codex to run. Default: "+dictionary['directoryPath']+"/StGermain/doc/', Current: "+ dictionary['docDataPath']
+ print "*******WARNING********"
+ print "This codex file ONLY works with Stg base directory. "
+ print " To only create codex for smaller samples, use createHTMLDocuments.py"
+ print "**********************"
+ print "*******WARNING********"
+ print "ALL data in "+dictionary['docPath']+ " will be overwritten or removed!"
+ print "**********************"
+ print "Other defaults: (Not all necessary) \n"
+ print dictionary.items()
+
+if __name__=='__main__':
+ values = sys.argv
+ for i in range(7):
+ if len(values)< 7:
+ values.append("")
+
+
+
+ #Define input directory (relative to ~/stgUnderworldE/ )
+ if values[4] != "" :
+ directoryPath = os.path.realpath(values[4])
+ else:
+ directoryPath = os.path.realpath('../../')
+ print directoryPath
+
+ # Create the output directory. This is relative to the ./mainProj/config page.(relative to ~/stgUnderworldE/ )
+ if values[5] != "":
+ docPath = os.path.realpath(values[5])
+ else:
+ docPath = os.path.join(directoryPath, 'doc/')
+ print docPath
+
+ # createDictionary
+ mainDictionary = createListDictionary(values[1],values[2], values[3], "", directoryPath, docPath, values[6])
+
+ # Set up help print statement
+ if ((mainDictionary['arg1'] == "help") or (mainDictionary['arg1'] == '-h') or (mainDictionary['arg1'] =='--help') or (mainDictionary['arg1'] == 'h')):
+ printHelpStatement(mainDictionary)
+
+ else:
+ #check the directory now exists.
+ createDocument.checkOutputPath(docPath)
+
+ createCodex(mainDictionary)
+
diff -r 71b60b1562af -r 767daf30b22b script/createDocs.py
--- a/script/createDocs.py Wed Jan 06 13:09:34 2010 +1100
+++ b/script/createDocs.py Tue Jan 12 14:38:16 2010 +1100
@@ -27,15 +27,23 @@ def findProjectDirectories(mainDirectory
return projList
## Create a dictionary that contains all data needed to create Codex and Doxygen pages
-def createListDictionary(arg1, arg2, arg3, arg4, directoryPath, docPath):
+def createListDictionary(arg1, arg2, arg3, arg4, directoryPath, docPath, docDataPath):
dictionary = {}
# Add items to dictionary
- dictionary['directoryPath'] = directoryPath
+ dictionary['directoryPath'] = os.path.realpath(directoryPath)
- dictionary['docPath'] = docPath
- dictionary['docDataPath'] = os.path.realpath(os.path.join(directoryPath,'StGermain/doc/'))
- dictionary['docScriptPath'] = os.path.realpath(os.path.join(directoryPath,'StGermain/script/'))
+ dictionary['docPath'] = os.path.realpath(docPath)
+ if docDataPath == "":
+ dictionary['docDataPath'] = os.path.realpath(os.path.join(directoryPath,'StGermain/doc/'))
+ else:
+ dictionary['docDataPath'] = os.path.realpath(docDataPath)
+
+ if docDataPath != "":
+ dictionary['docScriptPath'] = os.path.join(string.rstrip(os.path.realpath(dictionary['docDataPath']), "doc/"), "script/")
+ else:
+ dictionary['docScriptPath'] = os.path.realpath(os.path.join(directoryPath,'StGermain/script/'))
+
# Define Codex values
# Codex Subdir
dictionary['codexSubDir'] = 'Codex'
@@ -270,7 +278,7 @@ if __name__=='__main__':
docPath = os.path.realpath('./doc/')
# createDictionary
- mainDictionary = createListDictionary(values[1],values[2], values[3], values[4], directoryPath, docPath)
+ mainDictionary = createListDictionary(values[1],values[2], values[3], values[4], directoryPath, docPath, "")
# Set up help print statement
if ((mainDictionary['arg1'] == "help") or (mainDictionary['arg1'] == '-h') or (mainDictionary['arg1'] =='--help') or (mainDictionary['arg1'] == 'h')):
diff -r 71b60b1562af -r 767daf30b22b script/createDoxygen.py
--- a/script/createDoxygen.py Wed Jan 06 13:09:34 2010 +1100
+++ b/script/createDoxygen.py Tue Jan 12 14:38:16 2010 +1100
@@ -65,31 +65,7 @@ if __name__=='__main__':
print docPath
# createDictionary
- mainDictionary = createListDictionary("","", "", values[1], directoryPath, docPath)
-
- # Add other dictionary options or reset preset options
- if values[4] != "":
- print "Read in value"
- mainDictionary['docDataPath'] = os.path.realpath(values[4])
- else:
- mainDictionary['docDataPath'] = os.path.realpath(os.path.join(directoryPath,'StGermain/doc/'))
- # Setup docScriptPath
- if values[4] != "":
- print "stuff stuff stuff"
- mainDictionary['docScriptPath'] = os.path.join(string.rstrip(os.path.realpath(values[4]), "doc/"), "script/")
- else:
- mainDictionary['docScriptPath'] = os.path.realpath(os.path.join(directoryPath,'StGermain/script/'))
- print mainDictionary['docDataPath']
- print mainDictionary['docScriptPath']
-
- #Reset configPath as necessary:
- if ((values[1] != "") and (values[4] != "") ):
- mainDictionary['configPath'] = os.path.join(mainDictionary['docDataPath'], mainDictionary['configFile'])
- # reset the location of the headerfilter file
- mainDictionary['headerFilterPath'] = mainDictionary['docScriptPath']+"/headerfilter.py"
-
-
-
+ mainDictionary = createListDictionary("","", "", values[1], directoryPath, docPath, values[4])
# Set up help print statement
if ((values[1] == "help") or (values[1] == '-h') or (values[1] =='--help') or (values[1] == 'h')):
diff -r 71b60b1562af -r 767daf30b22b script/createHTMLDocuments.py
--- a/script/createHTMLDocuments.py Wed Jan 06 13:09:34 2010 +1100
+++ b/script/createHTMLDocuments.py Tue Jan 12 14:38:16 2010 +1100
@@ -138,9 +138,9 @@ class createHTMLDocuments(createDocument
text += '<INPUT type=submit name=btnG VALUE="Google Search">\n'
text += '<font size=-1>\n'
text += '<input type=hidden name=domains'+\
- ' value="'+path+'"><br><input type=radio name=sitesearch '+\
+ ' value="'+path+'"><br/><input type=radio name=sitesearch '+\
'value=""> WWW <input type=radio name=sitesearch'+\
- ' value="'+path+'" checked> '+path+' <br>\n'
+ ' value="'+path+'" checked> '+path+' <br/>\n'
text +='</font>\n'
text +='</td></tr></TABLE>\n'
text +='</FORM>\n'
@@ -185,7 +185,7 @@ class createHTMLDocuments(createDocument
## Create the tabs to navigate between the project pages.
def createNavitab(self, projectName):
- text = '<div id="navitab">\n <br>\n '
+ text = '<div id="navitab">\n <br/>\n '
if projectName == 'index':
text += '<a class="'+self.div.navitab[1]+'" href="index.html">Main</a><span class="hide"> | </span>'
else:
@@ -310,14 +310,14 @@ class createHTMLDocuments(createDocument
def createBlurb(self, projectName):
text = '<div id="'+self.div.desc+'">\n'
text += '<h3> '+projectName+' '+self.name+' </h3>\n'
- text += '<p>'+self.blurb+'<br>\n </p>\n </div>\n<br>\n'
+ text += '<p>'+self.blurb+'<br/>\n </p>\n </div>\n<br/>\n'
return text
## Put small blurb on index page, different from project pages. This is fixed
def createIndexBlurb(self, blurb):
text = '<div id="'+self.div.desc+'">\n'
text += '<h3>'+self.name+'</h3>\n'
- text += '<p>'+blurb+'<br>\n </p>\n </div>\n<br>\n'
+ text += '<p>'+blurb+'<br/>\n </p>\n </div>\n<br/>\n'
return text
## Create the meta-file content part of the pages.
@@ -349,7 +349,8 @@ class createHTMLDocuments(createDocument
text += '<div id="'+unicode(self.div.componentInfo[0])+'">\n'
text += '<div id="'+unicode(self.div.componentInfo[1])+'">\n'
text += '<b>'+unicode(name)+'</b>: </div>\n'
- text += '<div id="'+self.div.componentInfo[2]+'">'+value+'<br>\n'
+
+ text += '<div id="'+self.div.componentInfo[2]+'">'+value+'<br/>\n'
text += '</div>\n</div>\n'
return unicode(text)
## Example part of meta component
@@ -360,7 +361,7 @@ class createHTMLDocuments(createDocument
text += '<b>'+str(name)+'</b>:</div>\n'
text += '<div id="'+self.div.componentInfo[2]+'">\n<div id="codebox">\n'
text += '<xmp>'+str(value)+'</xmp>\n'
- text += '<br>\n</div>\n</div>\n</div>\n'
+ text += '<br/>\n</div>\n</div>\n</div>\n'
return text
## List entry html code
@@ -411,20 +412,11 @@ class createHTMLDocuments(createDocument
for title in titleList:
if item.has_key(title):
# check for latex code to convert Does multiple latex entries in one item.
- if string.count(item[title], '$') >1:
- #split string at $ signs
- titleString = " " + item[title]
- myList = string.split(titleString, '$')
- # all 'even' occurances(index 1,3,5 etc as nos start at 0) in this string will be latex code, even if string starts with a $.
- for listValue in range(len(myList)/2):
- latexString = '$' + myList[listValue+1]+'$'
- #call latex function
- picName = self.addEquationPicturePng(componentName +name, latexString, picsIndex)
- newString = '<img src="'+self.pictureSubDirectoryName+'/'+picName+'" ><br>\n'
- myList[listValue+1] = newString
- picsIndex = picsIndex + 1
- #turn list back into string
- text += '<td>'+ (string.lstrip(string.join(myList))).encode('ascii','xmlcharrefreplace')+'</td>'
+
+ if string.count(item[title], '$') >1:
+
+ text += '<td> ' + self.checkTextForEquations(item[title], componentName+name+str(picsIndex))+ '</td>'
+ picsIndex = picsIndex + 1
else:
# add code to table
text += '<td>'+(item[title]).encode('ascii','xmlcharrefreplace')+'</td>'
@@ -433,7 +425,28 @@ class createHTMLDocuments(createDocument
text +='</tr>\n'
text += '\n</table>\n</div>\n</div>'
return text
-
+
+ ## check for latex code to convert Does multiple latex entries in one item.
+ # Converts to html compatible format.
+ def checkTextForEquations(self, textStringIn, name):
+ if string.count(textStringIn, '$') >1:
+ #split string at $ signs
+ titleString = " " + textStringIn
+ myList = string.split(titleString, '$')
+ # all 'even' occurances(index 1,3,5 etc as nos start at 0) in this string will be latex code, even if string starts with a $.
+ picsIndex = 0
+ for listValue in range(int(math.floor(len(myList)/2))):
+ latexString = '$' + myList[2*listValue+1]+'$'
+ #call latex function
+ picName = self.addEquationPicturePng(name, latexString, picsIndex)
+ newString = '<img src="'+self.pictureSubDirectoryName+'/'+picName+'" >\n'
+ myList[2*listValue+1] = newString
+ picsIndex = picsIndex + 1
+ textStringOut = (string.lstrip(string.join(myList))).encode('ascii','xmlcharrefreplace')
+ else:
+ textStringOut = textStringIn
+ return textStringOut
+
## Call latex code to convert latex to pictures in html
def addEquationPicturePng(self, name, value, index):
# add to pics sub-directory
@@ -448,6 +461,8 @@ class createHTMLDocuments(createDocument
#Todo: create equation pic from latex source.
# create latex file.
latexCode = "\\documentclass{article}\n"
+ latexCode += "\\usepackage[latin1]{inputenc}\n"
+ latexCode += "\\usepackage{amsfonts}\n"
latexCode += "\\usepackage{amsmath}\n"
latexCode += "\\usepackage{amsthm}\n"
latexCode += "\\usepackage{amssymb}\n"
@@ -456,6 +471,7 @@ class createHTMLDocuments(createDocument
latexCode += "\\begin{document}\n"
latexCode += value + "\n"
latexCode += "\\end{document}"
+ #print latexCode
latexFileBase = picturePath + "/" + "temp"
latexFileName = latexFileBase +".tex"
latexFile = open(latexFileName, 'w')
@@ -466,9 +482,12 @@ class createHTMLDocuments(createDocument
cwd = os.getcwd()
os.chdir(picturePath)
# run latex on file
+ ###TODO: There is osmething seriously wrong here, as this doesn't work:
+ #### error code does not print, it just crashed.
#os.system('latex '+ latexFileName)
try:
- retcode = subprocess.call('latex '+ latexFileName + ">>temp.txt", shell=True)
+ retcode = subprocess.call('latex '+ latexFileName+ ">>temp.txt" , shell=True)
+
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal: latex file could not be run for creating " + pictureName, -retcode
@@ -484,7 +503,7 @@ class createHTMLDocuments(createDocument
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
#else:
- #print >>sys.stderr, "Picture created for ", pictureName
+ # print >>sys.stderr, "Picture created for ", pictureName
except OSError, e:
print >>sys.stderr, "Execution failed:", e
@@ -510,7 +529,7 @@ class createHTMLDocuments(createDocument
text += '<div id="'+self.div.componentInfo[2]+'">\n'
# create picture
pictureName = self.addEquationPicturePng(componentName, value, 1)
- text += '<img src="'+self.pictureSubDirectoryName+'/'+pictureName+'" align="top"><br>\n'
+ text += '<img src="'+self.pictureSubDirectoryName+'/'+pictureName+'" align="top"><br/>\n'
text += '</div>\n</div>\n'
return text
@@ -561,7 +580,7 @@ class createHTMLDocuments(createDocument
text +='<h3 align="center">\n'
text +='<a name="'+unicode(meta.dictionary['Name'])+'">'+unicode(meta.dictionary['Name'])+'</a>\n'
- text += '</h3>\n<br>\n'
+ text += '</h3>\n<br/>\n'
if meta.dictionary.has_key('Organisation'):
text += self.addSimpleComponentInfo('Organisation', unicode(meta.dictionary['Organisation']))
@@ -576,8 +595,9 @@ class createHTMLDocuments(createDocument
text += self.addParentInfoDtd('Parent', 'Name', unicode(meta.dictionary['Parent']))
text += self.addChildrenInfoDtd('Children', 'Parent', 'Name', (meta.dictionary['Name']).encode('ascii','xmlcharrefreplace'))
-
- text += self.addSimpleComponentInfo('Description', (meta.dictionary['Description']).encode('ascii','xmlcharrefreplace'))
+ #print "*****************"
+ #print meta.dictionary['Name'] + str(string.count(meta.dictionary['Description'], '$'))
+ text += self.addSimpleComponentInfo('Description', self.checkTextForEquations((meta.dictionary['Description']).encode('ascii','xmlcharrefreplace'),unicode(meta.dictionary['Name'])+'Description' ) )
# Next comes reference, if any
if meta.dictionary.has_key('Reference'):
refValue = unicode(meta.dictionary['Reference'])
@@ -587,6 +607,7 @@ class createHTMLDocuments(createDocument
text +=self.addExampleInfo('Example', (meta.dictionary['Example']).encode('ascii','xmlcharrefreplace'))
#Then equation if any
if meta.dictionary.has_key('Equation'):
+ #print "HAS EQUATION"
text +=self.addEquationInfo(unicode(meta.dictionary['Name']), (meta.dictionary['Equation']).encode('ascii','xmlcharrefreplace'))
if meta.dictionary.has_key('Params'):
# then params if any
@@ -646,7 +667,7 @@ class createHTMLDocuments(createDocument
text +='<h3 align="center">\n'
text +='<a name="'+meta.dictionary['info']['title']+'">'+meta.dictionary['info']['title']+'</a>\n'
- text += '</h3>\n<br>\n'
+ text += '</h3>\n<br/>\n'
text += '<h4 align="center">Information</h4>\n'
if meta.dictionary['info'].has_key('creator'):
text += self.addSimpleComponentInfo('creator', meta.dictionary['info']['creator'])
@@ -860,6 +881,9 @@ if __name__=='__main__':
project.assignMetas()
projectList.append(project)
+
+ # sort projects alphabetically
+ projectList.sort()
#now create the HTML documents
print "Now creating HTML documents in directory: " + os.path.realpath(options.documentPath)
#turn Ext.webs into useful list
diff -r 71b60b1562af -r 767daf30b22b script/headerfilter.py
--- a/script/headerfilter.py Wed Jan 06 13:09:34 2010 +1100
+++ b/script/headerfilter.py Tue Jan 12 14:38:16 2010 +1100
@@ -4,7 +4,7 @@ import glob
import glob
import os.path
import shutil
-import string
+import string, math, operator
import sys
import token
import tokenize
@@ -36,6 +36,7 @@ class Input():
self.metaFilename = nameList[0] + ".meta"
if os.path.isfile(self.metaFilename):
return True
+
else:
return False
@@ -49,7 +50,7 @@ class Input():
metaFile = Meta(metaText)
metaFile.createMetaDictionaryDtd()
- #print metaFile.dictionary
+
# put into C friendly format at top of function
# allows for dictionaries embedded in lists in the dictionary
@@ -142,7 +143,7 @@ class Input():
# add in rest of file
for i in range(stringNum, stringEnd-1):
outText += self.output[i]
- #print outText
+
# save to self.output
self.output = outText
else:
@@ -159,19 +160,25 @@ class Input():
stringStart = -1
stringEnd = -1
lineCount = 0
+ functionNames = []
+ parentNames = []
+ goodFunctionNames = []
+ goodParentNames = []
+ functionLineCount = []
+ functionCounter = 0
for line in text:
# find the function Name of the macro:
# Find line that starts with: "#define __" and ends with " \"
stringStart = (str(line)).find("#define __" )
-
+ functionName = ""
+ parentName = ""
+
if stringStart >= 0:
-
+
stringEnd =(str(line)).find("\\")
if stringEnd >=0:
-
- self.lines = [lineCount]
- self.functionName = ((line[stringStart+10: stringEnd]).lstrip()).rstrip()
-
+ functionName = ((line[stringStart+10: stringEnd]).lstrip()).rstrip()
+
stringNextStart = -1
stringNextEnd = -1
stringTemp = ""
@@ -180,95 +187,250 @@ class Input():
for i in range(1,15):
if (lineCount + i) < (len(text)-1):
stringNextStart = (str(text[lineCount +i])).find("__")
+
+
+
+
else:
stringNextStart = (str(text[len(text)-1])).find("__")
+
if stringNextStart >=0:
if (lineCount + i) < (len(text)-1):
stringNextEnd =(str(text[lineCount+i])).find("\\")
+
else:
stringNextEnd = (str(text[len(text)-1])).find("\\")
+
+
if stringNextEnd >= 0:
if (lineCount + i) < (len(text)-1):
- self.parentName = ((text[lineCount +i][stringNextStart + 2:stringNextEnd]).lstrip()).rstrip()
+ parentName = ((text[lineCount +i][stringNextStart + 2:stringNextEnd]).lstrip()).rstrip()
+
+
+
+ functionNames.append(functionName)
+ parentNames.append(parentName)
+
+ functionLineCount.append(lineCount)
+ functionCounter = functionCounter+1
+ break
+
else:
- self.parentName = ((text[len(text)-1][stringNextStart + 2:stringNextEnd]).lstrip()).rstrip()
+ parentName = ((text[len(text)-1][stringNextStart + 2:stringNextEnd]).lstrip()).rstrip()
+ functionNames.append(functionName)
+ parentNames.append(parentName)
+ functionLineCount.append(lineCount)
+ functionCounter = functionCounter+1
+ break
+
stringNextStart = -1
stringNextEnd = -1
+
+
+
+
stringStart = -1
stringEnd = -1
stringMiddle = -1
+
+
#Find line that creates the inherited struct:
# Find line that looks like " struct ",self.functionName," { __",self.FunctionName," };"
- myString = ""
- myString = "struct "
- myMiddleString = self.functionName
- myNextString = "__"+self.functionName
- stringStart = (str(line)).find(myString )
-
- if stringStart >=0:
+ functionCounter = 0
+
+
+ for functionName in functionNames:
+ myString = ""
+ myString = "struct "
+ myMiddleString = functionName
+ myNextString = "__"+functionName
+ stringStart = (str(line)).find(myString )
+
+ if stringStart >=0:
+
stringMiddle = (str(line)).find(myMiddleString)
stringEnd = (str(line)).find(myNextString)
if stringEnd >=0:
-
- (self.lines).append(lineCount)
+
+ # have to make this adaptable to multifunction possiblilities ...ouch.
+ goodFunctionNames.append(functionName)
+
+ goodParentNames.append(parentNames[functionCounter])
+ #Extract out lineCount beginning for section
+
+ (self.lines).append(functionLineCount[functionCounter])
+ # add lineCount end for section
+ (self.lines).append(lineCount)
+
elif stringMiddle >=0:
#check next line for remainder of code, just in case it didn't fit on one line.
stringEnd = (str(text[lineCount+1])).find(myNextString)
if stringEnd >=0:
- (self.lines).append(lineCount+1)
-
- lineCount = lineCount + 1
+ goodFunctionNames.append(functionName)
+ goodParentNames.append(parentNames[functionCounter])
-
- # Now, if there is text to replace:
- if self.functionName != "":
+ (self.lines).append(functionLineCount[functionCounter])
+ (self.lines).append(lineCount+1)
+
+
+ functionCounter = functionCounter +1
+ lineCount = lineCount + 1
+
+
+
+ # Now we have to check for #ifdef and #else statements within the code structure.
+ # If length self.lines > 2, then that means there maybe multiple definitions of the
+ # class, or multiple classes defined within the file... the second would be harder to manage.
+
+ if len(self.lines) > 2:
+
+ endLines = []
+ #check line before self.lines beginning for #ifdef or #else statements
+ # self.lines comes in [start, stop] pairs
+ for i in range (len(self.lines)/2):
+
+ # arbitrary range to check no of lines before #define line
+ inLoop = False
+ for k in range(1,4):
+ lineNum = self.lines[2*i] -k
+ if lineNum < 0:
+ lineNum = 0
+
+ if ((text[lineNum]).find("#ifdef") ) or ( (text[lineNum]).find("#else") ) :
+ inLoop = True
+
+ break
+
+ # It is in an #ifdef loop.
+ #so have to redefine the lines to be removed.
+ #Look for #else or #end
+ if inLoop == True:
+
+ for lineNum in range(self.lines[2*i], len(text) ):
+ if ((text[lineNum]).find("#else") >=0 ) or ( (text[lineNum]).find("#end") >=0 ) :
+
+ endLines.append(self.lines[2*i+1])
+ self.lines[2*i +1] = lineNum -1
+ break
+
+
+
+ # Now, if there is text to replace:
+ goodFuncCount = 0
+
+ for functionName in goodFunctionNames:
+ # dodgy set here, to let meta stuff work.
+ self.functionName = functionName
+
+ if functionName != "":
# replace all text between lines [a, b] with new struct structure:
inheritanceText = ""
# if no parent function, add all inbetween text
- if self.parentName != "":
- inheritanceText = " : "+self.parentName
- self.addedText = "struct "+ self.functionName + inheritanceText +"\n {\n "
+ parentName = goodParentNames[goodFuncCount]
+ self.parentName = goodParentNames[goodFuncCount]
+ if parentName != "":
+ inheritanceText = " : "+parentName
+ self.addedText = "struct "+ functionName + inheritanceText +"\n {\n "
lineNum = -1
-
- if len(self.lines) == 2:
- for lineNum in range(self.lines[0]+1, self.lines[1]-1):
- if self.parentName == "":
+
+ if operator.mod(len(self.lines),2) == 0:
+
+ for lineNum in range(self.lines[goodFuncCount*2]+1, self.lines[goodFuncCount*2 + 1]+1):
+ if parentName == "":
+ if (text[lineNum].find(functionName) < 0) and (text[lineNum].find("struct ") < 0) :
self.addedText += text[lineNum].split("\\")[0] + "\n "
+
else:
+ if (text[lineNum].find(functionName) < 0) and (text[lineNum].find("struct ") < 0) :
# add inbetween text removing old parent function line
- myText = 0
- myText = text[lineNum].count(self.parentName)
+ myText = -1
+ myText = text[lineNum].find(parentName)
+ if (myText < 0):
+ self.addedText += text[lineNum].split("\\")[0] + "\n "
+
- if myText == 0:
- self.addedText += text[lineNum].split("\\")[0] + "\n "
-
# replace old text section with new 'addedText'
- for lines in range(0, self.lines[0]-1):
- self.output += text[lines]
- self.output += self.addedText
- #Add in public: statement just in case.
+ if goodFuncCount == 0 :
+
+ for lines in range(0, self.lines[goodFuncCount*2]):
+
+ # make sure old struct functionname line not included.
+ if len(self.lines) >2 :
+ if lines != endLines[goodFuncCount]:
+ self.output += text[lines]
+
+ else:
+
+ self.output += text[lines]
+
+ else:
+ for lines in range(self.lines[((goodFuncCount-1) * 2)+1]+1, self.lines[goodFuncCount*2]):
+
+
+ # make sure old struct functionname line not included.
+ if len(self.lines) >2 :
+ if lines != endLines[goodFuncCount]:
+ self.output += text[lines]
+ else:
+ if lines != self.lines[len(self.lines)-1]:
+ self.output += text[lines]
+
+
+ self.output += self.addedText
+
+
+ #Add in public: statement just in case.
self.output += "public: \n"
-
- # Find #endif statement and insert bracket before it.
- for lines in range(self.lines[1]+1, len(text)):
- if ((text[lines]).find("#endif") >= 0):
-
- self.output += "};\n" + text[lines]
- else:
- self.output += text[lines]
- # if no alterations are needed, then write output to screen as is
- elif self.functionName == "":
- for lines in range(0, len(text)):
- self.output += text[lines]
- self.output+=" "
-
+ goodFuncCount = goodFuncCount + 1
+
+
+
+
+ # if no alterations are needed, then write output to screen as is
+ totalFunctionName = ""
+ for functionName in goodFunctionNames:
+ totalFunctionName = totalFunctionName + functionName
+
+ if totalFunctionName == "":
+ for lines in range(0, len(text)):
+ self.output += text[lines]
+ self.output+=" "
+
+ # Find last #endif statement and insert bracket before it.
+ if goodFunctionNames != []:
+ if goodFunctionNames[0] != "" :
+
+ for lines in range(len(text)-1, self.lines[len(self.lines) -1], -1):
+ if ((text[lines]).find("#endif") >= 0):
+ endLineNum = lines
+ break
+
+ for lines in range(self.lines[len(self.lines)-1]+1, len(text) ):
+ if (lines == endLineNum):
+ self.output += "};\n" + text[lines]
+ else:
+ valueBool = False
+ if len(self.lines) > 2:
+ for value in range(0, len(endLines)):
+ if lines == endLines[value]:
+ valueBool = True
+ else:
+
+ if lines == self.lines[1]:
+
+ valueBool = True
+ if valueBool == False:
+ self.output += text[lines]
+
+
+
## main function to tie all class functions together in a run
def main(self):
# Read in files
diff -r 71b60b1562af -r 767daf30b22b src/main.c
--- a/src/main.c Wed Jan 06 13:09:34 2010 +1100
+++ b/src/main.c Tue Jan 12 14:38:16 2010 +1100
@@ -63,16 +63,16 @@ typedef void (ForEachFunc) ( Stream* str
typedef void (ForEachFunc) ( Stream* stream, Type componentType );
static void forEachComponent( Stream* stream, ForEachFunc* forEach ) {
- BTreeIterator* i;
+ int i;
+ Stg_ComponentRegister* cr;
Stg_ComponentRegisterElement* cre;
- i = Stg_ComponentRegister_GetIterator( Stg_ComponentRegister_Get_ComponentRegister() );
- for( cre = Stg_ComponentRegisterIterator_First( i ); cre != NULL; cre = Stg_ComponentRegisterIterator_Next( i ) ) {
+ cr = Stg_ComponentRegister_Get_ComponentRegister();
+ for(i = 0; i < Stg_ComponentRegister_GetCount(cr); i++) {
+ cre = Stg_ComponentRegister_GetByIndex(cr, i);
Type componentType = Stg_ComponentRegisterElement_GetType( cre );
forEach( stream, componentType );
}
-
- Stg_Class_Delete( i );
}
static void forEachLiveComponent( Stream* stream, ForEachFunc* forEach ) {
@@ -143,17 +143,19 @@ static void printRightsListItem( Stream*
int main( int argc, char* argv[] ) {
/* StGermain standard bits & pieces */
- MPI_Comm CommWorld;
- int rank;
- int numProcessors;
- Dictionary* dictionary;
+ MPI_Comm CommWorld;
+ int rank;
+ int numProcessors;
+ Dictionary* dictionary;
XML_IO_Handler* ioHandler;
- Stream* stream;
- char* helpTopic;
- char* listAllTopic;
- Stg_ObjectList* listAllTopics;
- char* listTopic;
- Stg_ObjectList* listTopics;
+ Stream* stream;
+ char* helpTopic;
+ char* listAllTopic;
+ Stg_ObjectList* listAllTopics;
+ char* listTopic;
+ Stg_ObjectList* listTopics;
+ Dictionary* componentDict;
+ Stg_ComponentFactory* cf;
/* Initialise PETSc, get world info */
MPI_Init( &argc, &argv );
@@ -198,8 +200,8 @@ int main( int argc, char* argv[] ) {
Dictionary* metadata;
Index i;
- ModulesManager_Load( stgToolboxesManager, dictionary );
- ModulesManager_Load( plugins, dictionary );
+ ModulesManager_Load( stgToolboxesManager, dictionary, "" );
+ ModulesManager_Load( plugins, dictionary, "context" );
/* "--help" parameter */
if( helpTopic ) {
@@ -245,11 +247,17 @@ int main( int argc, char* argv[] ) {
}
else { /* ... run the app */
Index i;
- AbstractContext* context;
+ PluginsManager* lucPluginManager = PluginsManager_New();
+
+ /* the lucPlugin is not associated with a given context, as other plugins are, so load it in manually, assuming it exists */
+ ModulesManager_Load( lucPluginManager, dictionary, "lucPluginContext" );
+
+ ModulesManager_Load( stgToolboxesManager, dictionary, "" );
/* Magic happens here! */
- context = stgMainInit( dictionary, CommWorld );
- stgMainLoop( context );
+ cf = stgMainConstruct( dictionary, CommWorld, NULL );
+ stgMainBuildAndInitialise( cf );
+ stgMainLoop( cf );
/* "--list" parameters */
for( i = 0; i < Stg_ObjectList_Count( listTopics ); i++ ) {
@@ -277,14 +285,12 @@ int main( int argc, char* argv[] ) {
}
}
- stgMainDestroy( context );
+ stgMainDestroy( cf );
}
-
/* Close off everything */
Stg_Class_Delete( listAllTopics );
Stg_Class_Delete( listTopics );
- Stg_Class_Delete( dictionary );
#ifdef HAVE_PYTHON
Py_Finalize();
#endif
@@ -293,3 +299,5 @@ int main( int argc, char* argv[] ) {
return 0; /* success */
}
+
+
More information about the CIG-COMMITS
mailing list