#include <generaldata.h>
Inheritance diagram for GeneralData:
Public Member Functions | |
GeneralData () | |
virtual | ~GeneralData () |
virtual void | print_debug_info () |
db_recno_t | getRecno () |
void | setRecno (db_recno_t recno) |
virtual void | readAttributes (const QXmlAttributes &attr)=0 |
virtual void | writeXml (std::ostream &stream)=0 |
virtual void | readDom (QDomElement &elem) |
virtual void | writeDom (QDomElement &elem) |
virtual void | readStream (QDataStream &stream)=0 |
virtual void | writeStream (QDataStream &stream)=0 |
virtual TrDb::IndexMap | getIndexMap ()=0 |
virtual std::string | uniqueName ()=0 |
void | copy (GeneralData *other) |
Protected Attributes | |
db_recno_t | m_recno |
The function of this class is to transport data in and out of the Berkeley db backend. It is important to realize that changing values of data members of GeneralData and its subclasses will have no effect to other parts of your application before your GeneralData object has been used in the Database interface.
When you are implementing subclasses of GeneralData you will see the benifits of object orientation. You just have to serialize/unserialize the extra data members of the subclass. The parent class will have to serialize/unserialize its data members so you have to remember letting readStream() and writeStream() of your subclass call the readStream() resp. writeStream() of its parent class. Just be careful of the order of things when doing serializing and unserializing.
Right now there is a limit of 2^32 ( ca 4 billions ) of records that can be stored in the berkeley db backend for each GeneralData subclass. This limit is easy to recognize from the fact that the index type, db_recno_t, is a u_int32_t. For more information about berkeley db limits see: http://www.sleepycat.com/docs/ref/am_misc/dbsizes.html
Idea for the future to maybe implement: add hooks to GeneralData, like virtual void hookBeforeCreate(Txnid *) and virtual void hookBeforeRemove(Txnid *). Database::Creator would then call these hooks everytime a create or remove is to be done. We would now have the possibility to add substring search functionality for the dna sequence in the DnaStrData feature. We implement a new Class, SubStrData : public GeneralData that stores e.g. sequences of length 12. The DnaStrData::hookBeforeCreate(Txnid *) creates each possible 12-length-substring as records in the SubStrData. The SubStrData::getIndexMap() should return two secondary indices: one with sorting of the DnaStrData recno, and one with sorting in lexicographical order of the 12-length-substring
Definition at line 80 of file generaldata.h.
|
Definition at line 21 of file generaldata.cpp.
|
|
Definition at line 84 of file generaldata.h.
|
|
Definition at line 43 of file generaldata.cpp. References getRecno(), readStream(), setRecno(), uniqueName(), and writeStream(). Referenced by TrapperDoc::importChromat(), TrapperDoc::importMates(), and TrapperDoc::importPhd(). 00044 { 00045 if (this == other || this->uniqueName() != other->uniqueName()) { 00046 return; 00047 } 00048 QByteArray ar; 00049 QDataStream streamout( ar, IO_WriteOnly ); 00050 other->writeStream(streamout); 00051 QDataStream streamin( ar, IO_ReadOnly ); 00052 this->readStream(streamin); 00053 00054 this->setRecno( other->getRecno() ); 00055 }
|
|
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" Implemented in FeatureData, DnpData, and ReadData. Referenced by hookBeforeCreate(), and TrapperDoc::openDbs(). |
|
Returns the primary key index value of this GeneralData object. The primary key index value is unique among all stored objects of this class. But the primary key index values are not unique between different subclasses of GeneralData. The primary key indices for GeneralData and its subclasses are all implemented as primary databases of type Recno. Definition at line 38 of file generaldata.cpp. References m_recno. Referenced by TrapperView::contentsMousePressEvent(), copy(), TrapperView::findRead(), TrapperView::getInfo(), TrapperDoc::importChromat(), TrapperDoc::importPhd(), ReadData::print_debug_info(), TrapperDoc::saveExport(), TrapperView::selectAll(), TrapperView::selectBetween(), and FindMatesAlgo::start(). 00039 { 00040 return m_recno; 00041 }
|
|
Prints some info for debugging, this should be removed in release version! Reimplemented in FeatureData, and ReadData. Definition at line 86 of file generaldata.h. References uniqueName(). 00086 { std::cerr<<"No debug info for class "<<uniqueName()<<endl;}
|
|
Loads the state of this object from QXmlAttributes.This method is used for importing. Implemented in FeatureData, DnpData, DnaStrData, ChromatData, QualityData, and ReadData. Referenced by TrapperParser::startElement(). |
|
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 in FeatureData, DnpData, DnaStrData, ChromatData, QualityData, and ReadData. Definition at line 29 of file generaldata.cpp. References m_recno. Referenced by TrapperDoc::import(), ReadData::readDom(), and FeatureData::readDom(). 00030 { 00031 Q_ASSERT( elem.hasAttribute( "recno" )); 00032 QString recnoStr = elem.attribute("recno"); 00033 ulong recnoULong = recnoStr.toULong(); 00034 m_recno = static_cast< db_recno_t > ( recnoULong ); 00035 return; 00036 }
|
|
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. Implemented in FeatureData, DnpData, DnaStrData, ChromatData, QualityData, and ReadData. Referenced by copy(), TrapperView::readSelected(), and Database::setFromDbt(). |
|
Set the primary key index value of this GeneralData object. Definition at line 97 of file generaldata.h. References m_recno. Referenced by MAl::commit_seq_to_db(), copy(), Destroyer::destroy(), and MoveAlgo::start(). 00097 { m_recno = recno; }
|
|
Specifies a name that uniquely should identify this class. It will be used for lookups in the GeneralMaker class. Implemented in DnpData, DnaStrData, ChromatData, QualityData, and ReadData. Referenced by copy(), print_debug_info(), and FeatureData::writeXml(). |
|
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 in FeatureData, DnpData, DnaStrData, ChromatData, QualityData, and ReadData. Definition at line 24 of file generaldata.cpp. References m_recno. Referenced by ReadData::writeDom(), and FeatureData::writeDom(). 00025 { 00026 elem.setAttribute("recno",m_recno); 00027 }
|
|
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. Implemented in FeatureData, DnpData, DnaStrData, ChromatData, QualityData, and ReadData. Referenced by copy(). |
|
Writes the state of this object to a stream as an XML entry. This method is used for exporting Implemented in ReadData. |
|
Definition at line 151 of file generaldata.h. Referenced by getRecno(), readDom(), setRecno(), and writeDom(). |