Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
tpia_depot.cc File Reference
#include <string.h>
#include <tpia_depot.h>

Go to the source code of this file.

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 *, 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_targetEntrytpia_depot_getFirstTargetEntry (tpia_depot *depot)
 
tpia_targetEntrytpia_depot_getNextTargetEntry (tpia_targetEntry *targetEntry)
 
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)
 

Function Documentation

◆ tpia_depot_addTarget()

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.

153 {
154
155 return( tpia_depot_addTargetFromMap( smr, depot, depot->map, evaluation, targetName ) );
156}
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: tpia_depot.cc:160

◆ tpia_depot_addTargetFromMap()

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.

160 {
161
162 tpia_targetEntry *targetEntry;
163 tpia_target *target;
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,...)
char * projectileName
Definition: tpia_depot.h:60
tpia_target * target
Definition: tpia_depot.h:55
tpia_particle * targetID
Definition: tpia_target.h:298
tpia_targetEntry * tpia_depot_getNextTargetEntry(tpia_targetEntry *targetEntry)
Definition: tpia_depot.cc:146
tpia_targetEntry * tpia_depot_getFirstTargetEntry(tpia_depot *depot)
Definition: tpia_depot.cc:139
tpia_target * tpia_target_createReadFromMap(statusMessageReporting *smr, tpia_map *map, const char *evaluation, const char *projectileName, const char *targetName)
Definition: tpia_target.cc:93

Referenced by tpia_depot_addTarget().

◆ tpia_depot_create()

tpia_depot * tpia_depot_create ( statusMessageReporting smr,
const char *  projectileName 
)

Definition at line 47 of file tpia_depot.cc.

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}
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
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313

◆ tpia_depot_free()

tpia_depot * tpia_depot_free ( tpia_depot depot,
int  freeMap 
)

Definition at line 74 of file tpia_depot.cc.

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

Referenced by tpia_depot_create().

◆ tpia_depot_freeMap()

int tpia_depot_freeMap ( tpia_depot depot)

Definition at line 129 of file tpia_depot.cc.

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

◆ tpia_depot_getFirstTargetEntry()

tpia_targetEntry * tpia_depot_getFirstTargetEntry ( tpia_depot depot)

Definition at line 139 of file tpia_depot.cc.

139 {
140
141 return( depot->targets );
142}
tpia_targetEntry * targets
Definition: tpia_depot.h:62

Referenced by tpia_depot_addTargetFromMap().

◆ tpia_depot_getNextTargetEntry()

tpia_targetEntry * tpia_depot_getNextTargetEntry ( tpia_targetEntry targetEntry)

Definition at line 146 of file tpia_depot.cc.

146 {
147
148 return( targetEntry->next );
149}
tpia_targetEntry * next
Definition: tpia_depot.h:54

Referenced by tpia_depot_addTargetFromMap().

◆ tpia_depot_initialize()

int tpia_depot_initialize ( statusMessageReporting smr,
tpia_depot depot,
const char *  projectileName 
)

Definition at line 59 of file tpia_depot.cc.

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}
int numberOfTargets
Definition: tpia_depot.h:61

Referenced by tpia_depot_create().

◆ tpia_depot_release()

int tpia_depot_release ( tpia_depot depot,
int  freeMap 
)

Definition at line 83 of file tpia_depot.cc.

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

Referenced by tpia_depot_free().

◆ tpia_depot_releaseMap()

tpia_map * tpia_depot_releaseMap ( tpia_depot depot)

Definition at line 119 of file tpia_depot.cc.

119 {
120
121 tpia_map *map = depot->map;
122
123 depot->map = NULL;
124 return( map );
125}

Referenced by tpia_depot_freeMap().

◆ tpia_depot_setMap()

int tpia_depot_setMap ( statusMessageReporting smr,
tpia_depot depot,
tpia_map map 
)

Definition at line 103 of file tpia_depot.cc.

103 {
104
105 depot->map = map;
106 return( 0 );
107}

◆ tpia_depot_setMapFromFilename()

int tpia_depot_setMapFromFilename ( statusMessageReporting smr,
tpia_depot depot,
const char *  basePath,
const char *  mapFileName 
)

Definition at line 111 of file tpia_depot.cc.

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