Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Typedefs | Functions
tpia_depot.h File Reference
#include <tpia_map.h>
#include <tpia_target.h>

Go to the source code of this file.

Data Structures

struct  tpia_targetEntry_s
 
struct  tpia_depot_s
 

Typedefs

typedef struct tpia_targetEntry_s tpia_targetEntry
 
typedef struct tpia_depot_s tpia_depot
 

Functions

tpia_depottpia_depot_create (statusMessageReporting *smr, const char *projectileName)
 
int tpia_depot_initialize (statusMessageReporting *smr, tpia_depot *depot, const char *projectileName)
 
tpia_depottpia_depot_free (tpia_depot *depot, int freeMap)
 
int tpia_depot_release (tpia_depot *depot, int freeMap)
 
int tpia_depot_setMap (statusMessageReporting *smr, tpia_depot *depot, tpia_map *map)
 
int tpia_depot_setMapFromFilename (statusMessageReporting *smr, tpia_depot *depot, const char *basePath, const char *mapFileName)
 
tpia_maptpia_depot_releaseMap (tpia_depot *depot)
 
int tpia_depot_freeMap (tpia_depot *depot)
 
tpia_targettpia_depot_addTarget (statusMessageReporting *smr, tpia_depot *depot, const char *evaluation, const char *targetName)
 
tpia_targettpia_depot_addTargetFromMap (statusMessageReporting *smr, tpia_depot *depot, tpia_map *map, const char *evaluation, const char *targetName)
 

Typedef Documentation

typedef struct tpia_depot_s tpia_depot

Definition at line 51 of file tpia_depot.h.

Definition at line 50 of file tpia_depot.h.

Function Documentation

tpia_target* tpia_depot_addTarget ( statusMessageReporting smr,
tpia_depot depot,
const char *  evaluation,
const char *  targetName 
)

Definition at line 153 of file tpia_depot.cc.

References tpia_depot_s::map, and tpia_depot_addTargetFromMap().

153  {
154 
155  return( tpia_depot_addTargetFromMap( smr, depot, depot->map, evaluation, targetName ) );
156 }
tpia_target * tpia_depot_addTargetFromMap(statusMessageReporting *smr, tpia_depot *depot, tpia_map *map, const char *evaluation, const char *targetName)
Definition: tpia_depot.cc:160
tpia_map * map
Definition: tpia_depot.h:63
tpia_target* tpia_depot_addTargetFromMap ( statusMessageReporting smr,
tpia_depot depot,
tpia_map map,
const char *  evaluation,
const char *  targetName 
)

Definition at line 160 of file tpia_depot.cc.

References tpia_particle_s::name, tpia_depot_s::projectileName, smr_setMessageError(), tpia_targetEntry_s::target, tpia_target_s::targetID, tpia_depot_getFirstTargetEntry(), tpia_depot_getNextTargetEntry(), and tpia_target_createReadFromMap().

Referenced by tpia_depot_addTarget().

160  {
161 
162  tpia_targetEntry *targetEntry;
164 
165  for( targetEntry = tpia_depot_getFirstTargetEntry( depot ); targetEntry != NULL; targetEntry = tpia_depot_getNextTargetEntry( targetEntry ) ) {
166  if( !strcmp( targetEntry->target->targetID->name, targetName ) ) {
167  smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "depot already contains target = %s ", targetName );
168  return( NULL );
169  }
170  }
171  target = tpia_target_createReadFromMap( smr, map, evaluation, depot->projectileName, targetName );
172  return( target );
173 }
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
const XML_Char * target
Definition: tpia_depot.h:53
tpia_targetEntry * tpia_depot_getNextTargetEntry(tpia_targetEntry *targetEntry)
Definition: tpia_depot.cc:146
tpia_target * target
Definition: tpia_depot.h:55
tpia_targetEntry * tpia_depot_getFirstTargetEntry(tpia_depot *depot)
Definition: tpia_depot.cc:139
tpia_particle * targetID
Definition: tpia_target.h:298
tpia_target * tpia_target_createReadFromMap(statusMessageReporting *smr, tpia_map *map, const char *evaluation, const char *projectileName, const char *targetName)
Definition: tpia_target.cc:93
char * projectileName
Definition: tpia_depot.h:60
tpia_depot* tpia_depot_create ( statusMessageReporting smr,
const char *  projectileName 
)

Definition at line 47 of file tpia_depot.cc.

References tpia_depot_free(), tpia_depot_initialize(), and xData_malloc2.

47  {
48 
49  tpia_depot *depot;
50 
51  //if( ( depot = xData_malloc2( smr, sizeof( tpia_depot ), 0, "map" ) ) == NULL ) return( NULL );
52  if( ( depot = (tpia_depot*) xData_malloc2( smr, sizeof( tpia_depot ), 0, "map" ) ) == NULL ) return( NULL );
53  if( tpia_depot_initialize( smr, depot, projectileName ) ) depot = tpia_depot_free( depot, 0 );
54  return( depot );
55 }
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313
tpia_depot * tpia_depot_free(tpia_depot *depot, int freeMap)
Definition: tpia_depot.cc:74
int tpia_depot_initialize(statusMessageReporting *smr, tpia_depot *depot, const char *projectileName)
Definition: tpia_depot.cc:59
tpia_depot* tpia_depot_free ( tpia_depot depot,
int  freeMap 
)

Definition at line 74 of file tpia_depot.cc.

References tpia_depot_release(), and xData_free().

