Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GIDI Class Reference

#include <G4GIDI.hh>

Public Member Functions

 G4GIDI (int ip, std::string &dataDirectory)
 
 G4GIDI (int ip, std::list< std::string > &dataDirectory)
 
 ~G4GIDI ()
 
int numberOfDataDirectories (void)
 
int addDataDirectory (std::string &dataDirectory)
 
int removeDataDirectory (std::string &dataDirectory)
 
std::string getDataDirectoryAtIndex (int index)
 
std::vector< std::string > * getDataDirectories (void)
 
bool isThisDataAvailable (std::string &lib_name, int iZ, int iA, int iM=0)
 
bool isThisDataAvailable (std::string &lib_name, std::string &targetName)
 
char * dataFilename (std::string &lib_name, int iZ, int iA, int iM=0)
 
char * dataFilename (std::string &lib_name, std::string &targetName)
 
std::vector< std::string > * getNamesOfAvailableLibraries (int iZ, int iA, int iM=0)
 
std::vector< std::string > * getNamesOfAvailableLibraries (std::string &targetName)
 
std::vector< std::string > * getNamesOfAvailableTargets (void)
 
G4GIDI_targetreadTarget (std::string &lib_name, int iZ, int iA, int iM=0, bool bind=true)
 
G4GIDI_targetreadTarget (std::string &lib_name, std::string &targetName, bool bind=true)
 
G4GIDI_targetgetAlreadyReadTarget (int iZ, int iA, int iM=0)
 
G4GIDI_targetgetAlreadyReadTarget (std::string &targetName)
 
int freeTarget (int iZ, int iA, int iM=0)
 
int freeTarget (std::string &targetSymbol)
 
int freeTarget (G4GIDI_target *target)
 
std::vector< std::string > * getListOfReadTargetsNames (void)
 

Detailed Description

Definition at line 43 of file G4GIDI.hh.

Constructor & Destructor Documentation

G4GIDI::G4GIDI ( int  ip,
std::string &  dataDirectory 
)

Definition at line 40 of file G4GIDI.cc.

40  {
41 
42  init( ip );
43  addDataDirectory( dataDirectory );
44 }
int addDataDirectory(std::string &dataDirectory)
Definition: G4GIDI.cc:110
G4GIDI::G4GIDI ( int  ip,
std::list< std::string > &  dataDirectory 
)
G4GIDI::~G4GIDI ( void  )

Definition at line 58 of file G4GIDI.cc.

58  {
59 
61  list<G4GIDI_map *>::iterator iter;
62 
63  while( targets.size( ) > 0 ) {
64  target = targets.back( );
65  targets.pop_back( );
66  delete target;
67  } // Loop checking, 11.06.2015, T. Koi
68 
69  while( ( iter = dataDirectories.begin( ) ) != dataDirectories.end( ) ) {
70  delete *iter;
71  dataDirectories.pop_front( );
72  }// Loop checking, 11.06.2015, T. Koi
73 }
const XML_Char * target
Definition: expat.h:268

Member Function Documentation

int G4GIDI::addDataDirectory ( std::string &  dataDirectory)

Definition at line 110 of file G4GIDI.cc.

110  {
111 
112  list<G4GIDI_map *>::iterator iter;
113 
114  for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++ ) {
115  if( (*iter)->path( ) == dataDirectory ) return( 0 );
116  }
117 
118  G4GIDI_map *map = new G4GIDI_map( dataDirectory );
119  dataDirectories.push_back( map );
120 
121  return( 0 );
122 }
char * G4GIDI::dataFilename ( std::string &  lib_name,
int  iZ,
int  iA,
int  iM = 0 
)

Definition at line 196 of file G4GIDI.cc.

