Main Page | Modules | Data Structures | File List | Globals | Related Pages

Example.h

Go to the documentation of this file.
00001 #ifndef EXAMPLEH
00002 #define EXAMPLEH
00003 
00007 #include "ExampleSpec.h"
00008 #include "../util/lists.h"
00009 
00023 typedef union {
00024    short discreteValue;
00025    float continuousValue;
00026 } AttributeValue;
00027 
00028 typedef enum {
00029    Discrete,
00030    Continuous
00031 } AttributeType;
00032 
00037 typedef struct _Example_ {
00038    int myclass;
00039    ExampleSpecPtr spec;
00040 
00041    VoidAListPtr attributes;
00042 } Example, *ExamplePtr;
00043 
00044 /*************************/
00045 /* construction routines */
00046 /*************************/
00047 
00056 ExamplePtr ExampleNew(ExampleSpecPtr es);
00057 ExamplePtr ExampleNewInitUnknown(ExampleSpecPtr es);
00058 
00059 
00061 void ExampleFree(ExamplePtr e);
00062 
00064 ExamplePtr ExampleClone(ExamplePtr e);
00065 
00070 void ExampleSetAttributeUnknown(ExamplePtr e, int attNum);
00071 
00072 
00081 void ExampleSetDiscreteAttributeValue(ExamplePtr e, int attNum, int value);
00082 
00090 void ExampleSetContinuousAttributeValue(ExamplePtr e, int attNum, double value);
00091 
00098 void ExampleSetClass(ExamplePtr e, int theClass);
00099 
00100 
00102 void ExampleSetClassUnknown(ExamplePtr e);
00103 
00117 void ExampleAddNoise(ExamplePtr e, float p, int doClass, int attrib);
00118 
00134 ExamplePtr ExampleRead(FILE *file, ExampleSpecPtr es);
00135 
00142 VoidListPtr ExamplesRead(FILE *file, ExampleSpecPtr es);
00143 
00144 /*************************/
00145 /* Accessor routines     */
00146 /*************************/
00147 
00152 int ExampleIsAttributeDiscrete(ExamplePtr e, int attNum);
00153 
00158 int ExampleIsAttributeContinuous(ExamplePtr e, int attNum);
00159 
00160 //int ExampleIsAttributeUnknown(ExamplePtr e, int attNum);
00165 #define ExampleIsAttributeUnknown(e, attNum) \
00166    ( VALIndex(e->attributes, attNum) == 0 )
00167 
00168 //int ExampleGetNumAttributes(ExamplePtr e);
00174 #define ExampleGetNumAttributes(e) \
00175   (VALLength(((ExamplePtr)e)->attributes))
00176 
00185 int ExampleGetDiscreteAttributeValue(ExamplePtr e, int attNum);
00186 
00195 double ExampleGetContinuousAttributeValue(ExamplePtr e, int attNum);
00196 
00197 //inline int ExampleGetDiscreteAttributeValueUnsafe(ExamplePtr e, int attNum) {
00198 //    return ((AttributeValue *)VALIndex(e->attributes, attNum))->discreteValue;
00199 //}
00200 
00201 #define ExampleGetDiscreteAttributeValueUnsafe(e,attNum) \
00202    (((AttributeValue *)VALIndex((e)->attributes, (attNum)))->discreteValue)
00203 
00204 
00205 //int ExampleGetClass(ExamplePtr e);
00211 #define ExampleGetClass(e) \
00212      (((ExamplePtr)e)->myclass)
00213 
00216 int ExampleIsClassUnknown(ExamplePtr e);
00217 
00222 float ExampleDistance(ExamplePtr e, ExamplePtr dst);
00223 
00224 /*************************/
00225 /* Display routines      */
00226 /*************************/
00227 
00236 void ExampleWrite(ExamplePtr e, FILE *out);
00237 
00238 #endif 

Generated for VFML by doxygen hosted by SourceForge.net Logo