TagData Class Reference

General Tag data. More...

#include <featuredata.h>

Inheritance diagram for TagData:

Inheritance graph
[legend]
Collaboration diagram for TagData:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TagData ()
 TagData (db_recno_t readRecno, TR_DNA startPos, TR_DNA endPos)
void readDom (QDomElement &elem)
virtual std::string uniqueName ()
virtual ~TagData ()
void readStream (QDataStream &str)
void writeStream (QDataStream &str)
void writeDom (QDomElement &elem)
void readAttributes (const QXmlAttributes &attr)
void writeXml (ostream &stream)
TrDb::IndexMap getIndexMap ()
void setInfo (const std::string &inf)
std::string getInfo ()
void setScore (const double &s)
double getScore ()
 TagData ()
 TagData (db_recno_t readRecno, TR_DNA startPos, TR_DNA endPos)
void readDom (QDomElement &elem)
virtual std::string uniqueName ()
virtual ~TagData ()
void readStream (QDataStream &str)
void writeStream (QDataStream &str)
void writeDom (QDomElement &elem)
void readAttributes (const QXmlAttributes &attr)
void writeXml (ostream &stream)
void setInfo (const std::string &inf)
std::string getInfo ()
void setScore (const double &s)
double getScore ()

Static Public Member Functions

static int getInfoAssoc (Db *dbp, const Dbt *pkey, const Dbt *pdata, Dbt *skey)
static int getScoreAssoc (Db *dbp, const Dbt *pkey, const Dbt *pdata, Dbt *skey)
static int bt_compare_info (DB *db, const DBT *dbt1, const DBT *dbt2)
static int bt_compare_score (DB *db, const DBT *dbt1, const DBT *dbt2)

Protected Member Functions

FeatureGuimakeGui ()
FeatureInfomakeInfo ()
FeatureGuimakeGui ()
FeatureInfomakeInfo ()

Protected Attributes

std::string info
double score

Detailed Description

General Tag data.

Definition at line 226 of file featuredata.h.


Constructor & Destructor Documentation

TagData::TagData (  )  [inline]

Definition at line 229 of file featuredata.h.

00229              : SpatialFeatureData()
00230   {}

TagData::TagData ( db_recno_t  readRecno,
TR_DNA  startPos,
TR_DNA  endPos 
)

Definition at line 472 of file featuredata.cpp.

virtual TagData::~TagData (  )  [inline, virtual]

Definition at line 235 of file featuredata.h.

00236   {}

TagData::TagData (  )  [inline]

Definition at line 210 of file spatialfeaturedata.h.

00210              : FeatureData()
00211   {}

TagData::TagData ( db_recno_t  readRecno,
TR_DNA  startPos,
TR_DNA  endPos 
)

virtual TagData::~TagData (  )  [inline, virtual]

Definition at line 216 of file spatialfeaturedata.h.

00217   {}


Member Function Documentation

void TagData::readDom ( QDomElement elem  )  [virtual]

Loads the state of this object from a dom tree. Or in other words reads in the values of the data members of this class from a dom tree underneath the QDomElement elem. This method is used for importing.

Reimplemented from GeneralData.

Definition at line 500 of file featuredata.cpp.

References GeneralData::readDom().

00501 {
00502     SpatialFeatureData::readDom( elem );
00503 }

virtual std::string TagData::uniqueName (  )  [inline, virtual]

Specifies a name that uniquely should identify this class. It will be used for lookups in the GeneralMaker class.

Implements GeneralData.

Definition at line 233 of file featuredata.h.

Referenced by TagInfo::myInfoPos().

00233 { return std::string("TagData"); }

void TagData::readStream ( QDataStream str  )  [virtual]

Loads the state of this object from a byte stream. Or in other words reads and unserializes a byte stream to set the values of this class object. This method is used for loading a GeneralData object from Berkeley Db.

Reimplemented from FeatureData.

Definition at line 476 of file featuredata.cpp.

References FeatureData::info(), SpatialFeatureData::readStream(), and score.

00477 {
00478   SpatialFeatureData::readStream( stream );
00479   stream>> score;
00480   QString tmp;
00481   stream>>tmp;
00482   info = tmp.ascii();
00483 }

void TagData::writeStream ( QDataStream str  )  [virtual]

Saves the state of this object to a byte stream. Or in other words serializes and writes the internal data held in this class object to a byte stream. This method is used for storing a GeneralData object into Berkeley Db.

Reimplemented from FeatureData.

Definition at line 485 of file featuredata.cpp.

References FeatureData::info(), score, and SpatialFeatureData::writeStream().

00486 {
00487   SpatialFeatureData::writeStream( str );
00488   str<<score;
00489   QString tmp;
00490   tmp = info;
00491   str<<tmp;
00492 
00493 }