196  {
197 
198  char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM ), *fileName;
199 
200  if( targetName == NULL ) return( NULL );
201  string targetSymbol( targetName );
202  fileName = dataFilename( lib_name, targetSymbol );
203  smr_freeMemory( (void **) &targetName );
204  return( fileName );
205 }
char * dataFilename(std::string &lib_name, int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:196
char * G4GIDI_Misc_Z_A_m_ToName(int iZ, int iA, int im=0)
Definition: G4GIDI_Misc.cc:44
void * smr_freeMemory(void **p)

Here is the call graph for this function:

char * G4GIDI::dataFilename ( std::string &  lib_name,
std::string &  targetName 
)

Definition at line 209 of file G4GIDI.cc.

209  {
210 
211 /*
212  char *path;
213  list<G4GIDI_map *>::iterator iter;
214 
215  for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++ ) {
216  if( ( path = MCGIDI_map_findTarget( &((*iter)->smr), (*iter)->map, lib_name.c_str( ), projectile.c_str( ), targetSymbol.c_str( ) ) ) != NULL ) {
217  return( path );
218  }
219  }
220  return( NULL );
221 */
222 //150121
223 //
224  char *path;
225  list<G4GIDI_map *>::iterator iter;
226 
227  for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++ ) {
228  if( ( path = MCGIDI_map_findTarget( NULL, (*iter)->map, lib_name.c_str(), projectile.c_str( ), targetSymbol.c_str( ) ) ) != NULL ) {
229  return( path );
230  }
231  }
232  return( NULL );
233 }
char * MCGIDI_map_findTarget(statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, const char *projectile, const char *targetName)
Definition: MCGIDI_map.cc:376

Here is the call graph for this function:

int G4GIDI::freeTarget ( int  iZ,
int  iA,
int  iM = 0 
)

Definition at line 363 of file G4GIDI.cc.

363  {
364 
365  int status;
366  char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
367 
368  if( targetName == NULL ) return( 1 );
369  string targetSymbol( targetName );
370  status = freeTarget( targetSymbol );
371  smr_freeMemory( (void **) &targetName );
372  return( status );
373 }
char * G4GIDI_Misc_Z_A_m_ToName(int iZ, int iA, int im=0)
Definition: G4GIDI_Misc.cc:44
int freeTarget(int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:363
void * smr_freeMemory(void **p)

Here is the call graph for this function:

int G4GIDI::freeTarget ( std::string &  targetSymbol)

Definition at line 377 of file G4GIDI.cc.

377  {
378 
379  vector<G4GIDI_target *>::iterator iter_targets;
380 
381  for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
382  if( (*iter_targets)->name == targetSymbol ) return( freeTarget( *iter_targets ) );
383  }
384  return( 1 );
385 }
int freeTarget(int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:363
int G4GIDI::freeTarget ( G4GIDI_target target)

Definition at line 347 of file G4GIDI.cc.

347  {
348 
349  vector<G4GIDI_target *>::iterator iter_targets;
350 
351  for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
352  if( *iter_targets == target ) {
353  targets.erase( iter_targets );
354  delete target;
355  return( 0 );
356  }
357  }
358  return( 1 );
359 }
const XML_Char * target
Definition: expat.h:268
G4GIDI_target * G4GIDI::getAlreadyReadTarget ( int  iZ,
int  iA,
int  iM = 0 
)

Definition at line 321 of file G4GIDI.cc.

321  {
322 
323  char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
325 
326  if( targetName == NULL ) return( NULL );
327  string targetSymbol( targetName );
328  target = getAlreadyReadTarget( targetSymbol );
329  smr_freeMemory( (void **) &targetName );
330  return( target );
331 }
const XML_Char * target
Definition: expat.h:268
G4GIDI_target * getAlreadyReadTarget(int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:321
char * G4GIDI_Misc_Z_A_m_ToName(int iZ, int iA, int im=0)
Definition: G4GIDI_Misc.cc:44
void * smr_freeMemory(void **p)

Here is the call graph for this function:

G4GIDI_target * G4GIDI::getAlreadyReadTarget ( std::string &  targetName)

Definition at line 335 of file G4GIDI.cc.

335  {
336 
337  vector<G4GIDI_target *>::iterator iter_targets;
338 
339  for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
340  if( ( (*iter_targets)->name == targetSymbol ) ) return( *iter_targets );
341  }
342  return( NULL );
343 }
vector< string > * G4GIDI::getDataDirectories ( void  )

Definition at line 157 of file G4GIDI.cc.

157  {
158 
159  int i = 0;
160  list<G4GIDI_map *>::iterator iter;
161  vector<string> *v = new vector<string>( numberOfDataDirectories( ) );
162 
163  for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++, i++ ) (*v)[i] = string( (*iter)->fileName( ) );
164  return( v );
165 }
int numberOfDataDirectories(void)
Definition: G4GIDI.cc:103
tuple v
Definition: test.py:18
string G4GIDI::getDataDirectoryAtIndex ( int  index)

