mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 18:40:42 +02:00
Globally implement Copy() function for deep copy of detector objects
This commit is contained in:
parent
be607e8a2e
commit
ea288a1939
@ -222,6 +222,15 @@ template <class dataType> class analogDetector {
|
||||
*/
|
||||
virtual analogDetector *Clone() = 0;
|
||||
|
||||
/**
|
||||
Deep copy. Must be virtual!
|
||||
This is a new addition because of multithreaded storage cell data (where each sc has its own mutex).
|
||||
If the pure virtual function exists here, EVERY derived class has to overwrite it!
|
||||
That means a Copy() function must also be implemented in any derived class.
|
||||
\returns a deep copy of the original analog detector
|
||||
*/
|
||||
virtual analogDetector *Copy() = 0;
|
||||
|
||||
/**
|
||||
Gives an id to the structure. For debugging purposes in case of
|
||||
multithreading. \param i is to be set \returns current id
|
||||
|
@ -54,6 +54,10 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
pthread_mutex_init(fi, NULL);
|
||||
};
|
||||
|
||||
/**
|
||||
pointer-based copy constructor (cloner)
|
||||
\param orig detector to be copied
|
||||
*/
|
||||
interpolatingDetector(interpolatingDetector *orig)
|
||||
: singlePhotonDetector(orig) {
|
||||
// if (orig->interp)
|
||||
@ -66,10 +70,28 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
fi = orig->fi;
|
||||
}
|
||||
|
||||
/**
|
||||
* copy constructor (deep copy)
|
||||
* stricly, TODO: Implement Rule of Five!
|
||||
* (copy op=, move ctor, and move op= would need to be defined)
|
||||
*/
|
||||
interpolatingDetector(interpolatingDetector const& other)
|
||||
: singlePhotonDetector(other) {
|
||||
|
||||
interp = other.interp;
|
||||
|
||||
id = other.id;
|
||||
fi = other.fi;
|
||||
}
|
||||
|
||||
virtual interpolatingDetector *Clone() {
|
||||
return new interpolatingDetector(this);
|
||||
}
|
||||
|
||||
virtual interpolatingDetector *Copy() {
|
||||
return new interpolatingDetector(*this);
|
||||
}
|
||||
|
||||
virtual int setId(int i) {
|
||||
id = i;
|
||||
// interp->setId(id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user