void TagData::writeDom ( QDomElement elem  )  [virtual]

Saves the state of this object to a dom tree. Or in other words writes out the internal data held in this class to a dom tree underneath the QDomElement elem. This method is used for exporting.

Reimplemented from GeneralData.

Definition at line 495 of file featuredata.cpp.

References GeneralData::writeDom().

00496 {
00497     SpatialFeatureData::writeDom( elem );
00498 }

void TagData::readAttributes ( const QXmlAttributes attr  )  [virtual]

Loads the state of this object from QXmlAttributes.This method is used for importing.

Reimplemented from FeatureData.

Definition at line 505 of file featuredata.cpp.

References FeatureData::info(), SpatialFeatureData::readAttributes(), score, and QXmlAttributes::value().

Referenced by MacsimParser::endElement().

00506 {
00507   SpatialFeatureData::readAttributes( attr );
00508   if ( attr.value("info") != "" ) {
00509     info = attr.value("info").ascii();
00510   }
00511   if ( attr.value("score") != "" ) {
00512     score = attr.value("score").toDouble();
00513   }
00514 
00515 }

void TagData::writeXml ( ostream &  stream  )  [virtual]

Reimplemented from FeatureData.

Definition at line 517 of file featuredata.cpp.

References FeatureData::info(), score, and SpatialFeatureData::writeXml().

00518 {
00519   SpatialFeatureData::writeXml(stream);
00520   stream<<" info=\""<< info <<"\"";
00521   stream<<" score=\""<< score <<"\"";
00522   stream<<"/>\n";
00523 }

TrDb::IndexMap TagData::getIndexMap (  )  [virtual]

Returns a TrDb::IndexMap that specifies which secondary indexes should be generated for stored data objects of this class in the Berkeley Db backend. Each record in the TrDb::IndexMap generates a secondary index built as a btree ( a DB_BTREE in Berkeley Db wording ). The secondary index is sorted which makes it possible to do queries like "Give me the object that has the smallest value, bigger or equal than x".

And about speed performance, a quote from Berkeley Db documentation says: "Searches take O(log base_b N) time, where base_b is the average number of keys per page, and N is the total number of keys stored"

Reimplemented from FeatureData.

Definition at line 545 of file featuredata.cpp.

References QString::ascii(), bt_compare_info(), bt_compare_score(), FeatureData::getIndexMap(), getInfoAssoc(), getScoreAssoc(), and TrDb::Index::name.

00546 {
00547   TrDb::IndexMap iMap = FeatureData::getIndexMap();
00548   TrDb::Index i1 = {
00549     &TagData::bt_compare_info,
00550     &TagData::getInfoAssoc,
00551     QString("info"),
00552     NULL
00553   };
00554   iMap.insert( make_pair( i1.name.ascii(), i1 ) );
00555   
00556   TrDb::Index i2 = {
00557     &TagData::bt_compare_score,
00558     &TagData::getScoreAssoc,
00559     QString("score"),
00560     NULL
00561   };
00562   iMap.insert( make_pair( i2.name.ascii(), i2 ) );
00563 
00564   return iMap;
00565 }

int TagData::getInfoAssoc ( Db *  dbp,
const Dbt *  pkey,
const Dbt *  pdata,
Dbt *  skey 
) [static]

Definition at line 567 of file featuredata.cpp.

References getInfo(), FeatureData::info(), and Database::setFromDbt().

Referenced by getIndexMap().

00568 {
00569   memset(skey, 0, sizeof(Dbt));
00570   
00571   
00572   TagData tmp;
00573   Database::setFromDbt(pdata, &tmp);
00574   char* info = (char*)malloc(sizeof(char)*(tmp.getInfo().length() + 1));
00575   strcpy(info, tmp.getInfo().c_str());
00576   assert( info[ tmp.getInfo().length() ] == '\0' );
00577   skey->set_flags( DB_DBT_APPMALLOC );
00578   skey->set_data( (void*)info ); 
00579   skey->set_size(sizeof(char)*(strlen(info) + 1) );
00580   
00581 
00582   return 0;
00583 
00584 
00585 }

int TagData::getScoreAssoc ( Db *  dbp,
const Dbt *  pkey,
const Dbt *  pdata,
Dbt *  skey 
) [static]

Definition at line 587 of file featuredata.cpp.

References getScore(), and Database::setFromDbt().

Referenced by getIndexMap().

00588 {
00589   memset(skey, 0, sizeof(Dbt));
00590   
00591   TagData tmp;
00592   Database::setFromDbt(pdata, &tmp);
00593   double * data = (double*)malloc(sizeof(double));
00594   *data = tmp.getScore();
00595   skey->set_flags( DB_DBT_APPMALLOC );
00596   skey->set_data( (void*)data );
00597   skey->set_size(sizeof( double ));
00598 
00599   return 0;
00600 
00601 }

