Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Heed::FunNameStack Class Reference

#include <FunNameStack.h>

Public Member Functions

 FunNameStack (const FunNameStack &f)
 
FunNameStackoperator= (const FunNameStack &f)
 
 FunNameStack (void)
 
void set_parameters (int fs_act=1, int fs_print=0)
 
 ~FunNameStack ()
 
int put (const char *fname)
 
void del (int nname)
 
void replace (const char *fname)
 

Static Public Member Functions

static FunNameStackinstance ()
 

Public Attributes

int s_print
 

Friends

std::ostream & operator<< (std::ostream &file, const FunNameStack &f)
 

Detailed Description

Definition at line 309 of file FunNameStack.h.

Constructor & Destructor Documentation

◆ FunNameStack() [1/2]

Heed::FunNameStack::FunNameStack ( const FunNameStack f)

Definition at line 318 of file FunNameStack.cpp.

318{ *this = f; }

◆ FunNameStack() [2/2]

Heed::FunNameStack::FunNameStack ( void  )

Definition at line 94 of file FunNameStack.cpp.

95 : // usually called inly from instance()
96 s_init(1),
97 s_act(1),
98 s_print(0),
99 nmode(0) {
100#ifdef USE_BOOST_MULTITHREADING
101
102#ifdef USE_TOGETHER_WITH_CLEAN_NEW
103#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
104 MemoriseIgnore::instance().ignore();
105#else
106 s_ignore_keynumberlist = 1; // to avoid report from delete at deletion
107#endif
108#endif
109 namestack = new std::list<NameStack>;
110 namestack->push_back(NameStack());
111#ifdef USE_TOGETHER_WITH_CLEAN_NEW
112#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
113 MemoriseIgnore::instance().not_ignore();
114#else
115 s_ignore_keynumberlist = 0;
116#endif
117#endif // for ifdef USE_TOGETHER_WITH_CLEAN_NEW
118
119 pthread_t id = pthread_self();
120 namestack->back().id = id;
121#ifdef PRINT_MESSAGE_ABOUT_THREAD_INITIALIZATION
122 mcerr
123 << "-----------------------------------------------------------------\n";
124 mcerr
125 << "-----------------------------------------------------------------\n";
126 mcerr
127 << "-----------------------------------------------------------------\n";
128 mcerr
129 << "-----------------------------------------------------------------\n";
130 mcerr
131 << "-----------------------------------------------------------------\n";
132 mcerr << "FunNameStack::FunNameStack(void) const:\n";
133 mcerr << "thread is initialized:\n";
134 Iprintn(mcerr, id);
135 mcerr
136 << "-----------------------------------------------------------------\n";
137 mcerr
138 << "-----------------------------------------------------------------\n";
139 mcerr
140 << "-----------------------------------------------------------------\n";
141 mcerr
142 << "-----------------------------------------------------------------\n";
143 mcerr
144 << "-----------------------------------------------------------------\n";
145#endif
146#else // for ifdef USE_BOOST_MULTITHREADING
147 qname = 0;
148 for (int n = 0; n < pqname; n++) name[n] = NULL;
149#endif
150}
#define mcerr
Definition: prstream.h:128
#define Iprintn(file, name)
Definition: prstream.h:204

Referenced by instance().

◆ ~FunNameStack()

Heed::FunNameStack::~FunNameStack ( )

Definition at line 388 of file FunNameStack.cpp.

388 {
389#ifdef USE_BOOST_MULTITHREADING
390#ifdef USE_TOGETHER_WITH_CLEAN_NEW
391#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
392 MemoriseIgnore::instance().ignore();
393#else
394 s_ignore_keynumberlist = 1;
395#endif
396#endif
397 if (namestack) delete namestack;
398#ifdef USE_TOGETHER_WITH_CLEAN_NEW
399#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
400 MemoriseIgnore::instance().not_ignore();
401#else
402 s_ignore_keynumberlist = 0;
403#endif
404#endif
405#else
406#ifdef USE_TOGETHER_WITH_CLEAN_NEW
407 s_ignore_keynumberlist = 1;
408#endif
409 if (nmode == 1)
410 for (int n = 0; n < qname; n++) delete name[n];
411#ifdef USE_TOGETHER_WITH_CLEAN_NEW
412 s_ignore_keynumberlist = 0;
413#endif
414#endif
415}

Member Function Documentation

◆ del()

void Heed::FunNameStack::del ( int  nname)
inline

◆ instance()

FunNameStack & Heed::FunNameStack::instance ( )
static

Definition at line 59 of file FunNameStack.cpp.

