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

Go to the source code of this file.

Functions

tpi_channelIDtpi_channelID_allocate (statusMessageReporting *smr)
 
int tpi_channelID_initialize (statusMessageReporting *, tpi_channelID *channelID)
 
void * tpi_channelID_free (statusMessageReporting *smr, tpi_channelID *channelID)
 
int tpi_channelID_release (statusMessageReporting *smr, tpi_channelID *channelID)
 
tpi_channelIDtpi_channelID_parse (statusMessageReporting *smr, char const *str, char **EOP)
 
int tpi_channelID_toString (statusMessageReporting *smr, tpi_channelID *channelID, gString *gStr)
 
int tpi_channelID_toStringSanRevision (statusMessageReporting *smr, tpi_channelID *channelID, gString *gStr)
 
int tpi_channelID_toStringSans (statusMessageReporting *smr, tpi_channelID *channelID, gString *gStr, char *sans[])
 
tpi_spectralIDtpi_spectralID_allocate (statusMessageReporting *smr)
 
int tpi_spectralID_initialize (statusMessageReporting *, tpi_spectralID *spectralID)
 
void * tpi_spectralID_free (statusMessageReporting *smr, tpi_spectralID *spectralID)
 
int tpi_spectralID_release (statusMessageReporting *smr, tpi_spectralID *spectralID)
 
tpi_spectralIDtpi_spectralID_parse (statusMessageReporting *smr, char const *str, char **EOP)
 
int tpi_spectralID_toString (statusMessageReporting *smr, tpi_spectralID *spectralID, gString *gStr)
 
int tpi_spectralID_toStringSanRevision (statusMessageReporting *smr, tpi_spectralID *spectralID, gString *gStr)
 
int tpi_spectralID_toStringSans (statusMessageReporting *smr, tpi_spectralID *spectralID, gString *gStr, char *sans[])
 
char consttpi_misc_firstNonWhiteSpace (statusMessageReporting *, char const *str)
 
char * tpi_misc_allocateAndCopyNCharacters (statusMessageReporting *smr, char const *str, int n)
 

Function Documentation

◆ tpi_channelID_allocate()

tpi_channelID * tpi_channelID_allocate ( statusMessageReporting smr)

Definition at line 53 of file tpi_IDs.cc.

53 {
54
56
57 //if( ( channelID = xData_malloc2( smr, sizeof( tpi_channelID ), 0, "channelID" ) ) == NULL ) return( NULL );
58 if( ( channelID = (tpi_channelID*) xData_malloc2( smr, sizeof( tpi_channelID ), 0, "channelID" ) ) == NULL ) return( NULL );
60 return( channelID );
61}
struct channelID_s channelID
int tpi_channelID_initialize(statusMessageReporting *, tpi_channelID *channelID)
Definition: tpi_IDs.cc:66
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313

◆ tpi_channelID_free()

void * tpi_channelID_free ( statusMessageReporting smr,
tpi_channelID channelID 
)

Definition at line 74 of file tpi_IDs.cc.

74 {
75
76 if( channelID != NULL ) {
78 xData_free( smr, channelID );
79 }
80 return( NULL );
81}
int tpi_channelID_release(statusMessageReporting *smr, tpi_channelID *channelID)
Definition: tpi_IDs.cc:85
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89

Referenced by tpi_spectralID_release().

◆ tpi_channelID_initialize()

int tpi_channelID_initialize ( statusMessageReporting smr,
tpi_channelID channelID 
)

Definition at line 66 of file tpi_IDs.cc.

66 {
67
68 memset( channelID, 0, sizeof( tpi_channelID ) );
69 return( 0 );
70}

Referenced by tpi_channelID_allocate(), and tpi_channelID_release().

◆ tpi_channelID_parse()

tpi_channelID * tpi_channelID_parse ( statusMessageReporting smr,
char const str,
char **  EOP 
)

Definition at line 99 of file tpi_IDs.cc.

99 {
100
101 return( _tpi_channelID_parse2( smr, str, str, 0, EOP ) );
102}

◆ tpi_channelID_release()

int tpi_channelID_release ( statusMessageReporting smr,
tpi_channelID channelID 
)

Definition at line 85 of file tpi_IDs.cc.

85 {
86
87 tpi_spectralID *spectralID, *next;
88
89 for( spectralID = channelID->spectralIDs; spectralID != NULL; spectralID = next ) {
90 next = spectralID->next;
91 tpi_spectralID_free( smr, spectralID );
92 }
94 return( 0 );
95}
tpi_spectralID * next
Definition: tpi_IDs.h:62
void * tpi_spectralID_free(statusMessageReporting *smr, tpi_spectralID *spectralID)
Definition: tpi_IDs.cc:191

Referenced by tpi_channelID_free().

◆ tpi_channelID_toString()

int tpi_channelID_toString ( statusMessageReporting smr,
tpi_channelID channelID,
gString gStr 
)

Definition at line 138 of file tpi_IDs.cc.