Referenced by tpia_depot_create().

74  {
75 
76  tpia_depot_release( depot, freeMap );
77  xData_free( NULL, depot );
78  return( NULL );
79 }
int tpia_depot_release(tpia_depot *depot, int freeMap)
Definition: tpia_depot.cc:83
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89
int tpia_depot_freeMap ( tpia_depot depot)

Definition at line 129 of file tpia_depot.cc.

References tpia_depot_releaseMap(), and tpia_map_free().

129  {
130 
131  tpia_map *map = tpia_depot_releaseMap( depot );
132 
133  if( map != NULL ) tpia_map_free( NULL, map );
134  return( 0 );
135 }
void * tpia_map_free(statusMessageReporting *smr, tpia_map *map)
Definition: tpia_map.cc:184
tpia_map * tpia_depot_releaseMap(tpia_depot *depot)
Definition: tpia_depot.cc:119
int tpia_depot_initialize ( statusMessageReporting smr,
tpia_depot depot,
const char *  projectileName 
)

Definition at line 59 of file tpia_depot.cc.

References tpia_depot_s::map, tpia_depot_s::numberOfTargets, tpia_depot_s::projectileName, tpia_depot_s::status, tpia_depot_s::targets, and xData_malloc2.

Referenced by tpia_depot_create().

59  {
60 
61  memset( depot, 0, sizeof( tpia_depot ) );
62  depot->status = 0;
63  depot->projectileName = NULL;
64  depot->numberOfTargets = 0;
65  depot->targets = NULL;
66  depot->map = NULL;
67  //if( ( depot->projectileName = xData_malloc2( smr, strlen( projectileName ) + 1, 0, "projectile" ) ) == NULL ) return( 1 );
68  if( ( depot->projectileName = (char*) xData_malloc2( smr, strlen( projectileName ) + 1, 0, "projectile" ) ) == NULL ) return( 1 );
69  return( 0 );
70 }
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313
int numberOfTargets
Definition: tpia_depot.h:61
tpia_targetEntry * targets
Definition: tpia_depot.h:62
tpia_map * map
Definition: tpia_depot.h:63
char * projectileName
Definition: tpia_depot.h:60
int tpia_depot_release ( tpia_depot depot,
int  freeMap 
)

Definition at line 83 of file tpia_depot.cc.

References tpia_depot_s::map, tpia_targetEntry_s::next, tpia_depot_s::numberOfTargets, tpia_depot_s::projectileName, tpia_depot_s::status, tpia_targetEntry_s::target, tpia_depot_s::targets, tpia_map_free(), tpia_target_free(), and xData_free().

Referenced by tpia_depot_free().

83  {
84 
85  tpia_targetEntry *next, *targetEntry;
86 
87  if( depot->projectileName != NULL ) xData_free( NULL, depot->projectileName );
88  for( targetEntry = depot->targets; targetEntry != NULL; targetEntry = next ) {
89  next = targetEntry->next;
90  tpia_target_free( NULL, targetEntry->target );
91  xData_free( NULL, targetEntry );
92  }
93  depot->numberOfTargets = 0;
94  depot->targets = NULL;
95  //if( freeMap && ( depot->map != NULL ) ) depot->map = tpia_map_free( NULL, depot->map );
96  if( freeMap && ( depot->map != NULL ) ) depot->map = (tpia_map*) tpia_map_free( NULL, depot->map );
97  return( depot->status = 0 );
98 }
tpia_target * tpia_target_free(statusMessageReporting *smr, tpia_target *target)
Definition: tpia_target.cc:108
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89
Definition: tpia_depot.h:53
int numberOfTargets
Definition: tpia_depot.h:61
tpia_targetEntry * targets
Definition: tpia_depot.h:62
tpia_target * target
Definition: tpia_depot.h:55
tpia_map * map
Definition: tpia_depot.h:63
void * tpia_map_free(statusMessageReporting *smr, tpia_map *map)
Definition: tpia_map.cc:184
tpia_targetEntry * next
Definition: tpia_depot.h:54
char * projectileName
Definition: tpia_depot.h:60
tpia_map* tpia_depot_releaseMap ( tpia_depot depot)

Definition at line 119 of file tpia_depot.cc.

References tpia_depot_s::map.

Referenced by tpia_depot_freeMap().

119  {
120 
121  tpia_map *map = depot->map;
122 
123  depot->map = NULL;
124  return( map );
125 }
tpia_map * map
Definition: tpia_depot.h:63
int tpia_depot_setMap ( statusMessageReporting smr,
tpia_depot depot,
tpia_map map 
)

Definition at line 103 of file tpia_depot.cc.

References tpia_depot_s::map.

103  {
104 
105  depot->map = map;
106  return( 0 );
107 }
tpia_map * map
Definition: tpia_depot.h:63
int tpia_depot_setMapFromFilename ( statusMessageReporting smr,
tpia_depot depot,
const char *  basePath,
const char *  mapFileName 
)

Definition at line 111 of file tpia_depot.cc.

References tpia_depot_s::map, and tpia_map_readFile().

111  {
112 
113  if( ( depot->map = tpia_map_readFile( smr, basePath, mapFileName ) ) == NULL ) return( 1 );
114  return( 0 );
115 }
tpia_map * tpia_map_readFile(statusMessageReporting *smr, const char *basePath, const char *mapFileName)
Definition: tpia_map.cc:88
tpia_map * map
Definition: tpia_depot.h:63