37 #include <tpia_depot.h>
39 #if defined __cplusplus
52 if( ( depot = (tpia_depot*) xData_malloc2( smr,
sizeof( tpia_depot ), 0,
"map" ) ) == NULL )
return( NULL );
61 memset( depot, 0,
sizeof( tpia_depot ) );
63 depot->projectileName = NULL;
64 depot->numberOfTargets = 0;
65 depot->targets = NULL;
68 if( ( depot->projectileName = (
char*) xData_malloc2( smr, strlen( projectileName ) + 1, 0,
"projectile" ) ) == NULL )
return( 1 );
85 tpia_targetEntry *next, *targetEntry;
87 if( depot->projectileName != NULL )
xData_free( NULL, depot->projectileName );
88 for( targetEntry = depot->targets; targetEntry != NULL; targetEntry = next ) {
89 next = targetEntry->next;
93 depot->numberOfTargets = 0;
94 depot->targets = NULL;
96 if( freeMap && ( depot->map != NULL ) ) depot->map = (tpia_map*)
tpia_map_free( NULL, depot->map );
97 return( depot->status = 0 );
113 if( ( depot->map =
tpia_map_readFile( smr, basePath, mapFileName ) ) == NULL )
return( 1 );
121 tpia_map *map = depot->map;
141 return( depot->targets );
148 return( targetEntry->next );
153 tpia_target *
tpia_depot_addTarget( statusMessageReporting *smr, tpia_depot *depot,
const char *evaluation,
const char *targetName ) {
160 tpia_target *
tpia_depot_addTargetFromMap( statusMessageReporting *smr, tpia_depot *depot, tpia_map *map,
const char *evaluation,
const char *targetName ) {
162 tpia_targetEntry *targetEntry;
166 if( !strcmp( targetEntry->target->targetID->name, targetName ) ) {
167 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"depot already contains target = %s ", targetName );
175 #if defined __cplusplus
tpia_map * tpia_map_readFile(statusMessageReporting *smr, const char *basePath, const char *mapFileName)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
int tpia_depot_release(tpia_depot *depot, int freeMap)
tpia_targetEntry * tpia_depot_getNextTargetEntry(tpia_targetEntry *targetEntry)
tpia_target * tpia_depot_addTargetFromMap(statusMessageReporting *smr, tpia_depot *depot, tpia_map *map, const char *evaluation, const char *targetName)
int tpia_depot_setMap(statusMessageReporting *, tpia_depot *depot, tpia_map *map)
tpia_depot * tpia_depot_create(statusMessageReporting *smr, const char *projectileName)
tpia_targetEntry * tpia_depot_getFirstTargetEntry(tpia_depot *depot)
int tpia_depot_setMapFromFilename(statusMessageReporting *smr, tpia_depot *depot, const char *basePath, const char *mapFileName)
tpia_target * tpia_target_free(statusMessageReporting *smr, tpia_target *target)
tpia_map * tpia_depot_releaseMap(tpia_depot *depot)
void * xData_free(statusMessageReporting *, void *p)
tpia_target * tpia_depot_addTarget(statusMessageReporting *smr, tpia_depot *depot, const char *evaluation, const char *targetName)
tpia_depot * tpia_depot_free(tpia_depot *depot, int freeMap)
void * tpia_map_free(statusMessageReporting *smr, tpia_map *map)
int tpia_depot_freeMap(tpia_depot *depot)
int tpia_depot_initialize(statusMessageReporting *smr, tpia_depot *depot, const char *projectileName)
tpia_target * tpia_target_createReadFromMap(statusMessageReporting *smr, tpia_map *map, const char *evaluation, const char *projectileName, const char *targetName)