int TagData::bt_compare_info ( DB *  db,
const DBT *  dbt1,
const DBT *  dbt2 
) [static]

Definition at line 603 of file featuredata.cpp.

Referenced by getIndexMap().

00604 {
00605   char* infoData1 = ( char* ) dbt1->data;
00606   char* infoData2 = ( char* ) dbt2->data;
00607 
00608   
00609   return strcmp(infoData1, infoData2);
00610 
00611 }

int TagData::bt_compare_score ( DB *  db,
const DBT *  dbt1,
const DBT *  dbt2 
) [static]

Definition at line 613 of file featuredata.cpp.

Referenced by getIndexMap().

00614 {
00615     double* score1  = ( double*) dbt1->data;
00616     double* score2  = ( double*) dbt2->data;
00617     if ( *score1 > *score2 )
00618         return 1;
00619     if ( *score1 < *score2 )
00620         return -1;
00621     if ( *score1 == *score2 )
00622         return 0;
00623     /* should never reach this point */
00624     return 0;
00625 }

void TagData::setInfo ( const std::string &  inf  ) 

Definition at line 525 of file featuredata.cpp.

References FeatureData::info().

Referenced by TrapperView::findTag().

00526 {
00527   info = inf;
00528 }

std::string TagData::getInfo (  ) 

Definition at line 530 of file featuredata.cpp.

References FeatureData::info().

Referenced by TrapperView::findTag(), getInfoAssoc(), and TagInfo::myInfoPos().

00531 {
00532   return info;
00533 }

void TagData::setScore ( const double &  s  ) 

Definition at line 535 of file featuredata.cpp.

References score.

00536 {
00537   score = s;
00538 }

double TagData::getScore (  ) 

Definition at line 540 of file featuredata.cpp.

References score.

Referenced by getScoreAssoc(), TagInfo::myInfoPos(), and TagGui::paintMe().

00541 {
00542   return score;
00543 }

FeatureGui* TagData::makeGui (  )  [inline, protected, virtual]

Implements FeatureData.

Definition at line 257 of file featuredata.h.

00257 { return new TagGui( this ); }

FeatureInfo* TagData::makeInfo (  )  [inline, protected, virtual]

Implements FeatureData.

Definition at line 258 of file featuredata.h.

00258 { return new TagInfo( this ); }

void TagData::readDom ( QDomElement elem  )  [virtual]

Loads the state of this object from a dom tree. Or in other words reads in the values of the data members of this class from a dom tree underneath the QDomElement elem. This method is used for importing.

Reimplemented from GeneralData.

virtual std::string TagData::uniqueName (  )  [inline, virtual]

Specifies a name that uniquely should identify this class. It will be used for lookups in the GeneralMaker class.

Implements GeneralData.

Definition at line 214 of file spatialfeaturedata.h.

00214 { return std::string("TagData"); }

void TagData::readStream ( QDataStream str  )  [virtual]

Loads the state of this object from a byte stream. Or in other words reads and unserializes a byte stream to set the values of this class object. This method is used for loading a GeneralData object from Berkeley Db.

Reimplemented from FeatureData.

void TagData::writeStream ( QDataStream str  )  [virtual]

Saves the state of this object to a byte stream. Or in other words serializes and writes the internal data held in this class object to a byte stream. This method is used for storing a GeneralData object into Berkeley Db.

Reimplemented from FeatureData.

void TagData::writeDom ( QDomElement elem  )  [virtual]

Saves the state of this object to a dom tree. Or in other words writes out the internal data held in this class to a dom tree underneath the QDomElement elem. This method is used for exporting.

Reimplemented from GeneralData.

void TagData::readAttributes ( const QXmlAttributes attr  )  [virtual]

Loads the state of this object from QXmlAttributes.This method is used for importing.

Reimplemented from FeatureData.

void TagData::writeXml ( ostream &  stream  )  [virtual]

Reimplemented from FeatureData.

void TagData::setInfo ( const std::string &  inf  ) 

std::string TagData::getInfo (  ) 

void TagData::setScore ( const double &  s  ) 

double TagData::getScore (  ) 

FeatureGui* TagData::makeGui (  )  [inline, protected, virtual]

Implements FeatureData.

Definition at line 230 of file spatialfeaturedata.h.

00230 { return new TagGui( this ); }

FeatureInfo* TagData::makeInfo (  )  [inline, protected, virtual]

Implements FeatureData.

Definition at line 231 of file spatialfeaturedata.h.

00231 { return new TagInfo( this ); }


Member Data Documentation

std::string TagData::info [protected]

Definition at line 260 of file featuredata.h.

double TagData::score [protected]

Definition at line 261 of file featuredata.h.

Referenced by getScore(), readAttributes(), readStream(), setScore(), writeStream(), and writeXml().


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