#ifndef VEGA_VSignal
#define VEGA_VSignal

//#if !defined(__CINT__) || defined(__MAKECINT__)
#include "VGenericSignal.h"
#include "VSignalManager.h"
#include "Frv.h"
//#endif


#if !defined(__CINT__)
// Specialized helper functions for initialization, comparaison, copy
template <class T_type> FrVect* VSignalBuild(char* name, int nData, double dx, char* unitX="", char* unitY="", T_type dummy=0) {return 0;}
template <class T_type> int     VSignalTypeCompare(int type, T_type dummy=0) {return 0;}
template <class T_type> FrVect* VSignalCopyTo(FrVect* vect, T_type dummy=0) {return 0;}
#endif

//#if defined(__CINT__)
//class VSignal{};
//#endif

template <class T_type=double> class VSignal : public VGenericSignal
{
private:
   T_type*    mVectData;  // pointer to vector data
   // That should be all ! avoid putting too many data to be able to
   // pass VSignal objects instead of pointers to functions and methods

public:
      VSignal()
      {
     // VSignal constructor
         mVect = 0;
         mVectData = 0;
      //   mPlot = 0;
         printf("VSignal default constructorn");
      }

      VSignal(VFrVectObject* frvo)
      {
     // VSignal constructor
         printf ("operator = for VFrVectObjectn");
         FrVect* vect  = frvo->Release();
         delete frvo;
         Adopt(vect);
      }

      VSignal(const VSignal& v)
      {
     // VSignal copy constructor
         FrVect* vect0;
         if (!gSignalManager) gSignalManager = new VSignalManager();
         if (mVect) gSignalManager->Shrink(mVect);
         if (v.GetFrVect() != 0) {
            if (!VSignalTypeCompare<T_type>(v.GetFrVect()->type)) {
               vect0 = VSignalCopyTo<T_type>(v.GetFrVect());
            } else vect0 = v.GetFrVect();;
            gSignalManager->Grow(vect0);
            mVect = vect0;
            mVectData = (T_type*)(mVect->data);
    //        mPlot = 0;
         } else {
            mVect = 0;
            mVectData = 0;
         }
         printf("VSignal copy constructor from vector 0x%xn",(unsigned int)mVect);
      }
      
      VSignal(char* name, int nData, double dx, char* unitX="", char* unitY="")
      {
     // VSignal constructor
         mVect = VSignalBuild<T_type>(name,nData,dx,unitX,unitY);
         if (!mVect) {
            mVectData = 0;
            printf("Type not allowed n");
         } else {
            mVectData = (T_type*)(mVect->data);
            if (!gSignalManager) gSignalManager = new VSignalManager();
            gSignalManager->Grow(mVect);
            printf("VSignal constructor from vector doublen");
         }
     //    mPlot = 0;
      }

      virtual ~VSignal()
      {
     // VSignal destructor
         if (mVect && gSignalManager) gSignalManager->Shrink(mVect);
         printf("VSignal destructorn");
      }
      void  Adopt(FrVect* vect)
            {
               FrVect* vect0;
               if (!gSignalManager) gSignalManager = new VSignalManager();
               if (mVect) gSignalManager->Shrink(mVect);
               if (vect) {
                  if (!VSignalTypeCompare<T_type>(vect->type)) {
                     vect0 = VSignalCopyTo<T_type>(vect);
                  } else vect0=vect;
                  gSignalManager->Grow(vect0);
                  mVect = vect0;
                  mVectData = (T_type*)(mVect->data);
         //      mPlot = 0;
               } else {
                  mVect = 0;
                  mVectData = 0;
               }
               printf("adopt vector 0x%xn",(unsigned int)mVect);
            }
                            
      inline FrVect*   GetFrVect() const {return mVect;}
      inline int       GetLength() {if (mVect) return mVect->nx[0]; return 0;}
#if FR_VERS<6000
      inline double    GetTimeD() {return (double)(mVect->GTimeS + 1.e-9*mVect->GTimeN);}
#else
      inline double    GetTimeD() {return mVect->GTime;}
#endif
      inline T_type&   operator [] (int index){return mVectData[index];}
      inline VSignal<T_type>&   operator = (VSignal& v) {
         printf ("operator = called for VSignal\n");
         Adopt(v.GetFrVect());
         return *this;
      }
      
      inline VSignal<T_type> operator+ (VSignal<T_type>& v)
      {
	      VSignal<T_type> vout;
	      FrVect* vect;

 	      if(mVect==NULL || v.GetFrVect()==NULL){
	        printf("ERROR in in operator + -> Vector inside the object is NULL \n\n");
	        return vout;
	      }
	      
// 	      strcpy(output_name, v.GetFrVect()->name);
// 	      strcat(output_name, "_<+>_");
// 	      strcat(output_name, mVect->name);		
	      
	      if(mVect->nData!=v.GetFrVect()->nData){
	        printf("ERROR in operator + --> Different size vectors %ld %ldn\n", mVect->nData,v.GetFrVect()->nData);
	        return vout;
         }
	      
	      vect=FrvAdd(mVect,v.GetFrVect(),NULL,v.GetFrVect()->name);
#if FR_VERS<6000
	      vect->GTimeS=(v.GetFrVect())->GTimeS;
	      vect->GTimeN=(v.GetFrVect())->GTimeN;
#else
	      vect->GTime=(v.GetFrVect())->GTime;
#endif
	      vout.Adopt(vect);
	      return vout;
      }
         
      inline VSignal<T_type>& operator= (VFrVectObject* frvo) {
         printf ("operator = for VFrVectObject\n");
         FrVect* vect  = frvo->Release();
         delete frvo;
         Adopt(vect);
         return *this;
      }
      inline VSignal<T_type>&   operator= (FrVect* vect) {
         printf ("operator = not recommended for raw FrVect\n");
         return *this;
      }

      ClassDefT(VSignal,0) // Signal view/manipulation
};
ClassImpT(VSignal,T_type)

#endif


- ROOT page - VEGA page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to , or contact with any questions or problems regarding ROOT or VEGA.