138 {
139
140 return( tpi_channelID_toStringSans( smr, channelID, gStr, NULL ) );
141}
int tpi_channelID_toStringSans(statusMessageReporting *smr, tpi_channelID *channelID, gString *gStr, char *sans[])
Definition: tpi_IDs.cc:155

◆ tpi_channelID_toStringSanRevision()

int tpi_channelID_toStringSanRevision ( statusMessageReporting smr,
tpi_channelID channelID,
gString gStr 
)

Definition at line 145 of file tpi_IDs.cc.

145 {
146
147 //char *sans[] = { "revision", NULL };
148 char *sans[] = { (char*)"revision", NULL };
149
150 return( tpi_channelID_toStringSans( smr, channelID, gStr, sans ) );
151}

◆ tpi_channelID_toStringSans()

int tpi_channelID_toStringSans ( statusMessageReporting smr,
tpi_channelID channelID,
gString gStr,
char *  sans[] 
)

Definition at line 155 of file tpi_IDs.cc.

155 {
156
157 tpi_spectralID *spectralID;
158
159 for( spectralID = channelID->spectralIDs; spectralID != NULL; spectralID = spectralID->next ) {
160 if( ( tpi_spectralID_toStringSans( smr, spectralID, gStr, sans ) ) != 0 ) return( 1 );
161 if( spectralID->next != NULL ) {
162 if( ( gString_addTo( smr, gStr, " + " ) ) != 0 ) return( 1 );
163 }
164 }
165 return( 0 );
166}
int gString_addTo(statusMessageReporting *smr, gString *gStr, char const *str)
Definition: gString.cc:90
int tpi_spectralID_toStringSans(statusMessageReporting *smr, tpi_spectralID *spectralID, gString *gStr, char *sans[])
Definition: tpi_IDs.cc:371

Referenced by tpi_channelID_toString(), tpi_channelID_toStringSanRevision(), and tpi_spectralID_toStringSans().

◆ tpi_misc_allocateAndCopyNCharacters()

char * tpi_misc_allocateAndCopyNCharacters ( statusMessageReporting smr,
char const str,
int  n 
)

Definition at line 429 of file tpi_IDs.cc.

429 {
430
431 char *s;
432
433 //if( ( s = xData_malloc2( smr, n + 1, 0, "s" ) ) == NULL ) return( NULL );
434 if( ( s = (char*) xData_malloc2( smr, n + 1, 0, "s" ) ) == NULL ) return( NULL );
435 strncpy( s, str, n );
436 s[n] = 0;
437 return( s );
438}

◆ tpi_misc_firstNonWhiteSpace()

char const * tpi_misc_firstNonWhiteSpace ( statusMessageReporting smr,
char const str 
)

Definition at line 419 of file tpi_IDs.cc.

419 {
420
421 char const *s;
422
423 for( s = str; ( *s != 0 ) && isspace( *s ); s++ ) ;
424 return( s );
425}

◆ tpi_spectralID_allocate()

tpi_spectralID * tpi_spectralID_allocate ( statusMessageReporting smr)

Definition at line 170 of file tpi_IDs.cc.

170 {
171
172 tpi_spectralID *spectralID;
173
174 //if( ( spectralID = xData_malloc2( smr, sizeof( tpi_spectralID ), 1, "spectralID" ) ) == NULL ) return( NULL );
175 if( ( spectralID = (tpi_spectralID*) xData_malloc2( smr, sizeof( tpi_spectralID ), 1, "spectralID" ) ) == NULL ) return( NULL );
176 tpi_spectralID_initialize( smr, spectralID );
177 return( spectralID );
178}
int tpi_spectralID_initialize(statusMessageReporting *, tpi_spectralID *spectralID)
Definition: tpi_IDs.cc:183

◆ tpi_spectralID_free()

void * tpi_spectralID_free ( statusMessageReporting smr,
tpi_spectralID spectralID 
)

Definition at line 191 of file tpi_IDs.cc.

191 {
192
193 if( spectralID != NULL ) {
194 tpi_spectralID_release( smr, spectralID );
195 xData_free( smr, spectralID );
196 }
197 return( NULL );
198}
int tpi_spectralID_release(statusMessageReporting *smr, tpi_spectralID *spectralID)
Definition: tpi_IDs.cc:202

Referenced by tpi_channelID_release(), and tpia_particle_release().

◆ tpi_spectralID_initialize()

int tpi_spectralID_initialize ( statusMessageReporting smr,
tpi_spectralID spectralID 
)

Definition at line 183 of file tpi_IDs.cc.

183 {
184
185 memset( spectralID, 0, sizeof( tpi_spectralID ) );
186 return( 0 );
187}

Referenced by tpi_spectralID_allocate(), and tpi_spectralID_release().

◆ tpi_spectralID_parse()

tpi_spectralID * tpi_spectralID_parse ( statusMessageReporting smr,
char const str,
char **  EOP 
)

Definition at line 218 of file tpi_IDs.cc.