Definition at line 140 of file G4GIDI.cc.

140  {
141 
142  list<G4GIDI_map *>::iterator iter;
143  unsigned i = (unsigned) index;
144 
145  if( index >= 0 ) {
146  if( i >= dataDirectories.size( ) ) return( "" );
147  for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++, index-- ) {
148  if( index == 0 ) return( (*iter)->fileName( ) );
149  }
150  }
151 
152  return( "" );
153 }
vector< string > * G4GIDI::getListOfReadTargetsNames ( void  )

Definition at line 389 of file G4GIDI.cc.

389  {
390 
391  vector<G4GIDI_target *>::iterator iter_targets;
392  vector<string> *listOfTargets;
393 
394  listOfTargets = new vector<string>( );
395  if( listOfTargets == NULL ) return( NULL );
396  for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
397  listOfTargets->push_back( *(*iter_targets)->getName( ) );
398  }
399  return( listOfTargets );
400 }
vector< string > * G4GIDI::getNamesOfAvailableLibraries ( int  iZ,
int  iA,
int  iM = 0 
)

Definition at line 237 of file G4GIDI.cc.

237  {
238 
239  char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
240  vector<string> *listOfLibraries;
241 
242  if( targetName == NULL ) return( new vector<string>( ) );
243  string targetSymbol( targetName );
244  listOfLibraries = getNamesOfAvailableLibraries( targetSymbol );
245  smr_freeMemory( (void **) &targetName );
246  return( listOfLibraries );
247 }
char * G4GIDI_Misc_Z_A_m_ToName(int iZ, int iA, int im=0)
Definition: G4GIDI_Misc.cc:44
std::vector< std::string > * getNamesOfAvailableLibraries(int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:237
void * smr_freeMemory(void **p)

Here is the call graph for this function:

Here is the caller graph for this function:

vector< string > * G4GIDI::getNamesOfAvailableLibraries ( std::string &  targetName)

Definition at line 251 of file G4GIDI.cc.

251  {
252 
253  list<G4GIDI_map *>::iterator iter;
254  vector<string> *listOfLibraries = new vector<string>( );
255 
256  MCGIDI_map *map;
257  MCGIDI_mapEntry *entry;
258 
259  for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++ ) {
260  map = MCGIDI_map_findAllOfTarget( &((*iter)->smr), (*iter)->map, projectile.c_str( ), targetName.c_str( ) );
261  for( entry = MCGIDI_map_getFirstEntry( map ); entry != NULL; entry = MCGIDI_map_getNextEntry( entry ) ) {
262  listOfLibraries->push_back( entry->evaluation );
263  }
264  MCGIDI_map_free( NULL, map );
265  }
266  return( listOfLibraries );
267 }
MCGIDI_mapEntry * MCGIDI_map_getFirstEntry(MCGIDI_map *map)
Definition: MCGIDI_map.cc:204
char * evaluation
Definition: MCGIDI_map.h:34
Definition: MCGIDI_map.h:28
MCGIDI_map * MCGIDI_map_findAllOfTarget(statusMessageReporting *smr, MCGIDI_map *map, const char *projectile, const char *targetName)
Definition: MCGIDI_map.cc:430
void * MCGIDI_map_free(statusMessageReporting *smr, MCGIDI_map *map)
Definition: MCGIDI_map.cc:173
MCGIDI_mapEntry * MCGIDI_map_getNextEntry(MCGIDI_mapEntry *entry)
Definition: MCGIDI_map.cc:211

Here is the call graph for this function:

vector< string > * G4GIDI::getNamesOfAvailableTargets ( void  )

Definition at line 271 of file G4GIDI.cc.

