Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

VirtualFeatureTable.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Feature_VirtualFeatureTable_h
00002 #define Impala_Core_Feature_VirtualFeatureTable_h
00003 
00004 #include "Core/Array/Arrays.h"
00005 #include "Core/Vector/VectorTem.h"
00006 #include "Core/Table/QuidTable.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Feature
00013 {
00014 
00015 
00016 class VirtualFeatureTable
00017 {
00018 public:
00019 
00020     typedef Vector::VectorTem<Real64> Vector64;
00021 
00022     VirtualFeatureTable()
00023     {
00024     }
00025 
00026     virtual
00027     ~VirtualFeatureTable()
00028     {
00029     }
00030 
00031     virtual int
00032     Size() const = 0;
00033 
00034     virtual void
00035     GetQuids(Table::QuidTable* quids) = 0;
00036 
00037     virtual int
00038     GetVectorLength() const = 0;
00039 
00040     Vector64
00041     GetVector(int nr)
00042     {
00043         Vector64 res(GetVectorLength());
00044         GetVector(nr, res.GetData(), res.Size());
00045         return res;
00046     }
00047 
00048     int
00049     GetVector(int nr, Real64* buffer, int bufferSize)
00050     {
00051         if (bufferSize < GetVectorLength())
00052         {
00053             ILOG_ERROR("[GetVector] Buffer too small");
00054             return 0;
00055         }
00056         return GetVectorImpl(nr, buffer, bufferSize);
00057     }
00058 
00059     int
00060     GetVector(int nr, Real32* buffer, int bufferSize)
00061     {
00062         if (bufferSize < GetVectorLength())
00063         {
00064             ILOG_ERROR("[GetVector] Buffer too small");
00065             return 0;
00066         }
00067         Real64* tmpBuf = new Real64[bufferSize];
00068         int res = GetVectorImpl(nr, tmpBuf, bufferSize);
00069         for (int i=0 ; i<res ; i++)
00070             buffer[i] = tmpBuf[i];
00071         delete tmpBuf;
00072         return res;
00073     }
00074 
00075     template <class FType>
00076     int
00077     GetAlignedVectors(int start, int nr, FType* buffer, int outputPitch)
00078     {
00079         if (start >= Size())
00080         {
00081             ILOG_ERROR("[GetAlignedVectors] Start beyond total vector count");
00082             return 0;
00083         }
00084         int linesRead = Min(nr, Size() - start);
00085         for (int i=0 ; i<linesRead ; i++)
00086         {
00087             FType* ptr = buffer + i * outputPitch;
00088             GetVector(start+i, ptr, GetVectorLength());
00089             for (int j=GetVectorLength() ; j<outputPitch ; j++)
00090                 ptr[j] = 0.0;
00091         }
00092         // pad additional rows with zeros, if they were not read
00093         // because zero padding above is only done in unused area on the right
00094         for (int i=linesRead ; i<nr ; i++)
00095         {
00096             FType* ptr = buffer + i * outputPitch;
00097             for (int j=0 ; j<outputPitch ; j++)
00098                 ptr[j] = 0.0;
00099         }
00100         return linesRead;
00101     }
00102 
00103 private:
00104 
00105     virtual int
00106     GetVectorImpl(int nr, Real64* buffer, int bufferSize) = 0;
00107 
00108     ILOG_VAR_DEC;
00109 };
00110 
00111 ILOG_VAR_INIT(VirtualFeatureTable, Impala.Core.Feature);
00112 
00113 } // namespace Feature
00114 } // namespace Core
00115 } // namespace Impala
00116 
00117 #endif

Generated on Thu Jan 13 09:04:26 2011 for ImpalaSrc by  doxygen 1.5.1