218 {
219
220 return( _tpi_spectralID_parse2( smr, str, str, EOP ) );
221}

Referenced by tpia_particle_getInternalID().

◆ tpi_spectralID_release()

int tpi_spectralID_release ( statusMessageReporting smr,
tpi_spectralID spectralID 
)

Definition at line 202 of file tpi_IDs.cc.

202 {
203
204 tpi_spectralIDQualifier *qualifier, *next;
205
206 if( spectralID->name != NULL ) free( spectralID->name );
207 for( qualifier = spectralID->qualifiers; qualifier != NULL; qualifier = next ) {
208 next = qualifier->next;
209 xData_free( smr, qualifier );
210 }
211 if( spectralID->decayChannel != NULL ) tpi_channelID_free( smr, spectralID->decayChannel );
212 tpi_spectralID_initialize( smr, spectralID );
213 return( 0 );
214}
tpi_spectralIDQualifier * next
Definition: tpi_IDs.h:56
char * name
Definition: tpi_IDs.h:63
tpi_spectralIDQualifier * qualifiers
Definition: tpi_IDs.h:64
tpi_channelID * decayChannel
Definition: tpi_IDs.h:70
void * tpi_channelID_free(statusMessageReporting *smr, tpi_channelID *channelID)
Definition: tpi_IDs.cc:74

Referenced by tpi_spectralID_free().

◆ tpi_spectralID_toString()

int tpi_spectralID_toString ( statusMessageReporting smr,
tpi_spectralID spectralID,
gString gStr 
)

Definition at line 353 of file tpi_IDs.cc.

353 {
354
355 return( tpi_spectralID_toStringSans( smr, spectralID, gStr, NULL ) );
356}

◆ tpi_spectralID_toStringSanRevision()

int tpi_spectralID_toStringSanRevision ( statusMessageReporting smr,
tpi_spectralID spectralID,
gString gStr 
)

Definition at line 360 of file tpi_IDs.cc.

360 {
361
362 //char *sans[] = { "revision", NULL };
363 char *sans[] = { (char*)"revision", NULL };
364
365 return( tpi_spectralID_toStringSans( smr, spectralID, gStr, sans ) );
366}

◆ tpi_spectralID_toStringSans()

int tpi_spectralID_toStringSans ( statusMessageReporting smr,
tpi_spectralID spectralID,
gString gStr,
char *  sans[] 
)

Definition at line 371 of file tpi_IDs.cc.

371 {
372
373 tpi_spectralIDQualifier *qualifier;
374 int i;
375 char **san, *sSan[] = { NULL };
376
377 if( sans == NULL ) sans = sSan;
378 if( spectralID->decayChannel != NULL ) if( gString_addTo( smr, gStr, "(" ) != 0 ) return( 1 );
379 if( ( gString_addTo( smr, gStr, spectralID->name ) ) != 0 ) return( 1 );
380 if( spectralID->qualifiers != NULL ) {
381 for( qualifier = spectralID->qualifiers, i = 0; qualifier != NULL; qualifier = qualifier->next ) i++;
382 for( qualifier = spectralID->qualifiers; qualifier != NULL; qualifier = qualifier->next ) {
383 for( san = (char **) sans; *san != NULL; san++ ) {
384 if( strcmp( *san, qualifier->name ) == 0 ) {
385 i--;
386 break;
387 }
388 }
389 }
390 if( i > 0 ) {
391 if( gString_addTo( smr, gStr, "[" ) != 0 ) return( 1 );
392 for( qualifier = spectralID->qualifiers; qualifier != NULL; qualifier = qualifier->next ) {
393 for( san = (char **) sans; *san != NULL; san++ ) if( strcmp( *san, qualifier->name ) == 0 ) break;
394 if( *san != NULL ) continue;
395 if( gString_addTo( smr, gStr, qualifier->name ) != 0 ) return( 1 );
396 if( gString_addTo( smr, gStr, ":'" ) != 0 ) return( 1 );
397 if( gString_addTo( smr, gStr, qualifier->value ) != 0 ) return( 1 );
398 if( gString_addTo( smr, gStr, "'") != 0 ) return( 1 );
399 if( i == 1 ) {
400 if( gString_addTo( smr, gStr, "]" ) != 0 ) return( 1 ); }
401 else {
402 if( gString_addTo( smr, gStr, ", " ) != 0 ) return( 1 );
403 }
404 i--;
405 }
406 }
407 }
408 if( spectralID->decayChannel != NULL ) {
409 if( ( gString_addTo( smr, gStr, " -> " ) ) != 0 ) return( 1 );
410 if( ( tpi_channelID_toStringSans( smr, spectralID->decayChannel, gStr, sans ) ) != 0 ) return( 1 );
411 if( ( gString_addTo( smr, gStr, ")" ) ) != 0 ) return( 1 );
412 }
413 return( 0 );
414}

Referenced by tpi_channelID_toStringSans(), tpi_spectralID_toString(), and tpi_spectralID_toStringSanRevision().