Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPs_private.h File Reference

Go to the source code of this file.

Classes

struct  unitsDB_s
 
struct  PoPs_s
 

Typedefs

typedef struct unitsDB_s unitsDB
 
typedef struct PoPs_s PoPs
 

Functions

int PoPs_releasePrivate (statusMessageReporting *smr)
 
char const * unitsDB_addUnitIfNeeded (statusMessageReporting *smr, char const *unit)
 
int unitsDB_index (statusMessageReporting *smr, char const *unit)
 
char const * unitsDB_stringFromIndex (statusMessageReporting *smr, int index)
 

Typedef Documentation

◆ PoPs

typedef struct PoPs_s PoPs

Definition at line 15 of file PoPs_private.h.

◆ unitsDB

typedef struct unitsDB_s unitsDB

Definition at line 14 of file PoPs_private.h.

Function Documentation

◆ PoPs_releasePrivate()

int PoPs_releasePrivate ( statusMessageReporting smr)

Definition at line 98 of file PoPs.cc.

98 {
99
100 int i;
101
102 for( i = 0; i < popsRoot.numberOfParticles; i++ ) PoP_free( popsRoot.pops[i] );
103 smr_freeMemory( (void **) &(popsRoot.pops) );
104 popsRoot.sorted = NULL;
105 popsRoot.numberOfParticles = 0;
106 popsRoot.allocated = 0;
107 unitsDB_release( );
108 return( 0 );
109}
PoP * PoP_free(PoP *pop)
Definition: PoPs.cc:558
void * smr_freeMemory(void **p)
int allocated
Definition: PoPs_private.h:25
PoP ** pops
Definition: PoPs_private.h:26
int numberOfParticles
Definition: PoPs_private.h:24
PoP ** sorted
Definition: PoPs_private.h:27

Referenced by PoPs_release().

◆ unitsDB_addUnitIfNeeded()

char const * unitsDB_addUnitIfNeeded ( statusMessageReporting smr,
char const *  unit 
)

Definition at line 700 of file PoPs.cc.

700 {
701
702 int i;
703
704 for( i = 0; i < unitsRoot.numberOfUnits; i++ ) {
705 if( strcmp( unit, unitsRoot.unsorted[i] ) == 0 ) return( unitsRoot.unsorted[i] );
706 }
707 if( unitsRoot.numberOfUnits == unitsRoot.allocated ) {
708 int size = unitsRoot.allocated + 20;
709 char const **unsorted = (char const **) smr_malloc2( smr, size * sizeof( char * ), 0, "unsorted" );
710
711 if( unsorted == NULL ) return( NULL );
712 for( i = 0; i < unitsRoot.numberOfUnits; i++ ) unsorted[i] = unitsRoot.unsorted[i];
713 smr_freeMemory( (void **) &(unitsRoot.unsorted) );
714 unitsRoot.unsorted = unsorted;
715 unitsRoot.allocated = size;
716 }
717 if( ( unitsRoot.unsorted[unitsRoot.numberOfUnits] = smr_allocateCopyString2( smr, unit, "unitsRoot.unsorted[unitsRoot.numberOfUnits]" ) ) == NULL )
718 return( NULL );
719 unitsRoot.numberOfUnits++;
720 return( unitsRoot.unsorted[unitsRoot.numberOfUnits - 1] );
721}
#define smr_allocateCopyString2(smr, s, forItem)
#define smr_malloc2(smr, size, zero, forItem)
int allocated
Definition: PoPs_private.h:19
int numberOfUnits
Definition: PoPs_private.h:18
char const ** unsorted
Definition: PoPs_private.h:20

Referenced by PoP_makeParticle(), and PoPs_particleLoadInfo().

◆ unitsDB_index()

int unitsDB_index ( statusMessageReporting smr,
char const *  unit 
)

Definition at line 725 of file PoPs.cc.

725 {
726
727 int i;
728
729 for( i = 0; i < unitsRoot.numberOfUnits; i++ ) {
730 if( !strcmp( unit, unitsRoot.unsorted[i] ) ) return( i );
731 }
732 return( -1 );
733}

◆ unitsDB_stringFromIndex()

char const * unitsDB_stringFromIndex ( statusMessageReporting smr,
int  index 
)

Definition at line 737 of file PoPs.cc.

737 {
738
739 if( ( index < 0 ) || ( index >= unitsRoot.numberOfUnits ) ) {
740 smr_setReportError2( smr, PoPs_smr_ID, 1, "index = %d out of baounds [0 to %d)", index, unitsRoot.numberOfUnits );
741 return( NULL );
742 }
743 return( unitsRoot.unsorted[index] );
744}
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)