Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCGIDI_map.cc File Reference
#include <string.h>
#include <limits.h>
#include <PoPs.h>
#include "MCGIDI_map.h"
#include <xDataTOM_importXML_private.h>
Include dependency graph for MCGIDI_map.cc:

Go to the source code of this file.

Macros

#define PATH_MAX   4096
 

Functions

static MCGIDI_mapEntry_MCGIDI_map_addEntry (statusMessageReporting *smr, MCGIDI_map *map, enum MCGIDI_mapEntry_type type, const char *schema, const char *path, const char *evaluation, const char *projectile, const char *target)
 
static char * _MCGIDI_map_findTargetViaPoPIDs2 (statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, int projectile_PoPID, int target_PoPID)
 
static int _MCGIDI_map_findAllOfTargetViaPoPIDs2 (statusMessageReporting *smr, MCGIDI_map *mapAllOfTarget, MCGIDI_map *map, int projectile_PoPID, int target_PoPID)
 
static int _MCGIDI_map_walkTree2 (statusMessageReporting *smr, MCGIDI_map *map, int level, int(*handler)(MCGIDI_mapEntry *entry, int level, void *userData), void *userData)
 
static void _MCGIDI_map_simpleWrite2 (FILE *f, MCGIDI_map *map, int level)
 
static char * _MCGIDI_map_smrUserInterface (void *userData)
 
MCGIDI_mapMCGIDI_map_new (statusMessageReporting *smr)
 
int MCGIDI_map_initialize (statusMessageReporting *smr, MCGIDI_map *map)
 
MCGIDI_mapMCGIDI_map_readFile (statusMessageReporting *smr, const char *basePath, const char *mapFileName)
 
voidMCGIDI_map_free (statusMessageReporting *smr, MCGIDI_map *map)
 
void MCGIDI_map_release (statusMessageReporting *smr, MCGIDI_map *map)
 
MCGIDI_mapEntryMCGIDI_map_getFirstEntry (MCGIDI_map *map)
 
MCGIDI_mapEntryMCGIDI_map_getNextEntry (MCGIDI_mapEntry *entry)
 
int MCGIDI_map_addTarget (statusMessageReporting *smr, MCGIDI_map *map, const char *schema, const char *path, const char *evaluation, const char *projectile, const char *target)
 
int MCGIDI_map_addPath (statusMessageReporting *smr, MCGIDI_map *map, const char *path)
 
char * MCGIDI_map_findTargetViaPoPIDs (statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, int projectile_PoPID, int target_PoPID)
 
char * MCGIDI_map_findTarget (statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, const char *projectile, const char *targetName)
 
MCGIDI_mapMCGIDI_map_findAllOfTargetViaPoPIDs (statusMessageReporting *smr, MCGIDI_map *map, int projectile_PoPID, int target_PoPID)
 
MCGIDI_mapMCGIDI_map_findAllOfTarget (statusMessageReporting *smr, MCGIDI_map *map, const char *projectile, const char *targetName)
 
char * MCGIDI_map_getFullPath (statusMessageReporting *smr, MCGIDI_map *map, const char *endPath)
 
char * MCGIDI_map_getTargetsFullPath (statusMessageReporting *smr, MCGIDI_mapEntry *target)
 
int MCGIDI_map_walkTree (statusMessageReporting *smr, MCGIDI_map *map, int(*handler)(MCGIDI_mapEntry *entry, int level, void *userData), void *userData)
 
char * MCGIDI_map_toXMLString (statusMessageReporting *smr, MCGIDI_map *map)
 
void MCGIDI_map_simpleWrite (FILE *f, MCGIDI_map *map)
 

Variables

static int aliasesNeeded = 1
 

Macro Definition Documentation

#define PATH_MAX   4096

Definition at line 12 of file MCGIDI_map.cc.

Function Documentation

static MCGIDI_mapEntry * _MCGIDI_map_addEntry ( statusMessageReporting smr,
MCGIDI_map map,
enum MCGIDI_mapEntry_type  type,
const char *  schema,
const char *  path,
const char *  evaluation,
const char *  projectile,
const char *  target 
)
static

Definition at line 237 of file MCGIDI_map.cc.