59 {
60// static FunNameStack inst; // According to some Internet site this is
61// Meyer's approach,
62// // time of descruction is not determined.
63// // So it can potentially be destructed before it is still in use.
64// return inst;
65#ifdef USE_BOOST_MULTITHREADING
66#ifdef PRINT_BEFORE_LOCK
67 fprintf(stderr, "FunNameStack& FunNameStack::instance()\n");
68#endif
69 boost::mutex locked_object;
70 boost::mutex::scoped_lock scopedLock_object(locked_object);
71#endif
72
73 static FunNameStack* inst = NULL; // According to this site it is
74 // "GoF" approach,
75 // destruction is not performed at all.
76#ifdef USE_TOGETHER_WITH_CLEAN_NEW
77#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
78 MemoriseIgnore::instance().ignore();
79#else
80 s_ignore_keynumberlist = 1; // to avoid report from delete at deletion
81#endif
82#endif
83 if (!inst) inst = new FunNameStack();
84#ifdef USE_TOGETHER_WITH_CLEAN_NEW
85#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
86 MemoriseIgnore::instance().not_ignore();
87#else
88 s_ignore_keynumberlist = 0;
89#endif
90#endif
91 return *inst;
92}

Referenced by operator=().

◆ operator=()

FunNameStack & Heed::FunNameStack::operator= ( const FunNameStack f)

Definition at line 320 of file FunNameStack.cpp.

320 {
321 if (this == &(FunNameStack::instance())) {
322 mcerr << "ERROR in FunNameStack& FunNameStack::operator=(const "
323 "FunNameStack& f)\n";
324 mcerr << "Attempt to copy to operative FunNameStack\n";
325 mcerr << "You don't need and should not initialize main FunNameStack "
326 "directly\n";
327 mcerr << "If you want to change its parameters, use "
328 "FunNameStack::instance()\n";
329 Iprintn(mcout, this);
331 Iprintn(mcout, (*this));
333
334 spexit(mcerr);
335 }
336#ifdef USE_BOOST_MULTITHREADING
337
338#ifdef USE_TOGETHER_WITH_CLEAN_NEW
339#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
340 MemoriseIgnore::instance().ignore();
341#else
342 s_ignore_keynumberlist = 1;
343#endif
344#endif
345 if (namestack) delete namestack;
346 namestack = new std::list<NameStack>(*(f.namestack));
347#ifdef USE_TOGETHER_WITH_CLEAN_NEW
348#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
349 MemoriseIgnore::instance().not_ignore();
350#else
351 s_ignore_keynumberlist = 0;
352#endif
353#endif
354
355#else
356 qname = f.qname;
357#endif
358 s_init = f.s_init;
359 s_act = f.s_act;
360 s_print = f.s_print;
361 nmode = f.nmode;
362#ifdef USE_BOOST_MULTITHREADING
363#else
364 for (int n = 0; n < f.qname; n++) {
365 if (nmode == 0) {
366 name[n] = f.name[n];
367 } else {
368 int l = strlen(f.name[n]) + 1;
369#ifdef USE_TOGETHER_WITH_CLEAN_NEW
370 s_ignore_keynumberlist = 1;
371#endif
372 name[n] = new char[l];
373 strcpy(name[n], f.name[n]);
374#ifdef USE_TOGETHER_WITH_CLEAN_NEW
375 s_ignore_keynumberlist = 0;
376#endif
377 }
378 }
379#endif
380 return *this;
381}
#define spexit(stream)
Definition: FunNameStack.h:256
static FunNameStack & instance()
#define mcout
Definition: prstream.h:126

◆ put()

int Heed::FunNameStack::put ( const char *  fname)
inline

◆ replace()

void Heed::FunNameStack::replace ( const char *  fname)
inline

◆ set_parameters()

void Heed::FunNameStack::set_parameters ( int  fs_act = 1,
int  fs_print = 0 
)

Definition at line 383 of file FunNameStack.cpp.

383 {
384 s_act = fs_act;
385 s_print = fs_print; // only to correct this
386}

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  file,
const FunNameStack f 
)
friend

Definition at line 455 of file FunNameStack.cpp.

455 {
456 if (f.s_act == 1) {
457#ifdef USE_BOOST_MULTITHREADING
458 file << "FunNameStack: s_init=" << f.s_init << '\n';
459 long nret, qret;
460 NameStack* ns = f.get_thread_stack_q(nret, qret);
461 file << " id=" << ns->id << " qname=" << ns->qname << '\n';
462 file << "At the time of scanning there were " << qret << " threads \n"
463 << "registered in FunNameStack system.\n";
464 file << "The current one appeared nth: " << nret << '\n';
465 for (int n = 0; n < ns->qname; n++) {
466 file << std::setw(3) << n << " " << ns->name[n] << " \n";
467 }
468#else
469 file << "FunNameStack: s_init=" << f.s_init << " qname=" << f.qname << '\n';
470 for (int n = 0; n < f.qname; n++) {
471 file << std::setw(3) << n << " " << f.name[n] << " \n";
472 }
473#endif
474 }
475 return file;
476}

Member Data Documentation

◆ s_print

int Heed::FunNameStack::s_print

Definition at line 347 of file FunNameStack.h.

Referenced by operator=(), and set_parameters().


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