00001 /***************************** License ********************************** 00002 00003 Copyright (C) 2008 by Communicative Machines 00004 http://www.cmlabs.com All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 ************************************************************************/ 00021 00022 00023 // CVML.h: CVML related classes 00024 // 00025 ////////////////////////////////////////////////////////////////////// 00026 00027 #if !defined(__CVML_H__) 00028 #define __CVML_H__ 00029 00030 #include "Collections.h" 00031 #include "XMLParser.h" 00032 #include "MathClasses.h" 00033 00034 namespace cmlabs { 00035 00036 class CVMLHypothesis : public Object 00037 { 00038 public: 00039 CVMLHypothesis(); 00040 CVMLHypothesis(JString xml); 00041 CVMLHypothesis(XMLNode* node); 00042 virtual ~CVMLHypothesis(); 00043 00044 Object* clone() const; 00045 00046 JString id; 00047 JString previous; 00048 double evaluation; 00049 Dictionary parameters; 00050 Dictionary evaluations; 00051 00052 bool setID(JString newID); 00053 bool setPrevious(JString prev); 00054 bool setEvaluation(double eval); 00055 bool setLabel(JString label, JString value, double eval); 00056 00057 JString getID(); 00058 JString getPrevious(); 00059 double getEvaluation(); 00060 Collection getLabels(); 00061 JString getLabelValue(JString label); 00062 double getLabelEval(JString label); 00063 00064 JString print() ; 00065 JString toXML() ; 00066 bool fromXML(XMLNode* node); 00067 }; 00068 00069 00070 00071 00072 00073 00074 class CVMLObjectBase : public Object 00075 { 00076 public: 00077 CVMLObjectBase(); 00078 CVMLObjectBase(JString xml); 00079 CVMLObjectBase(XMLNode* node); 00080 virtual ~CVMLObjectBase(); 00081 00082 Object* clone() const; 00083 00084 JString id; 00085 JString type; 00086 JString appearance; 00087 Box box; 00088 ObjectDictionary hypotheses; 00089 Dictionary features; 00090 Collection members; 00091 00092 virtual bool setID(JString newID); 00093 virtual bool setBox(Box b); 00094 virtual bool setBox(double x, double y, double w, double h, double orientation); 00095 virtual bool setAppearance(JString appear); 00096 virtual bool addHypothesis(CVMLHypothesis* hyp); 00097 virtual bool addFeature(JString featurename, JString content); 00098 00099 virtual JString getID(); 00100 virtual Box getBox(); 00101 virtual JString getAppearance(); 00102 virtual CVMLHypothesis* getHypothesis(JString hypID); 00103 virtual Collection getHypothesesIDs(); 00104 virtual Dictionary getFeatureList(); 00105 00106 virtual JString print() ; 00107 virtual JString toXML() ; 00108 virtual bool fromXML(XMLNode* node); 00109 }; 00110 00111 00112 00113 00114 00115 class CVMLObject : public CVMLObjectBase 00116 { 00117 public: 00118 CVMLObject(); 00119 CVMLObject(JString xml); 00120 CVMLObject(XMLNode* node); 00121 virtual ~CVMLObject(); 00122 }; 00123 00124 00125 00126 00127 00128 00129 00130 class CVMLGroup : public CVMLObjectBase 00131 { 00132 public: 00133 CVMLGroup(); 00134 CVMLGroup(JString xml); 00135 CVMLGroup(XMLNode* node); 00136 virtual ~CVMLGroup(); 00137 00138 bool addMember(JString id); 00139 Collection getMembers(); 00140 }; 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 class CVMLFrame : public Object 00155 { 00156 public: 00157 CVMLFrame(); 00158 CVMLFrame(JString xml); 00159 CVMLFrame(XMLNode* node); 00160 virtual ~CVMLFrame(); 00161 00162 Object* clone() const; 00163 00164 JString id; 00165 ObjectDictionary objects; 00166 ObjectDictionary groups; 00167 00168 bool addObject(CVMLObject* object); 00169 bool addGroup(CVMLGroup* group); 00170 bool removeObject(JString id); 00171 bool removeGroup(JString id); 00172 00173 JString print() ; 00174 JString toXML() ; 00175 bool fromXML(XMLNode* node); 00176 }; 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 class CVMLDataSet : public Object 00188 { 00189 public: 00190 CVMLDataSet(); 00191 CVMLDataSet(JString xml); 00192 CVMLDataSet(XMLNode* node); 00193 virtual ~CVMLDataSet(); 00194 00195 Object* clone() const; 00196 00197 JString name; 00198 ObjectDictionary frames; 00199 00200 bool addFrame(CVMLFrame* frame); 00201 bool removeFrame(JString id); 00202 00203 int getCount(); 00204 00205 JString print() ; 00206 JString toXML() ; 00207 bool fromXML(XMLNode* node); 00208 bool unitTest(int max); 00209 }; 00210 00211 00212 } // namespace cmlabs 00213 00214 00215 #endif // !defined(__CVML_H__)