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

#include <FunNameStack.h>

+ Inheritance diagram for FunNameStack:

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 ()
 
wl_inline int put (const char *fname)
 
wl_inline void del (int nname)
 
wl_inline 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 593 of file FunNameStack.h.

Constructor & Destructor Documentation

◆ FunNameStack() [1/2]

FunNameStack::FunNameStack ( const FunNameStack f)

Definition at line 333 of file FunNameStack.cpp.

333{ *this = f; }

◆ FunNameStack() [2/2]

FunNameStack::FunNameStack ( void  )

Definition at line 101 of file FunNameStack.cpp.

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

Referenced by instance().

◆ ~FunNameStack()

FunNameStack::~FunNameStack ( )

Definition at line 404 of file FunNameStack.cpp.

404 {
405#ifdef USE_BOOST_MULTITHREADING
406#ifdef USE_TOGETHER_WITH_CLEAN_NEW
407#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
408 MemoriseIgnore::instance().ignore();
409#else
410 s_ignore_keynumberlist = 1;
411#endif
412#endif
413 if (namestack != NULL) delete namestack;
414#ifdef USE_TOGETHER_WITH_CLEAN_NEW
415#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
416 MemoriseIgnore::instance().not_ignore();
417#else
418 s_ignore_keynumberlist = 0;
419#endif
420#endif
421#else
422 int n;
423#ifdef USE_TOGETHER_WITH_CLEAN_NEW
424 s_ignore_keynumberlist = 1;
425#endif
426 if (nmode == 1) for (n = 0; n < qname; n++)
427 delete name[n];
428#ifdef USE_TOGETHER_WITH_CLEAN_NEW
429 s_ignore_keynumberlist = 0;
430#endif
431#endif
432}

Member Function Documentation

◆ del()

wl_inline void FunNameStack::del ( int  nname)

◆ instance()

FunNameStack & FunNameStack::instance ( )
static

Definition at line 66 of file FunNameStack.cpp.

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

Referenced by FunNameStack_Assist::FunNameStack_Assist(), and operator=().

◆ operator=()

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

Definition at line 335 of file FunNameStack.cpp.

335 {
336 if (this == &(FunNameStack::instance())) {
337 mcerr << "ERROR in FunNameStack& FunNameStack::operator=(const "
338 "FunNameStack& f)\n";
339 mcerr << "Attempt to copy to operative FunNameStack\n";
340 mcerr << "You don't need and should not initialize main FunNameStack "
341 "directly\n";
342 mcerr << "If you want to change its parameters, use "
343 "FunNameStack::instance()\n";
344 Iprintn(mcout, this);
346 Iprintn(mcout, (*this));
348
349 spexit(mcerr);
350 }
351#ifdef USE_BOOST_MULTITHREADING
352
353#ifdef USE_TOGETHER_WITH_CLEAN_NEW
354#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
355 MemoriseIgnore::instance().ignore();
356#else
357 s_ignore_keynumberlist = 1;
358#endif
359#endif
360 if (namestack != NULL) delete namestack;
361 namestack = new AbsList<NameStack>(*(f.namestack));
362#ifdef USE_TOGETHER_WITH_CLEAN_NEW
363#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
364 MemoriseIgnore::instance().not_ignore();
365#else
366 s_ignore_keynumberlist = 0;
367#endif
368#endif
369
370#else
371 qname = f.qname;
372#endif
373 s_init = f.s_init;
374 s_act = f.s_act;
375 s_print = f.s_print;
376 nmode = f.nmode;
377#ifdef USE_BOOST_MULTITHREADING
378#else
379 int n;
380 for (n = 0; n < f.qname; n++) {
381 if (nmode == 0) {
382 name[n] = f.name[n];
383 } else {
384 int l = strlen(f.name[n]) + 1;
385#ifdef USE_TOGETHER_WITH_CLEAN_NEW
386 s_ignore_keynumberlist = 1;
387#endif
388 name[n] = new char[l];
389 strcpy(name[n], f.name[n]);
390#ifdef USE_TOGETHER_WITH_CLEAN_NEW
391 s_ignore_keynumberlist = 0;
392#endif
393 }
394 }
395#endif
396 return *this;
397}
#define spexit(stream)
Definition: FunNameStack.h:536
static FunNameStack & instance()
#define mcout
Definition: prstream.h:133

◆ put()

wl_inline int FunNameStack::put ( const char *  fname)

◆ replace()

wl_inline void FunNameStack::replace ( const char *  fname)

◆ set_parameters()

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

Definition at line 399 of file FunNameStack.cpp.

399 {
400 s_act = fs_act;
401 s_print = fs_print; // only to correct this
402}

Referenced by FunNameStack_Assist::FunNameStack_Assist().

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 476 of file FunNameStack.cpp.

476 {
477 if (f.s_act == 1) {
478#ifdef USE_BOOST_MULTITHREADING
479 file << "FunNameStack: s_init=" << f.s_init << '\n';
480 long nret, qret;
481 NameStack* ns = f.get_thread_stack_q(nret, qret);
482 file << " id=" << ns->id << " qname=" << ns->qname << '\n';
483 file << "At the time of scanning there were " << qret << " threads \n"
484 << "registered in FunNameStack system.\n";
485 file << "The current one appeared nth: " << nret << '\n';
486 int n;
487 for (n = 0; n < ns->qname; n++) {
488 //file << " n =" << std::setw(3) << n << " " << f.name[n] << '\n';
489 file << std::setw(3) << n << " " << ns->name[n] << " \n";
490 }
491#else
492 file << "FunNameStack: s_init=" << f.s_init << " qname=" << f.qname << '\n';
493 int n;
494 for (n = 0; n < f.qname; n++) {
495 //file << " n =" << std::setw(3) << n << " " << f.name[n] << '\n';
496 file << std::setw(3) << n << " " << f.name[n] << " \n";
497 }
498#endif
499 }
500 return file;
501}

Member Data Documentation

◆ s_print

int FunNameStack::s_print

Definition at line 631 of file FunNameStack.h.

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


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