Streaming of template

Hi,
I have some classes that are not based on TObject. I wanted to make some workaround to “pretend” that they are TObjects (I not store them I ROOT files).
The class template looks like:

template<class T>
  class ObjectVoid : public Object {
    T* fPointer   = {nullptr};
    Bool_t fOwner = {kFALSE};

  public:
    ObjectVoid() {};
    ObjectVoid(T* obj, Bool_t owner) : fPointer(obj), fOwner(owner) {}
    T* GetCore() const { return fPointer; }
    virtual ~ObjectVoid() {
      if (fOwner && fPointer) delete fPointer;
    }
    ClassDef(ObjectVoid, 0)
  };

I build a library with this (let’s call it libraryA). The problem is that I do not know the types of classes at this moment.
Therefore I have to build dictionary in project that uses libraryA, however adding few lines to linkdef doesn’t help. So my question is possible to create a dictionary in library that does not contain definition of template?


Please read tips for efficient and successful posting and posting code

Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,

Bear with me, I think I do not understand what the exact problem is. Could you perhaps rephrase the goal you are trying to achieve?
Maybe I misunderstood, but if you do not store the instances of this template in files, why do you need their dictionaries?

Thanks in advance.

Cheers,
D

Hi,
I need dictionaries because it inherits from TObject.

Why? (I.e. how it the inheritance from TObject helping you)"

So my question is possible to create a dictionary in library that does not contain definition of template?

I am not sure which direction you mean :slight_smile: but typically you have:

  • library/package A which contain the main declaration/implementation of the class template (Tmplt)
  • library/package B which contain the implementation of concrete class (SomeClass)
  • library/package C which can contain the dictionary for the class template instance of the concrete class (Tmplt<SomeClass>)
  • A and B can be completely indepedent.
  • C will depend/use both A and B.
  • C might be the same library as B; B might be the same library as A. A might be the same library as C. A, B and C might be the same library. If A and C are the same library the combined library has to depend/use B.

however adding few lines to linkdef doesn’t help

How did it fail?

How did it fail?
during compilation process it simply says "Warning: Unused class rule: mytemplate

However, I probably found the source of the issue -missing include in the header - when I included a template header in the SomeClass.h, it started working.

So thank you for your help.