00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "thirdparty/FeatureVector.h"
00024
00025 namespace cmlabs {
00026
00027 FeatureVector::FeatureVector() {
00028 i1 = i2 = 0;
00029 }
00030
00031 FeatureVector::FeatureVector(JString xml) {
00032 if (!Object::fromXML(xml)) {
00033 i1 = i2 = 0;
00034 }
00035 }
00036
00037 FeatureVector::FeatureVector(XMLNode* node) {
00038 if (!fromXML(node)) {
00039 i1 = i2 = 0;
00040 }
00041 }
00042
00043 FeatureVector::FeatureVector(int ii1, int ii2, JTime t) {
00044 i1 = ii1;
00045 i2 = ii2;
00046 time = t;
00047 }
00048
00049 FeatureVector::~FeatureVector() {}
00050
00051 Object* FeatureVector::clone() const {
00052 FeatureVector* fv = new FeatureVector();
00053 *fv = *this;
00054 return fv;
00055 }
00056
00057 JString FeatureVector::print() {
00058 return JString::format("(%d,%d) [%s] %s", i1, i2, (char*) time.printTime(), (char*) vect.print());
00059 }
00060
00061 JString FeatureVector::toXML() {
00062 return JString::format("<featurevector i1=\"%d\" i2=\"%d\">\n%s%s</featurevector>", i1, i2, (char*) time.toXML().indentXML(), (char*) vect.toXML().indentXML());
00063 }
00064
00065 bool FeatureVector::fromXML(XMLNode* node) {
00066 if (node == NULL) {
00067 return false;
00068 }
00069 if (!node->getTag().equalsIgnoreCase("featurevector"))
00070 return false;
00071
00072 i1 = node->getAttribute("i1").toInt();
00073 i2 = node->getAttribute("i2").toInt();
00074
00075 XMLNode* xmlNode = node->getChildNode("time");
00076 if (xmlNode == NULL)
00077 return false;
00078 if (!time.fromXML(xmlNode))
00079 return false;
00080
00081 xmlNode = node->getChildNode("vector");
00082 if (xmlNode == NULL)
00083 return false;
00084 if (!vect.fromXML(xmlNode))
00085 return false;
00086
00087 return true;
00088 }
00089
00090 }
00091