271  {
272 
273  vector<string> *listOfTargets;
274  list<G4GIDI_map *>::iterator iter_map;
275 
276  listOfTargets = new vector<string>( );
277  if( listOfTargets == NULL ) return( NULL );
278  for( iter_map = dataDirectories.begin( ); iter_map != dataDirectories.end( ); iter_map++ ) {
279  if( MCGIDI_map_walkTree( NULL, (*iter_map)->map, getNamesOfAvailableTargets_walker, (void *) listOfTargets ) != 0 ) {
280  delete listOfTargets;
281  return( NULL );
282  }
283  }
284  return( listOfTargets );
285 }
int MCGIDI_map_walkTree(statusMessageReporting *smr, MCGIDI_map *map, int(*handler)(MCGIDI_mapEntry *entry, int level, void *userData), void *userData)
Definition: MCGIDI_map.cc:494
int getNamesOfAvailableTargets_walker(GIDI::MCGIDI_mapEntry *entry, int level, void *userData)

Here is the call graph for this function:

bool G4GIDI::isThisDataAvailable ( std::string &  lib_name,
int  iZ,
int  iA,
int  iM = 0 
)

Definition at line 169 of file G4GIDI.cc.

169  {
170 
171  bool b;
172  char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
173 
174  if( targetName == NULL ) return( false );
175  string targetSymbol( targetName );
176  b = isThisDataAvailable( lib_name, targetSymbol );
177  smr_freeMemory( (void **) &targetName );
178  return( b );
179 }
tuple b
Definition: test.py:12
char * G4GIDI_Misc_Z_A_m_ToName(int iZ, int iA, int im=0)
Definition: G4GIDI_Misc.cc:44
bool isThisDataAvailable(std::string &lib_name, int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:169
void * smr_freeMemory(void **p)

Here is the call graph for this function:

Here is the caller graph for this function:

bool G4GIDI::isThisDataAvailable ( std::string &  lib_name,
std::string &  targetName 
)

Definition at line 183 of file G4GIDI.cc.

183  {
184 
185  char *path = dataFilename( lib_name, targetName );
186 
187  if( path != NULL ) {
188  smr_freeMemory( (void **) &path );
189  return( true );
190  }
191  return( false );
192 }
char * dataFilename(std::string &lib_name, int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:196
void * smr_freeMemory(void **p)

Here is the call graph for this function:

int G4GIDI::numberOfDataDirectories ( void  )

Definition at line 103 of file G4GIDI.cc.

103  {
104 
105  return( dataDirectories.size( ) );
106 }
G4GIDI_target * G4GIDI::readTarget ( std::string &  lib_name,
int  iZ,
int  iA,
int  iM = 0,
bool  bind = true 
)

Definition at line 289 of file G4GIDI.cc.

289  {
290 
291  char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
293 
294  if( targetName == NULL ) return( NULL );
295  string targetSymbol( targetName );
296  target = readTarget( lib_name, targetSymbol, bind );
297  smr_freeMemory( (void **) &targetName );
298  return( target );
299 }
const XML_Char * target
Definition: expat.h:268
char * G4GIDI_Misc_Z_A_m_ToName(int iZ, int iA, int im=0)
Definition: G4GIDI_Misc.cc:44
void * smr_freeMemory(void **p)
G4GIDI_target * readTarget(std::string &lib_name, int iZ, int iA, int iM=0, bool bind=true)
Definition: G4GIDI.cc:289

Here is the call graph for this function:

Here is the caller graph for this function:

G4GIDI_target * G4GIDI::readTarget ( std::string &  lib_name,
std::string &  targetName,
bool  bind = true 
)

Definition at line 303 of file G4GIDI.cc.

303  {
304 
305  vector<G4GIDI_target *>::iterator iter_targets;
306 
307  for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
308  if( (*iter_targets)->name == targetName ) return( NULL );
309  }
310  char *path = dataFilename( lib_name, targetName );
311  if( path == NULL ) return( NULL );
312 
313  G4GIDI_target *target = new G4GIDI_target( path );
314  if( bind ) targets.push_back( target );
315  smr_freeMemory( (void **) &path );
316  return( target );
317 }
char * dataFilename(std::string &lib_name, int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:196
const XML_Char * target
Definition: expat.h:268
void * smr_freeMemory(void **p)

Here is the call graph for this function:

int G4GIDI::removeDataDirectory ( std::string &  dataDirectory)

Definition at line 126 of file G4GIDI.cc.

126  {
127 
128  list<G4GIDI_map *>::iterator iter;
129 
130  for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++ ) {
131  if( dataDirectory == (*iter)->path( ) ) {
132 
133  }
134  }
135  return( 0 );
136 }

The documentation for this class was generated from the following files: