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

#include <AbsPtr.h>

Static Public Member Functions

static X * copy (const X *f)
 

Detailed Description

template<class X>
class StandardCopyDefinition< X >

Definition at line 351 of file AbsPtr.h.

Member Function Documentation

◆ copy()

template<class X >
static X * StandardCopyDefinition< X >::copy ( const X *  f)
inlinestatic

Definition at line 353 of file AbsPtr.h.

353 {
354#ifdef DEBUG_ACTIVEPTR
355 mcout << "static X* StandardCopyDefinition::copy(const X* f)\n";
356#endif
357// If to allow the type of copy function be any (void* for example,
358// it needs to convert it. This seems there is no reason to allow this.
359#ifndef COPY_TYPE_CHECK
360#ifndef COPY_RETURNS_COMMON_BASE
361 return f->copy();
362#else
363 X* ptr = dynamic_cast<X*>(f->copy());
364 if (ptr == NULL) {
365 mcerr << "Error in X* StandardCopyDefinition::copy(const X* f): "
366 << "cannot convert pointer returned from f->copy()"
367 << "to type " << typeid(X).name() << '\n';
368 }
369 return ptr;
370#endif
371#else
372 //return (X*)(f->copy());
373 //X* p = static_cast< X* >(f->copy());
374 //#ifndef COPY_RETURNS_VOID // this macro should NOT be used, leads to
375 //errors
376 X* p = f->copy();
377//#else
378//X* p = dynamic_cast< X* >(f->copy());
379//if(p == NULL)
380//{
381// mcerr<<"Error in X* StandardCopyDefinition::copy(const X* f): "
382// <<"cannot convert pointer returned from f->copy()"
383// <<"to type "<<typeid(X).name()<<'\n';
384//}
385//#endif
386#ifdef DEBUG_ACTIVEPTR
387 mcout << "X* StandardCopyDefinition::copy(const X* f): f->copy() returned "
388 << p << '\n';
389 mcerr << "Type of X is (in internal notations) " << typeid(X).name()
390 << '\n';
391 mcerr << "Type of *p is (in internal notations) " << typeid(*p).name()
392 << '\n';
393#endif
394 if (typeid(*p) != typeid(*f)) {
395 mcerr << "Error in X* StandardCopyDefinition::copy(const X* f): "
396 << "typeid(*p) != typeid(*f) \n";
397 mcerr << "Type of X is (in internal notations) " << typeid(X).name()
398 << '\n';
399 mcerr << "Type of *p is (in internal notations) " << typeid(*p).name()
400 << '\n';
401 mcerr << "Type of *f is (in internal notations) " << typeid(*f).name()
402 << '\n';
403 mcerr << "Possible reason is omiting of copy function in one of the "
404 "derivative classes\n";
405 spexit(mcerr);
406 }
407 return p;
408#endif
409 }
#define spexit(stream)
Definition: FunNameStack.h:536
#define mcout
Definition: prstream.h:133
#define mcerr
Definition: prstream.h:135

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