SyneRBI / SIRF

Main repository for the CCP SynerBI software
http://www.ccpsynerbi.ac.uk
Other
59 stars 29 forks source link

Longer term solutions to DataContainer data type issue needed. #1193

Open evgueni-ovtchinnikov opened 1 year ago

evgueni-ovtchinnikov commented 1 year ago

Some DataContainer methods compute a value that is complex for Gadgetron containers and real for other containers, and so, the variable that would store such a value cannot be explicitly declared in this abstract base class. Currently, this issue is quick-fixed by passing a void* to these methods that is cast to float* or complex_float_t* in the respective methods of the derived classes.

Possible longer term fixes:

evgueni-ovtchinnikov commented 1 year ago

@KrisThielemans sorry not sure I understand your last suggestion:

KrisThielemans commented 1 year ago

Something like this is probably better than what I had originally suggested as it needs only a template class, not 2 of them

template <typename DataType>
class DataContainerWithDataType: public DataContainer
{
public:
...
 virtual DataType sum() const = 0;
 virtual void sum(void * ptr) const override
 {
    const DataType ret = this->sum();
    *static_cast<DataType *>(ptr) = ret;
}

class STIRDataContainer : public DataContainerWithDataType<float>
{
private:
 typedef DataContainerWithDataType<float> base_type;
public:
  // make sure we get the generic version as well
  using  base_type::sum;
  virtual float sum() const override;
}