238  {
239 
241  MCGIDI_mapEntry *entry;
242 
243  if( ( entry = (MCGIDI_mapEntry * ) smr_malloc2( smr, sizeof( MCGIDI_mapEntry ), 1, "entry" ) ) == NULL ) return( NULL );
244  entry->next = NULL;
245  entry->type = type;
246  entry->parent = map;
247  entry->schema = NULL;
248  entry->path = NULL;
249  entry->evaluation = NULL;
250  entry->projectile = NULL;
251  entry->targetName = NULL;
253  entry->map = NULL;
254 
255  if( path != NULL ) {
256  if( ( entry->path = (char *) smr_malloc2( smr, strlen( path ) + 1, 0, "path" ) ) == NULL ) goto err;
257  strcpy( entry->path, path );
258  }
259 
260  if( evaluation != NULL ) {
261  if( ( entry->evaluation = (char *) smr_malloc2( smr, strlen( evaluation ) + 1, 0, "evaluation" ) ) == NULL ) goto err;
262  strcpy( entry->evaluation, evaluation );
263  }
264 
265  if( projectile != NULL ) {
266  if( ( entry->globalPoPsIndexProjectile = lPoPs_addParticleIfNeeded( smr, projectile, "LLNL" ) ) < 0 ) goto err;
267  if( ( entry->projectile = (char *) smr_malloc2( smr, strlen( projectile ) + 1, 0, "projectile" ) ) == NULL ) goto err;
268  strcpy( entry->projectile, projectile );
269  }
270 
271  if( targetName != NULL ) {
272  if( ( entry->globalPoPsIndexTarget = lPoPs_addParticleIfNeeded( smr, targetName, "LLNL" ) ) < 0 ) goto err;
273  if( ( entry->targetName = (char *) smr_malloc2( smr, strlen( targetName ) + 1, 0, "target" ) ) == NULL ) goto err;
274  strcpy( entry->targetName, targetName );
275  }
276 
277  if( schema != NULL ) {
278  if( ( entry->schema = (char *) smr_malloc2( smr, strlen( schema ) + 1, 0, "schema" ) ) == NULL ) goto err;
279  strcpy( entry->schema, schema );
280  }
281 
282  if( map->mapEntries == NULL ) {
283  map->mapEntries = entry; }
284  else {
285  for( p = map->mapEntries; p->next != NULL; p = p->next );
286  p->next = entry;
287  }
288  map->numberOfEntries++;
289  return( entry );
290 
291 err:
292  smr_freeMemory( (void **) &(entry->path) );
293  smr_freeMemory( (void **) &(entry->evaluation) );
294  smr_freeMemory( (void **) &(entry->projectile) );
295  smr_freeMemory( (void **) &(entry->targetName) );
296  smr_freeMemory( (void **) &entry );
297  return( NULL );
298 }
MCGIDI_map * parent
Definition: MCGIDI_map.h:31
char * path
Definition: MCGIDI_map.h:33
int globalPoPsIndexProjectile
Definition: MCGIDI_map.h:37
char * evaluation
Definition: MCGIDI_map.h:34
const char * p
Definition: xmltok.h:285
Definition: MCGIDI_map.h:28
int lPoPs_addParticleIfNeeded(statusMessageReporting *smr, char const *name, char const *special)
Definition: lPoPs.cc:36
char * targetName
Definition: MCGIDI_map.h:36
MCGIDI_mapEntry * mapEntries
Definition: MCGIDI_map.h:47
#define smr_malloc2(smr, size, zero, forItem)
int numberOfEntries
Definition: MCGIDI_map.h:46
int globalPoPsIndexTarget
Definition: MCGIDI_map.h:37
char * schema
Definition: MCGIDI_map.h:32
void * smr_freeMemory(void **p)
enum MCGIDI_mapEntry_type type
Definition: MCGIDI_map.h:30
char * projectile
Definition: MCGIDI_map.h:35
MCGIDI_mapEntry * next
Definition: MCGIDI_map.h:29
MCGIDI_map * map
Definition: MCGIDI_map.h:38

Here is the call graph for this function:

Here is the caller graph for this function:

static int _MCGIDI_map_findAllOfTargetViaPoPIDs2 ( statusMessageReporting smr,
MCGIDI_map mapAllOfTarget,
MCGIDI_map map,
int  projectile_PoPID,
int  target_PoPID 
)
static

Definition at line 404 of file MCGIDI_map.cc.

405  {
406 
407  MCGIDI_mapEntry *entry;
408 
409  for( entry = map->mapEntries; entry != NULL; entry = entry->next ) {
410  switch( entry->type ) {
412  if( ( projectile_PoPID == entry->globalPoPsIndexProjectile ) && ( target_PoPID == entry->globalPoPsIndexTarget ) ) {
413  if( _MCGIDI_map_addEntry( smr, mapAllOfTarget, entry->type, entry->schema, entry->path, entry->evaluation, entry->projectile,
414  entry->targetName ) == NULL ) return( 1 );
415  }
416  break;
418  if( _MCGIDI_map_findAllOfTargetViaPoPIDs2( smr, mapAllOfTarget, entry->map, projectile_PoPID, target_PoPID ) != 0 ) return( 1 );
419  break;
420  default :
421  smr_setReportInfo3( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_UnknownType, "unknown type = %d", entry->type );
422  return( 1 );
423  }
424  }
425  return( 0 );
426 }
char * path
Definition: MCGIDI_map.h:33
int globalPoPsIndexProjectile
Definition: MCGIDI_map.h:37
char * evaluation
Definition: MCGIDI_map.h:34
#define smr_setReportInfo3(smr, userInterface, libraryID, code, fmt,...)
Definition: MCGIDI_map.h:28
char * targetName
Definition: MCGIDI_map.h:36
MCGIDI_mapEntry * mapEntries
Definition: MCGIDI_map.h:47
static MCGIDI_mapEntry * _MCGIDI_map_addEntry(statusMessageReporting *smr, MCGIDI_map *map, enum MCGIDI_mapEntry_type type, const char *schema, const char *path, const char *evaluation, const char *projectile, const char *target)
Definition: MCGIDI_map.cc:237
#define smr_unknownID
int globalPoPsIndexTarget
Definition: MCGIDI_map.h:37
MCGIDI_map_smr smrUserInterface
Definition: MCGIDI_map.h:43
char * schema
Definition: MCGIDI_map.h:32
enum MCGIDI_mapEntry_type type
Definition: MCGIDI_map.h:30
char * projectile
Definition: MCGIDI_map.h:35
static int _MCGIDI_map_findAllOfTargetViaPoPIDs2(statusMessageReporting *smr, MCGIDI_map *mapAllOfTarget, MCGIDI_map *map, int projectile_PoPID, int target_PoPID)
Definition: MCGIDI_map.cc:404
MCGIDI_mapEntry * next
Definition: MCGIDI_map.h:29
MCGIDI_map * map
Definition: MCGIDI_map.h:38

Here is the call graph for this function:

Here is the caller graph for this function:

static char * _MCGIDI_map_findTargetViaPoPIDs2 ( statusMessageReporting smr,
MCGIDI_map map,
const char *  evaluation,
int  projectile_PoPID,
int  target_PoPID 
)
static

Definition at line 329 of file MCGIDI_map.cc.

