TrapperVector< T > Class Template Reference

To store an array of values. It's a template class to be used in the serializing bytearray and import/export to dom tree. More...

#include <trappervector.h>

Inheritance diagram for TrapperVector< T >:

Inheritance graph
[legend]
List of all members.

Public Types

typedef QValueList< T > QualityList

Public Member Functions

 TrapperVector ()
 TrapperVector (size_t n)
 ~TrapperVector ()
vector< T > & stlVector ()
void readDom (QDomElement &elem)
void readAttributes (const QXmlAttributes &attr)
void readString (QString &str)
convertToTemplateType (QString valueStr)
QString convertToString (T value)
void writeDom (QDomElement &elem)
const char * data ()
const uint size ()
void resize (Q_UINT32 &len)

Protected Member Functions

QString name_of_type ()

Protected Attributes

vector< T > v

Detailed Description

template<class T>
class TrapperVector< T >

To store an array of values. It's a template class to be used in the serializing bytearray and import/export to dom tree.

Definition at line 40 of file trappervector.h.


Member Typedef Documentation

template<class T>
typedef QValueList< T > TrapperVector< T >::QualityList

Definition at line 51 of file trappervector.h.


Constructor & Destructor Documentation

template<class T>
TrapperVector< T >::TrapperVector (  )  [inline]

Definition at line 43 of file trappervector.h.

00044   {
00045   }

template<class T>
TrapperVector< T >::TrapperVector ( size_t  n  )  [inline]

Definition at line 46 of file trappervector.h.

00046                             : v(n)
00047   {
00048   }

template<class T>
TrapperVector< T >::~TrapperVector (  )  [inline]

Definition at line 49 of file trappervector.h.

00050   { }


Member Function Documentation

template<class T>
vector<T>& TrapperVector< T >::stlVector (  )  [inline]

Definition at line 52 of file trappervector.h.

Referenced by TrapperView::getInfo(), TrapperDoc::importPhd(), QualityInfo::myInfoPos(), DnaStrInfo::myInfoPos(), TrapperView::paintFeatures(), ChromatGui::paintMe(), PhdParser::parse(), QualityData::quality(), ReadMetaData::readStream(), ReadMetaData::writeXml(), ChromatData::writeXml(), QualityData::writeXml(), and DnaStrData::writeXml().

00053   {
00054     return v;
00055   }

template<class T>
void TrapperVector< T >::readDom ( QDomElement elem  )  [inline]

Definition at line 57 of file trappervector.h.

Referenced by QualityData::readDom(), and DnaStrData::readDom().

00058   {
00059     v.clear();
00060     
00061     QDomNode node = elem.firstChild();
00062     while ( !node.isNull() )
00063       {
00064         if ( node.isElement() && node.nodeName() == "trappervector" &&
00065              node.toElement().attribute("type") == name_of_type() )
00066           {
00067             QDomNode node2 = node.firstChild();
00068             while ( !node2.isNull() )
00069               {
00070                 if ( node2.isElement() && node2.nodeName() == "member" )
00071                   {
00072                     QDomElement elem2 = node2.toElement();
00073                     //                        QString name = name_of_type();
00074                     Q_ASSERT( elem2.hasAttribute( "value" ) );
00075                     QString valueStr = elem2.attribute( "value" );
00076                     T t = convertToTemplateType( valueStr );
00077                     v.push_back(t);
00078                   }
00079                 node2 = node2.nextSibling();
00080               }
00081             break;
00082           }
00083         node = node.nextSibling();
00084       }
00085   }

template<class T>
void TrapperVector< T >::readAttributes ( const QXmlAttributes attr  )  [inline]

Definition at line 87 of file trappervector.h.

Referenced by QualityData::readAttributes(), and DnaStrData::readAttributes().

00088   {
00089     
00090     QString str = attr.value("trappervector");
00091     
00092     readString(str);
00093     
00094   }

template<class T>
void TrapperVector< T >::readString ( QString str  )  [inline]

Definition at line 96 of file trappervector.h.

Referenced by TrapperVector< char >::readAttributes(), ReadMetaData::readAttributes(), and ChromatData::readAttributes().

00097   {
00098     v.clear();
00099     
00100     QTextStream stream(&str, IO_ReadOnly);
00101     
00102     while ( !stream.atEnd() ) {
00103       T tmp;
00104       stream>>tmp;
00105       v.push_back(tmp);
00106     }
00107     
00108   }

template<class T>
T TrapperVector< T >::convertToTemplateType ( QString  valueStr  )  [inline]

Definition at line 110 of file trappervector.h.

Referenced by TrapperVector< char >::readDom().

00111   {
00112     T t = valueStr;
00113     return t;
00114   }

template<class T>
QString TrapperVector< T >::convertToString ( value  )  [inline]

Definition at line 115 of file trappervector.h.

Referenced by TrapperVector< char >::writeDom().

00116   {
00117     QString s = value;
00118     return s;
00119   }

template<class T>
void TrapperVector< T >::writeDom ( QDomElement elem  )  [inline]

Definition at line 121 of file trappervector.h.

Referenced by QualityData::writeDom(), and DnaStrData::writeDom().

00122   {
00123     QDomDocument doc = elem.ownerDocument();
00124     QDomElement array = doc.createElement("trappervector");
00125     array.setAttribute("type",name_of_type());
00126     elem.appendChild( array );
00127     typename vector<T>::iterator it;
00128     
00129     for ( it = v.begin(); it != v.end(); ++it )
00130       {
00131         QDomElement member = doc.createElement("member");
00132         array.appendChild( member );
00133         QString str = convertToString( *it );
00134             member.setAttribute( "value" , str );
00135       }
00136   }

template<class T>
const char* TrapperVector< T >::data (  )  [inline]

Definition at line 137 of file trappervector.h.

Referenced by operator>>().

00138     {
00139         if (v.empty())
00140         {
00141             return NULL;
00142         }
00143         else
00144         {
00145             return ( char * ) &v[0];
00146         }
00147     }

template<class T>
const uint TrapperVector< T >::size (  )  [inline]

Definition at line 148 of file trappervector.h.

Referenced by TrapperDoc::importPhd(), and ChromatGui::paintMe().

00149     {
00150         return (uint) ( v.size() * sizeof( T ));
00151     }

template<class T>
void TrapperVector< T >::resize ( Q_UINT32 &  len  )  [inline]

Definition at line 152 of file trappervector.h.

Referenced by operator>>().

00153     {
00154         v.resize( (size_t) (len / sizeof( T ))) ;
00155     }

template<class T>
QString TrapperVector< T >::name_of_type (  )  [inline, protected]

Definition at line 158 of file trappervector.h.

Referenced by TrapperVector< char >::readDom(), and TrapperVector< char >::writeDom().

00159     {
00160         //  return standardMemberName;
00161         return QString("unknownType");
00162     }


Member Data Documentation

template<class T>
vector<T> TrapperVector< T >::v [protected]

Definition at line 157 of file trappervector.h.

Referenced by TrapperVector< char >::data(), TrapperVector< char >::readDom(), TrapperVector< char >::readString(), TrapperVector< char >::resize(), TrapperVector< char >::size(), TrapperVector< char >::stlVector(), and TrapperVector< char >::writeDom().


The documentation for this class was generated from the following file:
Generated on Fri Jul 17 20:19:54 2009 for ngsview by  doxygen 1.5.1