XML interface for Signal. More...
#include <XMLSignal.h>
Public Member Functions | |
Signal * | signal () const |
virtual const QString & | xml_tagName () const |
XMLSignal () | |
XMLSignal (Signal *sig) | |
~XMLSignal () | |
Static Public Attributes | |
static const QString | xmlSignalTag = "Signal" |
Protected Member Functions | |
virtual XMLMember | xml_member (XML_MEMBER_ARGS) |
virtual bool | xml_setBinaryData (XML_SETBINARYDATA_ARGS) |
virtual bool | xml_setProperty (XML_SETPROPERTY_ARGS) |
virtual void | xml_writeBinaryData (XML_WRITEBINARYDATA_ARGS) const |
virtual void | xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const |
XML interface for Signal.
Storage for signals in XML stream is either a reference to signal inside a database, or a full record of signal data (including samples). The first option is used only when the XML stream is created from a existing and not modified database (on a permanent storage).
GeopsyCore::XMLSignal::XMLSignal | ( | Signal * | sig | ) |
GeopsyCore::XMLSignal::~XMLSignal | ( | ) | [inline] |
{}
Signal * GeopsyCore::XMLSignal::signal | ( | ) | const |
References GeopsyCore::SignalDB::signal(), and TRACE.
Referenced by GeopsyCore::XMLSubSignalPool::subPool(), and GeopsyGui::SignalLayer::xml_polishChild().
XMLMember GeopsyCore::XMLSignal::xml_member | ( | XML_MEMBER_ARGS | ) | [protected, virtual] |
Re-implement this function to offer XML restore (children and properties) support to your class.
From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:
Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):
static const QString tmp("childrenName"); XMLRestoreAttributeIterator it=map.find(tmp); if(it!=map.end()) { // found attribute "childrenName" }
If the map of attributes is not used:
Q_UNUSED(attributes); if(tag=="x1") return XMLMember(0); else if(tag=="y1") return XMLMember(1); else if(tag=="x2") return XMLMember(2); else if(tag=="y2") return XMLMember(3); else return XMLMember(XMLMember::Unknown);
Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.
if(tag=="anInteger") return XMLMember(0); else if(tag=="aString") return XMLMember(1); else if(tag=="aDouble") return XMLMember(2); return AbstractLine::xml_member(tag, attributes, context)+3;
For the arguments of this function use Macro XML_MEMBER_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
References GeopsyCore::GeopsyCoreEngine::currentDB(), GeopsyCore::geopsyCore, TRACE, and GeopsyCore::Signal::xml_member().
{ TRACE; Q_UNUSED(attributes); if(tag=="database") return XMLMember(0); else if(tag=="id") return XMLMember(1); else { if(!_sig) _sig=new Signal(geopsyCore->currentDB()); return _sig->xml_member(tag, attributes, context)+4; } }
bool GeopsyCore::XMLSignal::xml_setBinaryData | ( | XML_SETBINARYDATA_ARGS | ) | [protected, virtual] |
This function must be re-implemented in all classes dealing with binary data that cannot be saved in an ASCII xml file (e.g. due to the amount of data).
See also xml_writeBinaryData().
The difference between xml_setBinaryData() and xml_setBinaryData200410() is detected by the type of tag at the beginning of each block if it can be read with QString ==> 200510, else try with a normal C string, if it match the current tag then execute xml_setBinaryData200411().
See also xml_setBinaryData200411() to maintain compatibility with previous versions of xml storages.
For the arguments of this function use Macro XML_SETBINARYDATA_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
References LOCK_SAMPLES, GeopsyCore::SignalTemplate< sampleType >::nSamples(), TRACE, and UNLOCK_SAMPLES.
{ TRACE; Q_UNUSED(context); if(!_database) { if(_sig->nSamples()>0) { LOCK_SAMPLES(double, samples, _sig) s.readRawData(( char * ) samples, sizeof(double) * _sig->nSamples()); UNLOCK_SAMPLES(_sig) } } return true; }
bool GeopsyCore::XMLSignal::xml_setProperty | ( | XML_SETPROPERTY_ARGS | ) | [protected, virtual] |
Re-implement this function to offer XML restore properties support to your class.
From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).
For a general case:
Q_UNUSED(attributes); double val=content.toDouble(); switch (memberID) { case 0: _x1=val; return true; case 1: _y1=val; return true; case 2: _x2=val; return true; case 3: _y2=val; return true; default: return false; }
For classes inheriting other classes (see also xml_member())
switch (memberID) { case 0: _anInteger=content.toString(); return true; case 1: _aString=content.toInt(); return true; case 2: _aDouble=content.toDouble(); return true; default: return AbstractLine::xml_setProperty(memberID-3, map, content);
For the arguments of this function use Macro XML_SETPROPERTY_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
References GeopsyCore::GeopsyCoreEngine::database(), GeopsyCore::geopsyCore, TRACE, and GeopsyCore::Signal::xml_setProperty().
{ TRACE; Q_UNUSED(attributes); switch (memberID) { case 0: _database=geopsyCore->database(content.toString()); if(_database) return true; else return false; case 1: _id=content.toInt(); return true; default: if(_sig) { return _sig->xml_setProperty(memberID-4, tag, attributes, content, context); } return false; } }
virtual const QString& GeopsyCore::XMLSignal::xml_tagName | ( | ) | const [inline, virtual] |
Implements QGpCoreTools::XMLClass.
{return xmlSignalTag;}
void GeopsyCore::XMLSignal::xml_writeBinaryData | ( | XML_WRITEBINARYDATA_ARGS | ) | const [protected, virtual] |
This function must be re-implemented in all classes dealing with binary data that cannot be saved in an ASCII xml file (e.g. due to the amount of data).
The way binary data is stored drastically changed in November 2006 with the introduction of tar.gz structures for xml files. Each class willing to store binary data can automatically generate a new file (with an automatic file name) in the .tar.gz structure by sending bytes to s.
See also xml_setBinaryData().
For the arguments of this function use Macro XML_WRITEBINARYDATA_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
References CONST_LOCK_SAMPLES, GeopsyCore::Signal::database(), GeopsyCore::SignalDB::exists(), GeopsyCore::Signal::file(), GeopsyCore::SignalDB::isModified(), GeopsyCore::SignalTemplate< sampleType >::nSamples(), TRACE, and UNLOCK_SAMPLES.
{ TRACE; Q_UNUSED(context); if(!_sig) return; if( !_sig->file() || !_sig->database()->exists() || _sig->database()->isModified()) { CONST_LOCK_SAMPLES(double, samples, _sig) s.writeRawData(( const char * ) samples, sizeof(double) * _sig->nSamples()); UNLOCK_SAMPLES(_sig) } }
void GeopsyCore::XMLSignal::xml_writeProperties | ( | XML_WRITEPROPERTIES_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References GeopsyCore::Signal::database(), GeopsyCore::SignalDB::exists(), GeopsyCore::Signal::file(), GeopsyCore::SignalFile::format(), GeopsyCore::SignalFileFormat::id(), GeopsyCore::Signal::id(), GeopsyCore::SignalDB::isModified(), GeopsyCore::SignalDB::name(), GeopsyCore::SignalFileFormat::Temporary, TRACE, QGpCoreTools::XMLClass::writeBinaryData(), QGpCoreTools::XMLClass::writeProperty(), and GeopsyCore::Signal::xml_writeProperties().
{ TRACE; if(!_sig) return; if(_sig->file() && _sig->file()->format().id()!=SignalFileFormat::Temporary && _sig->database()->exists() && !_sig->database()->isModified()) { writeProperty(s, "database", _sig->database()->name()); writeProperty(s, "id", _sig->id()); } else { _sig->xml_writeProperties(s, context); writeBinaryData(s, context); } }
const QString GeopsyCore::XMLSignal::xmlSignalTag = "Signal" [static] |
Referenced by GeopsyCore::XMLSubSignalPool::xml_member().