330  {
331 
332  MCGIDI_mapEntry *entry;
333  char *path = NULL;
334  int n, status;
335 
336  if( evaluation != NULL ) {
337  if( strlen( evaluation ) == 0 ) evaluation = NULL;
338  }
339 
340  for( entry = map->mapEntries; entry != NULL; entry = entry->next ) {
341  switch( entry->type ) {
343  if( ( projectile_PoPID == entry->globalPoPsIndexProjectile ) && ( target_PoPID == entry->globalPoPsIndexTarget ) ) {
344  if( evaluation == NULL ) {
345  status = 1; }
346  else {
347  status = strcmp( evaluation, entry->evaluation ) == 0;
348  }
349  if( status ) {
350  n = (int) strlen( map->path ) + 1 + (int) strlen( entry->path ) + 1;
351  if( ( path = (char * ) smr_malloc2( smr, n, 0, "path" ) ) == NULL ) return( NULL );
352  strcpy( path, map->path );
353  strcat( path, "/" );
354  if( entry->path[0] == '/' ) {
355  strcpy( path, entry->path ); }
356  else {
357  strcat( path, entry->path );
358  }
359  return( path );
360  }
361  }
362  break;
364  if( ( path = _MCGIDI_map_findTargetViaPoPIDs2( smr, entry->map, evaluation, projectile_PoPID, target_PoPID ) ) != NULL ) return( path );
365  break;
366  default :
367  smr_setReportInfo3( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_UnknownType, "unknown type = %d", entry->type );
368  return( NULL );
369  }
370  }
371  return( NULL );
372 }
char * path
Definition: MCGIDI_map.h:33
int globalPoPsIndexProjectile
Definition: MCGIDI_map.h:37
char * evaluation
Definition: MCGIDI_map.h:34
#define smr_setReportInfo3(smr, userInterface, libraryID, code, fmt,...)
Definition: MCGIDI_map.h:28
static char * _MCGIDI_map_findTargetViaPoPIDs2(statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, int projectile_PoPID, int target_PoPID)
Definition: MCGIDI_map.cc:329
char * path
Definition: MCGIDI_map.h:44
MCGIDI_mapEntry * mapEntries
Definition: MCGIDI_map.h:47
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
#define smr_malloc2(smr, size, zero, forItem)
const G4int n
#define smr_unknownID
int globalPoPsIndexTarget
Definition: MCGIDI_map.h:37
MCGIDI_map_smr smrUserInterface
Definition: MCGIDI_map.h:43
enum MCGIDI_mapEntry_type type
Definition: MCGIDI_map.h:30
MCGIDI_mapEntry * next
Definition: MCGIDI_map.h:29
MCGIDI_map * map
Definition: MCGIDI_map.h:38

Here is the call graph for this function:

Here is the caller graph for this function:

static void _MCGIDI_map_simpleWrite2 ( FILE *  f,
MCGIDI_map map,
int  level 
)
static

Definition at line 554 of file MCGIDI_map.cc.

554  {
555 
556  MCGIDI_mapEntry *entry;
557  char sLevel[] = " ";
558  int n = (int ) strlen( sLevel ) / 4;
559 
560  if( map->status != MCGIDI_map_status_Ok ) {
561  fprintf( f, "Bad map status = %d\n", map->status );
562  return;
563  }
564  if( level < n ) sLevel[4 * level] = 0;
565  fprintf( f, "%smap->path = %s\n", sLevel, map->path );
566  fprintf( f, "%smap->mapFileName = %s\n", sLevel, map->mapFileName );
567  for( entry = map->mapEntries; entry != NULL; entry = entry->next ) {
568  switch( entry->type ) {
570  fprintf( f, "%sType = target: schema = %s: evaluation = %s: projectile = %s: target = %s: path = %s\n", sLevel, entry->schema,
571  entry->evaluation, entry->projectile, entry->targetName, entry->path );
572  break;
574  fprintf( f, "%sType = path: path = %s\n", sLevel, entry->path );
575  _MCGIDI_map_simpleWrite2( f, entry->map, level + 1 );
576  break;
577  default :
578  fprintf( f, "%sUnknown type = %d\n", sLevel, entry->type );
579  }
580  }
581 }
char * path
Definition: MCGIDI_map.h:33
char * evaluation
Definition: MCGIDI_map.h:34
Definition: MCGIDI_map.h:28
char * path
Definition: MCGIDI_map.h:44
char * targetName
Definition: MCGIDI_map.h:36
MCGIDI_mapEntry * mapEntries
Definition: MCGIDI_map.h:47
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
char * mapFileName
Definition: MCGIDI_map.h:45
const G4int n
char * schema
Definition: MCGIDI_map.h:32
enum MCGIDI_mapEntry_type type
Definition: MCGIDI_map.h:30
enum MCGIDI_map_status status
Definition: MCGIDI_map.h:42
char * projectile
Definition: MCGIDI_map.h:35
MCGIDI_mapEntry * next
Definition: MCGIDI_map.h:29
MCGIDI_map * map
Definition: MCGIDI_map.h:38
static void _MCGIDI_map_simpleWrite2(FILE *f, MCGIDI_map *map, int level)
Definition: MCGIDI_map.cc:554

Here is the call graph for this function:

Here is the caller graph for this function:

static char * _MCGIDI_map_smrUserInterface ( void userData)
static

Definition at line 585 of file MCGIDI_map.cc.

585  {
586 
587  MCGIDI_map_smr *smrUserInterface = (MCGIDI_map_smr *) userData;
588 
589  return( smr_allocateFormatMessage( "map file = %s", smrUserInterface->map->mapFileName ) );
590 }
#define userData
Definition: xmlparse.cc:572
char * smr_allocateFormatMessage(char const *fmt,...)
char * mapFileName
Definition: MCGIDI_map.h:45
MCGIDI_map * map
Definition: MCGIDI_map.h:25

Here is the call graph for this function:

Here is the caller graph for this function:

static int _MCGIDI_map_walkTree2 ( statusMessageReporting smr,
MCGIDI_map map,
int  level,
int(*)(MCGIDI_mapEntry *entry, int level, void *userData handler,
void userData 
)
static

Definition at line 480 of file MCGIDI_map.cc.

481  {
482 
483  MCGIDI_mapEntry *entry;
484 
485  for( entry = map->mapEntries; entry != NULL; entry = entry->next ) {
486  if( handler( entry, level, userData ) != 0 ) return( 1 );
487  if( entry->type == MCGIDI_mapEntry_type_path ) if( _MCGIDI_map_walkTree2( smr, entry->map, level + 1, handler, userData ) != 0 ) return( 1 );
488  }
489  return( 0 );
490 }
Definition: MCGIDI_map.h:28
#define userData
Definition: xmlparse.cc:572
MCGIDI_mapEntry * mapEntries
Definition: MCGIDI_map.h:47
enum MCGIDI_mapEntry_type type
Definition: MCGIDI_map.h:30
static int _MCGIDI_map_walkTree2(statusMessageReporting *smr, MCGIDI_map *map, int level, int(*handler)(MCGIDI_mapEntry *entry, int level, void *userData), void *userData)
Definition: MCGIDI_map.cc:480
MCGIDI_mapEntry * next
Definition: MCGIDI_map.h:29
MCGIDI_map * map
Definition: MCGIDI_map.h:38

Here is the caller graph for this function:

int MCGIDI_map_addPath ( statusMessageReporting smr,
MCGIDI_map map,
const char *  path 
)

Definition at line 225 of file MCGIDI_map.cc.

225  {
226 
227  MCGIDI_mapEntry *entry = _MCGIDI_map_addEntry( smr, map, MCGIDI_mapEntry_type_path, NULL, path, NULL, NULL, NULL );
228 
229  if( entry != NULL ) {
230  if( ( entry->map = MCGIDI_map_readFile( smr, map->path, entry->path ) ) == NULL ) entry = NULL;
231  }
232  return( entry != NULL );
233 }
char * path
Definition: MCGIDI_map.h:33
Definition: MCGIDI_map.h:28
MCGIDI_map * MCGIDI_map_readFile(statusMessageReporting *smr, const char *basePath, const char *mapFileName)
Definition: MCGIDI_map.cc:93
char * path
Definition: MCGIDI_map.h:44
static MCGIDI_mapEntry * _MCGIDI_map_addEntry(statusMessageReporting *smr, MCGIDI_map *map, enum MCGIDI_mapEntry_type type, const char *schema, const char *path, const char *evaluation, const char *projectile, const char *target)
Definition: MCGIDI_map.cc:237
MCGIDI_map * map
Definition: MCGIDI_map.h:38

Here is the call graph for this function:

Here is the caller graph for this function:

int MCGIDI_map_addTarget ( statusMessageReporting smr,
MCGIDI_map map,
const char *  schema,
const char *  path,
const char *  evaluation,
const char *  projectile,
const char *  target 
)

Definition at line 218 of file MCGIDI_map.cc.

218  {
219 
220  return( _MCGIDI_map_addEntry( smr, map, MCGIDI_mapEntry_type_target, schema, path, evaluation, projectile, target ) != NULL );
221 }
const XML_Char * target
Definition: expat.h:268
static MCGIDI_mapEntry * _MCGIDI_map_addEntry(statusMessageReporting *smr, MCGIDI_map *map, enum MCGIDI_mapEntry_type type, const char *schema, const char *path, const char *evaluation, const char *projectile, const char *target)
Definition: MCGIDI_map.cc:237

Here is the call graph for this function:

Here is the caller graph for this function:

MCGIDI_map* MCGIDI_map_findAllOfTarget ( statusMessageReporting smr,
MCGIDI_map map,
const char *  projectile,
const char *  targetName 
)

Definition at line 430 of file MCGIDI_map.cc.

430  {
431 
432  int projectile_PoPID, target_PoPID;
433 
434  if( ( projectile_PoPID = lPoPs_addParticleIfNeeded( smr, projectile, "LLNL" ) ) < 0 ) return( NULL );
435  if( ( target_PoPID = lPoPs_addParticleIfNeeded( smr, targetName, "LLNL" ) ) < 0 ) return( NULL );
436  return( MCGIDI_map_findAllOfTargetViaPoPIDs( smr, map, projectile_PoPID, target_PoPID ) );
437 }
int lPoPs_addParticleIfNeeded(statusMessageReporting *smr, char const *name, char const *special)
Definition: lPoPs.cc:36
MCGIDI_map * MCGIDI_map_findAllOfTargetViaPoPIDs(statusMessageReporting *smr, MCGIDI_map *map, int projectile_PoPID, int target_PoPID)
Definition: MCGIDI_map.cc:387

Here is the call graph for this function:

Here is the caller graph for this function:

MCGIDI_map* MCGIDI_map_findAllOfTargetViaPoPIDs ( statusMessageReporting smr,
MCGIDI_map map,
int  projectile_PoPID,
int  target_PoPID 
)

Definition at line 387 of file MCGIDI_map.cc.

388  {
389 /*
390 * Calling routine must free returned pointer.
391 */
392  int status;
393  MCGIDI_map *mapAllOfTarget;
394 
395  if( map->status != MCGIDI_map_status_Ok ) return( NULL );
396  if( ( mapAllOfTarget = MCGIDI_map_new( smr ) ) == NULL ) return( NULL );
397  status = _MCGIDI_map_findAllOfTargetViaPoPIDs2( smr, mapAllOfTarget, map, projectile_PoPID, target_PoPID );
398  if( ( status != 0 ) ) mapAllOfTarget = (MCGIDI_map *) MCGIDI_map_free( smr, mapAllOfTarget );
399  return( mapAllOfTarget );
400 }
MCGIDI_map * MCGIDI_map_new(statusMessageReporting *smr)
Definition: MCGIDI_map.cc:49
void * MCGIDI_map_free(statusMessageReporting *smr, MCGIDI_map *map)
Definition: MCGIDI_map.cc:173
enum MCGIDI_map_status status
Definition: MCGIDI_map.h:42
static int _MCGIDI_map_findAllOfTargetViaPoPIDs2(statusMessageReporting *smr, MCGIDI_map *mapAllOfTarget, MCGIDI_map *map, int projectile_PoPID, int target_PoPID)
Definition: MCGIDI_map.cc:404

Here is the call graph for this function:

Here is the caller graph for this function:

char* MCGIDI_map_findTarget ( statusMessageReporting smr,
MCGIDI_map map,
const char *  evaluation,
const char *  projectile,
const char *  targetName 
)

Definition at line 376 of file MCGIDI_map.cc.

376  {
377 
378  int projectile_PoPID, target_PoPID;
379 
380  if( ( projectile_PoPID = lPoPs_addParticleIfNeeded( smr, projectile, "LLNL" ) ) < 0 ) return( NULL );
381  if( ( target_PoPID = lPoPs_addParticleIfNeeded( smr, targetName, "LLNL" ) ) < 0 ) return( NULL );
382  return( MCGIDI_map_findTargetViaPoPIDs( smr, map, evaluation, projectile_PoPID, target_PoPID ) );
383 }
int lPoPs_addParticleIfNeeded(statusMessageReporting *smr, char const *name, char const *special)
Definition: lPoPs.cc:36
char * MCGIDI_map_findTargetViaPoPIDs(statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, int projectile_PoPID, int target_PoPID)
Definition: MCGIDI_map.cc:302

Here is the call graph for this function:

Here is the caller graph for this function:

char* MCGIDI_map_findTargetViaPoPIDs ( statusMessageReporting smr,
MCGIDI_map map,
const char *  evaluation,
int  projectile_PoPID,
int  target_PoPID 
)

Definition at line 302 of file MCGIDI_map.cc.

303  {
304 /*
305 * Calling routine must free returned pointer.
306 */
307  char *path;
308  char const *projectileName = PoPs_getName_atIndex( smr, projectile_PoPID );
309  char const *targetName = PoPs_getName_atIndex( smr, target_PoPID );
310 
311  if( !smr_isOk( smr ) ) return( NULL );
312  if( map->status != MCGIDI_map_status_Ok ) return( NULL );
313 
314  path = _MCGIDI_map_findTargetViaPoPIDs2( smr, map, evaluation, projectile_PoPID, target_PoPID );
315  if( ( path == NULL ) && smr_isOk( smr ) ) {
316  if( evaluation == NULL ) {
317  smr_setReportInfo3( smr, &(map->smrUserInterface), smr_unknownID, 1, "target %s for projectile %s not found",
318  targetName, projectileName ); }
319  else {
320  smr_setReportInfo3( smr, &(map->smrUserInterface), smr_unknownID, 1, "target %s for projectile %s and evaluation %s not found",
321  targetName, projectileName, evaluation );
322  }
323  }
324  return( path );
325 }
char const * PoPs_getName_atIndex(statusMessageReporting *smr, int index)
Definition: PoPs.cc:275
#define smr_setReportInfo3(smr, userInterface, libraryID, code, fmt,...)
static char * _MCGIDI_map_findTargetViaPoPIDs2(statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, int projectile_PoPID, int target_PoPID)
Definition: MCGIDI_map.cc:329
#define smr_unknownID
int smr_isOk(statusMessageReporting *smr)
MCGIDI_map_smr smrUserInterface
Definition: MCGIDI_map.h:43
enum MCGIDI_map_status status
Definition: MCGIDI_map.h:42

Here is the call graph for this function:

Here is the caller graph for this function:

void* MCGIDI_map_free ( statusMessageReporting smr,
MCGIDI_map map 
)

Definition at line 173 of file MCGIDI_map.cc.

173  {
174 
175  MCGIDI_map_release( smr, map );
176  smr_freeMemory( (void **) &map );
177  return( NULL );
178 }
void MCGIDI_map_release(statusMessageReporting *smr, MCGIDI_map *map)
Definition: MCGIDI_map.cc:182
void * smr_freeMemory(void **p)

Here is the call graph for this function:

Here is the caller graph for this function:

MCGIDI_mapEntry* MCGIDI_map_getFirstEntry ( MCGIDI_map map)

Definition at line 204 of file MCGIDI_map.cc.

204  {
205 
206  return( map->mapEntries );
207 }
MCGIDI_mapEntry * mapEntries
Definition: MCGIDI_map.h:47

Here is the caller graph for this function:

char* MCGIDI_map_getFullPath ( statusMessageReporting smr,
MCGIDI_map map,
const char *  endPath 
)

Definition at line 441 of file MCGIDI_map.cc.

441  {
442 
443  char *path;
444 
445  if( endPath[0] == '/' ) {
446  if( ( path = (char *) smr_malloc2( smr, strlen( endPath ) + 1, 0, "path" ) ) == NULL ) return( NULL );
447  path[0] = 0; }
448  else {
449  if( ( path = (char *) smr_malloc2( smr, strlen( map->path ) + strlen( endPath ) + 2, 0, "path" ) ) == NULL ) return( NULL );
450  strcpy( path, map->path );
451  strcat( path, "/" );
452  }
453  strcat( path, endPath );
454  return( path );
455 }
char * path
Definition: MCGIDI_map.h:44
#define smr_malloc2(smr, size, zero, forItem)

Here is the caller graph for this function:

MCGIDI_mapEntry* MCGIDI_map_getNextEntry ( MCGIDI_mapEntry entry)

Definition at line 211 of file MCGIDI_map.cc.

211  {
212 
213  return( entry->next );
214 }
MCGIDI_mapEntry * next
Definition: MCGIDI_map.h:29

Here is the caller graph for this function:

char* MCGIDI_map_getTargetsFullPath ( statusMessageReporting smr,
MCGIDI_mapEntry target 
)

Definition at line 459 of file MCGIDI_map.cc.

459  {
460 
461  char *path = NULL;
462  MCGIDI_map *map = target->parent;
463 
464  switch( target->type ) {
466  path = MCGIDI_map_getFullPath( smr, map, target->path );
467  break;
469  smr_setReportInfo3p( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_UnknownType, "path type not allowed" );
470  break;
471  default :
472  smr_setReportInfo3( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_UnknownType, "unknown type = %d", target->type );
473  break;
474  }
475  return( path );
476 }
MCGIDI_map * parent
Definition: MCGIDI_map.h:31
char * path
Definition: MCGIDI_map.h:33
#define smr_setReportInfo3(smr, userInterface, libraryID, code, fmt,...)
#define smr_setReportInfo3p(smr, userInterface, libraryID, code, fmt)
char * MCGIDI_map_getFullPath(statusMessageReporting *smr, MCGIDI_map *map, const char *endPath)
Definition: MCGIDI_map.cc:441
#define smr_unknownID
MCGIDI_map_smr smrUserInterface
Definition: MCGIDI_map.h:43
enum MCGIDI_mapEntry_type type
Definition: MCGIDI_map.h:30

Here is the call graph for this function:

int MCGIDI_map_initialize ( statusMessageReporting smr,
MCGIDI_map map 
)

Definition at line 60 of file MCGIDI_map.cc.

60  {
61 
62  memset( map, 0, sizeof( MCGIDI_map ) );
65  map->smrUserInterface.map = map;
66  map->path = NULL;
67  map->mapFileName = NULL;
68  map->numberOfEntries = 0;
69  map->mapEntries = NULL;
70 
71 /*
72 * Add some default aliases. This is a kludge until aliases are fully supported.
73 */
74 if( aliasesNeeded ) { /* Support all meta-stables in ENDF/B-VII.1 */
75  char const *aliases[] = { "Co58m1", "Ag110m1", "Cd115m1", "Te127m1", "Te129m1", "Pm148m1", "Ho166m1", "Am242m1", "Am244m1", "Es254m1" };
76  char const *targets[] = { "Co58_e1", "Ag110_e2", "Cd115_e1", "Te127_e2", "Te129_e1", "Pm148_e2", "Ho166_e1", "Am242_e2", "Am244_e1", "Es254_e2" };
77  int i1, n1 = sizeof( aliases ) / sizeof( aliases[1] );
78 
79 
80  for( i1 = 0; i1 < n1; i1++ ) {
81  lPoPs_addParticleIfNeeded( smr, targets[i1], NULL );
82  if( !smr_isOk( smr ) ) return( 1 );
83  PoPs_addAliasIfNeeded( smr, targets[i1], aliases[i1] );
84  if( !smr_isOk( smr ) ) return( 1 );
85  }
86  aliasesNeeded = 0;
87 }
88  return( 0 );
89 }
static char * _MCGIDI_map_smrUserInterface(void *userData)
Definition: MCGIDI_map.cc:585
static int aliasesNeeded
Definition: MCGIDI_map.cc:20
smr_userInterface smrUserInterface
Definition: MCGIDI_map.h:24
int lPoPs_addParticleIfNeeded(statusMessageReporting *smr, char const *name, char const *special)
Definition: lPoPs.cc:36
char * path
Definition: MCGIDI_map.h:44
MCGIDI_mapEntry * mapEntries
Definition: MCGIDI_map.h:47
PoP * PoPs_addAliasIfNeeded(statusMessageReporting *smr, char const *name, char const *alias)
Definition: PoPs.cc:179
char * mapFileName
Definition: MCGIDI_map.h:45
int numberOfEntries
Definition: MCGIDI_map.h:46
int smr_isOk(statusMessageReporting *smr)
MCGIDI_map_smr smrUserInterface
Definition: MCGIDI_map.h:43
enum MCGIDI_map_status status
Definition: MCGIDI_map.h:42
MCGIDI_map * map
Definition: MCGIDI_map.h:25

Here is the call graph for this function:

Here is the caller graph for this function:

MCGIDI_map* MCGIDI_map_new ( statusMessageReporting smr)

Definition at line 49 of file MCGIDI_map.cc.

49  {
50 
51  MCGIDI_map *map;
52 
53  if( ( map = (MCGIDI_map *) smr_malloc2( smr, sizeof( MCGIDI_map ), 0, "map" ) ) == NULL ) return( NULL );
54  if( MCGIDI_map_initialize( smr, map ) ) map = (MCGIDI_map *) MCGIDI_map_free( NULL, map );
55  return( map );
56 }
void * MCGIDI_map_free(statusMessageReporting *smr, MCGIDI_map *map)
Definition: MCGIDI_map.cc:173
#define smr_malloc2(smr, size, zero, forItem)
int MCGIDI_map_initialize(statusMessageReporting *smr, MCGIDI_map *map)
Definition: MCGIDI_map.cc:60

Here is the call graph for this function:

Here is the caller graph for this function:

MCGIDI_map* MCGIDI_map_readFile ( statusMessageReporting smr,
const char *  basePath,
const char *  mapFileName 
)

Definition at line 93 of file MCGIDI_map.cc.

93  {
94 /*
95 * If an error occurrs, map is freed and NULL is returned.
96 */
97  int n = 0;
98  xDataXML_document *doc;
99  xDataXML_element *element;
100  xDataXML_element *child;
101  MCGIDI_map *map;
102  const char *evaluation, *projectile, *targetName, *path, *schema;
103  char realPath[2 * ( PATH_MAX + 1 )], *p = &(realPath[PATH_MAX+1]);
104 
105  if( ( map = MCGIDI_map_new( smr ) ) == NULL ) return( NULL );
106 
107  if( ( basePath == NULL ) || ( mapFileName[0] == '/' ) ) {
108  strcpy( realPath, mapFileName ); }
109  else {
110  strcpy( realPath, basePath );
111  strcat( realPath, "/" );
112  strcat( realPath, mapFileName );
113  }
114  if( realpath( realPath, p ) == NULL ) {
115  smr_setReportError2( smr, smr_unknownID, MCGIDI_map_status_mapParsing, "No map file %s\n", mapFileName );
116  return( (MCGIDI_map *) MCGIDI_map_free( NULL, map ) );
117  }
118  n = (int) strlen( p ) + 2;
119  if( ( map->path = (char *) smr_malloc2( smr, 2 * n, 0, "map->path" ) ) == NULL ) return( (MCGIDI_map *) MCGIDI_map_free( NULL, map ) );
120  map->mapFileName = &(map->path[n + 1]);
121  strcpy( map->mapFileName, p );
122  strcpy( map->path, p );
123  if( ( p = strrchr( map->path, '/' ) ) != NULL ) {
124  *p = 0; }
125  else {
126  strcpy( map->path, "." );
127  }
128 
129  if( ( doc = xDataXML_importFile2( smr, map->mapFileName ) ) == NULL ) return( (MCGIDI_map *) MCGIDI_map_free( NULL, map ) );
130 
131  element = xDataXML_getDocumentsElement( doc );
132  for( child = xDataXML_getFirstElement( element ); child != NULL; child = xDataXML_getNextElement( child ) ) {
133  if( strcmp( child->name, "path" ) == 0 ) {
134  if( ( path = xDataXML_getAttributesValueInElement( child , "path" ) ) == NULL ) {
135  smr_setReportError3p( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_mapParsing, "path missing path attribute" );
136  break;
137  }
138  MCGIDI_map_addPath( smr, map, path ); }
139  else if( strcmp( child->name, "target" ) == 0 ) {
140  if( ( schema = xDataXML_getAttributesValueInElement( child , "schema" ) ) == NULL ) {
141  smr_setReportError3p( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_mapParsing, "target missing 'schema' attribute" );
142  break;
143  }
144  if( ( path = xDataXML_getAttributesValueInElement( child , "path" ) ) == NULL ) {
145  smr_setReportError3p( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_mapParsing, "target missing 'path' attribute" );
146  break;
147  }
148  if( ( evaluation = xDataXML_getAttributesValueInElement( child , "evaluation" ) ) == NULL ) {
149  smr_setReportError3p( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_mapParsing, "target missing 'evaluation' attribute" );
150  break;
151  }
152  if( ( projectile = xDataXML_getAttributesValueInElement( child , "projectile" ) ) == NULL ) {
153  smr_setReportError3p( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_mapParsing, "target missing 'projectile' attribute" );
154  break;
155  }
156  if( ( targetName = xDataXML_getAttributesValueInElement( child , "target" ) ) == NULL ) {
157  smr_setReportError3p( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_mapParsing, "target missing 'target' attribute" );
158  break;
159  }
160  MCGIDI_map_addTarget( smr, map, schema, path, evaluation, projectile, targetName ); }
161  else {
162  smr_setReportError3( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_mapParsing, "invalid element = %s", child->name );
163  }
164  if( !smr_isOk( smr ) ) break;
165  }
166  xDataXML_freeDoc( smr, doc );
167  if( !smr_isOk( smr ) ) map = (MCGIDI_map *) MCGIDI_map_free( NULL, map );
168  return( map );
169 }
MCGIDI_map * MCGIDI_map_new(statusMessageReporting *smr)
Definition: MCGIDI_map.cc:49
const char * p
Definition: xmltok.h:285
xDataXML_document * xDataXML_importFile2(statusMessageReporting *smr, char const *fileName)
#define PATH_MAX
Definition: MCGIDI_map.cc:12
#define smr_setReportError3p(smr, userInterface, libraryID, code, fmt)
int MCGIDI_map_addPath(statusMessageReporting *smr, MCGIDI_map *map, const char *path)
Definition: MCGIDI_map.cc:225
void * MCGIDI_map_free(statusMessageReporting *smr, MCGIDI_map *map)
Definition: MCGIDI_map.cc:173
char * path
Definition: MCGIDI_map.h:44
xDataXML_element * xDataXML_getDocumentsElement(xDataXML_document *doc)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
void * xDataXML_freeDoc(statusMessageReporting *smr, xDataXML_document *doc)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
#define smr_malloc2(smr, size, zero, forItem)
char * mapFileName
Definition: MCGIDI_map.h:45
xDataXML_element * xDataXML_getNextElement(xDataXML_element *element)
const G4int n
#define smr_unknownID
int smr_isOk(statusMessageReporting *smr)
int MCGIDI_map_addTarget(statusMessageReporting *smr, MCGIDI_map *map, const char *method, const char *path, const char *evaluation, const char *projectile, const char *targetName)
Definition: MCGIDI_map.cc:218
MCGIDI_map_smr smrUserInterface
Definition: MCGIDI_map.h:43
char const * xDataXML_getAttributesValueInElement(xDataXML_element *element, char const *name)
#define smr_setReportError3(smr, userInterface, libraryID, code, fmt,...)
xDataXML_element * xDataXML_getFirstElement(xDataXML_element *element)

Here is the call graph for this function:

Here is the caller graph for this function:

void MCGIDI_map_release ( statusMessageReporting smr,
MCGIDI_map map 
)

Definition at line 182 of file MCGIDI_map.cc.

182  {
183 
184  MCGIDI_mapEntry *entry, *next;
185 
186  if( map->path != NULL ) smr_freeMemory( (void **) &(map->path) );
187  for( entry = map->mapEntries; entry != NULL; entry = next ) {
188  next = entry->next;
189  if( entry->schema != NULL ) smr_freeMemory( (void **) &(entry->schema) );
190  if( entry->path != NULL ) smr_freeMemory( (void **) &(entry->path) );
191  if( entry->evaluation != NULL ) smr_freeMemory( (void **) &(entry->evaluation) );
192  if( entry->projectile != NULL ) smr_freeMemory( (void **) &(entry->projectile) );
193  if( entry->targetName != NULL ) smr_freeMemory( (void **) &(entry->targetName) );
194  if( entry->map != NULL ) MCGIDI_map_free( smr, entry->map );
195  smr_freeMemory( (void **) &entry );
196  }
197  map->numberOfEntries = 0;
198  map->mapEntries = NULL;
200 }
char * path
Definition: MCGIDI_map.h:33
char * evaluation
Definition: MCGIDI_map.h:34
Definition: MCGIDI_map.h:28
void * MCGIDI_map_free(statusMessageReporting *smr, MCGIDI_map *map)
Definition: MCGIDI_map.cc:173
char * path
Definition: MCGIDI_map.h:44
char * targetName
Definition: MCGIDI_map.h:36
MCGIDI_mapEntry * mapEntries
Definition: MCGIDI_map.h:47
int numberOfEntries
Definition: MCGIDI_map.h:46
char * schema
Definition: MCGIDI_map.h:32
void * smr_freeMemory(void **p)
enum MCGIDI_map_status status
Definition: MCGIDI_map.h:42
char * projectile
Definition: MCGIDI_map.h:35
MCGIDI_mapEntry * next
Definition: MCGIDI_map.h:29
MCGIDI_map * map
Definition: MCGIDI_map.h:38

Here is the call graph for this function:

Here is the caller graph for this function:

void MCGIDI_map_simpleWrite ( FILE *  f,
MCGIDI_map map 
)

Definition at line 550 of file MCGIDI_map.cc.

550 { _MCGIDI_map_simpleWrite2( f, map, 0 ); }
static void _MCGIDI_map_simpleWrite2(FILE *f, MCGIDI_map *map, int level)
Definition: MCGIDI_map.cc:554

Here is the call graph for this function:

char* MCGIDI_map_toXMLString ( statusMessageReporting smr,
MCGIDI_map map 
)

Definition at line 501 of file MCGIDI_map.cc.

501  {
502 
503  MCGIDI_mapEntry *entry;
504  char *s, *p;
505  char targetFormat[] = "<target schema=\"%s\" evaluation=\"%s\" projectile=\"%s\" target=\"%s\" path=\"%s\"/>\n";
506  char pathFormat[] = "<path projectile=\"%s\" path=\"%s\"/>\n";
507  char start[] = "<map>\n";
508  char end[] = "</map>";
509  int n = 0, nStart = (int) strlen( start ), nEnd = (int) strlen( end );
510  int nTarget = (int) strlen( targetFormat ) - 10, nPath = (int) strlen( pathFormat ) - 4;
511 
512  if( map->status != MCGIDI_map_status_Ok ) return( NULL );
513 
514  n = nStart + nEnd + 1;
515  for( entry = map->mapEntries; entry != NULL; entry = entry->next ) {
516  switch( entry->type ) {
518  n += (int) ( strlen( entry->schema ) + strlen( entry->path ) + strlen( entry->evaluation ) + strlen( entry->projectile ) + strlen( entry->targetName ) + nTarget );
519  break;
521  n += (int ) strlen( entry->path ) + (int ) strlen( entry->projectile ) + nPath;
522  break;
523  default :
524  smr_setReportInfo3( smr, &(map->smrUserInterface), smr_unknownID, MCGIDI_map_status_UnknownType, "unknown type = %d", entry->type );
525  return( NULL );
526  }
527  }
528 
529  if( ( s = (char *) smr_malloc2( smr, n, 0, "xml string" ) ) == NULL ) return( NULL );
530  p = s;
531  strcpy( p, start );
532  while( *p ) p++; // Loop checking, 11.06.2015, T. Koi
533  for( entry = map->mapEntries; entry != NULL; entry = entry->next ) {
534  switch( entry->type ) {
536  sprintf( p, targetFormat, entry->schema, entry->evaluation, entry->projectile, entry->targetName, entry->path );
537  break;
539  sprintf( p, pathFormat, entry->projectile, entry->path );
540  break;
541  }
542  while( *p ) p++; // Loop checking, 11.06.2015, T. Koi
543  }
544  strcpy( p, end );
545  return( s );
546 }
char * path
Definition: MCGIDI_map.h:33
char * evaluation
Definition: MCGIDI_map.h:34
const char * p
Definition: xmltok.h:285
#define smr_setReportInfo3(smr, userInterface, libraryID, code, fmt,...)
Definition: MCGIDI_map.h:28
char * targetName
Definition: MCGIDI_map.h:36
const XML_Char * s
Definition: expat.h:262
MCGIDI_mapEntry * mapEntries
Definition: MCGIDI_map.h:47
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
#define smr_malloc2(smr, size, zero, forItem)
const G4int n
#define smr_unknownID
MCGIDI_map_smr smrUserInterface
Definition: MCGIDI_map.h:43
char * schema
Definition: MCGIDI_map.h:32
enum MCGIDI_mapEntry_type type
Definition: MCGIDI_map.h:30
enum MCGIDI_map_status status
Definition: MCGIDI_map.h:42
char * projectile
Definition: MCGIDI_map.h:35
MCGIDI_mapEntry * next
Definition: MCGIDI_map.h:29

Here is the call graph for this function:

int MCGIDI_map_walkTree ( statusMessageReporting smr,
MCGIDI_map map,
int(*)(MCGIDI_mapEntry *entry, int level, void *userData handler,
void userData 
)

Definition at line 494 of file MCGIDI_map.cc.

494  {
495 
496  return( _MCGIDI_map_walkTree2( smr, map, 0, handler, userData ) );
497 }
#define userData
Definition: xmlparse.cc:572
static int _MCGIDI_map_walkTree2(statusMessageReporting *smr, MCGIDI_map *map, int level, int(*handler)(MCGIDI_mapEntry *entry, int level, void *userData), void *userData)
Definition: MCGIDI_map.cc:480

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int aliasesNeeded = 1
static

Definition at line 20 of file MCGIDI_map.cc.