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

ExampleSpec.h

Go to the documentation of this file.
00001 #ifndef EXAMPLESPECH
00002 #define EXAMPLESPECH
00003 
00021 #include <stdio.h>
00022 #include "../util/lists.h"
00023 
00024 typedef enum { asIgnore, 
00025                asContinuous,
00026                asDiscreteNamed,
00027                asDiscreteNoName } AttributeSpecType;
00028 
00029 typedef struct _AttributeSpec_ {
00030    AttributeSpecType type;
00031    char *attributeName;
00032 
00033    int numDiscreteValues;
00034    VoidAListPtr attributeValues;
00035 } AttributeSpec, *AttributeSpecPtr;
00036 
00037 /*************************/
00038 /* construction routines */
00039 /*************************/
00040 AttributeSpecPtr AttributeSpecNew(void);
00041 void AttributeSpecFree(AttributeSpecPtr as);
00042 void AttributeSpecSetType(AttributeSpecPtr as, AttributeSpecType type);
00043 void AttributeSpecSetName(AttributeSpecPtr as, char *name);
00044    /* Set name takes the memory of the name over, but check */
00045 void AttributeSpecSetNumValues(AttributeSpecPtr as, int num);
00046 void AttributeSpecAddValue(AttributeSpecPtr as, char *value);
00047 
00048 /*************************/
00049 /* Accessor routines     */
00050 /*************************/
00051 //AttributeSpecType AttributeSpecGetType(AttributeSpecPtr as);
00052 #define AttributeSpecGetType(as) (as->type)
00053 
00054 
00055 //int AttributeSpecGetNumValues(AttributeSpecPtr as);
00056 #define AttributeSpecGetNumValues(as) \
00057    (((AttributeSpecPtr)as)->numDiscreteValues)
00058 
00059 int AttributeSpecGetNumAssignedValues(AttributeSpecPtr as);
00060 char *AttributeSpecGetName(AttributeSpecPtr as);
00061 //char *AttributeSpecGetValueName(AttributeSpecPtr as, int index);
00062 #define AttributeSpecGetValueName(as, index) \
00063             (VALIndex(as->attributeValues, index))
00064 
00065 int AttributeSpecLookupName(AttributeSpecPtr as, char *name);
00066 
00067 /*************************/
00068 /* Display routines      */
00069 /*************************/
00070 void AttributeSpecWrite(AttributeSpecPtr as, FILE *out);
00071 
00072 
00074 typedef struct _ExampleSpec_ {
00075    VoidAListPtr classes;
00076    VoidAListPtr attributes;
00077 } ExampleSpec, *ExampleSpecPtr;
00078 
00079 /*************************/
00080 /* construction routines */
00081 /*************************/
00082 
00091 ExampleSpecPtr ExampleSpecNew(void);
00092 
00099 void ExampleSpecFree(ExampleSpecPtr es);
00100 
00112 void ExampleSpecAddClass(ExampleSpecPtr es, char *className);
00113 
00114 void ExampleSpecAddAttributeSpec(ExampleSpecPtr es, AttributeSpecPtr as);
00115   /* NOTE AddAttributeSpec is not part of the external interface. */
00116   /*  it is only for internal library use. */
00117 
00128 int ExampleSpecAddDiscreteAttribute(ExampleSpecPtr es, char *name);
00129 
00130 
00141 int ExampleSpecAddContinuousAttribute(ExampleSpecPtr es, char *name);
00142 
00155 void ExampleSpecAddAttributeValue(ExampleSpecPtr es, int attNum, char *name);
00156 
00157 
00158 
00176 ExampleSpecPtr ExampleSpecRead(char *fileName);
00177 void ExampleSpecIgnoreAttribute(ExampleSpecPtr es, int num);
00178 
00179 /*************************/
00180 /* Accessor routines     */
00181 /*************************/
00182 
00189 int ExampleSpecGetNumAttributes(ExampleSpecPtr es);
00190 
00191 
00204 //AttributeSpecType ExampleSpecGetAttributeType(ExampleSpecPtr es, int num);
00205 #define ExampleSpecGetAttributeType(es, num) \
00206    ( AttributeSpecGetType(((AttributeSpecPtr)VALIndex(es->attributes, num))) )
00207 
00208 
00214 int ExampleSpecIsAttributeDiscrete(ExampleSpecPtr es, int num);
00215 
00221 int ExampleSpecIsAttributeContinuous(ExampleSpecPtr es, int num);
00222 
00227 int ExampleSpecIsAttributeIgnored(ExampleSpecPtr es, int num);
00228 
00235 //int ExampleSpecGetAttributeValueCount(ExampleSpecPtr es, int attNum);
00236 #define ExampleSpecGetAttributeValueCount(es, attNum) \
00237   ( AttributeSpecGetNumValues(((AttributeSpecPtr)VALIndex(es->attributes, attNum))) )
00238 
00239 
00240 int ExampleSpecGetAssignedAttributesValueCount(ExampleSpecPtr es, int attNum);
00241 /* GetAssignedValueCount is only needed internally for I/O */
00242 
00244 char *ExampleSpecGetAttributeName(ExampleSpecPtr es, int attNum);
00245 
00246 //char *ExampleSpecGetAttributeValueName(ExampleSpecPtr es,
00247 //                                       int attNum, int valNum);
00248 
00255 #define ExampleSpecGetAttributeValueName(es, attNum, valNum) \
00256       ( (char *)AttributeSpecGetValueName(((AttributeSpecPtr)VALIndex(es->attributes, attNum)), valNum) )
00257 
00264 int ExampleSpecLookupAttributeName(ExampleSpecPtr es, char *valName);
00265 
00272 int ExampleSpecLookupAttributeValueName(ExampleSpecPtr es, int attNum,
00273                                    char *valName);
00274 
00276 int ExampleSpecLookupClassName(ExampleSpecPtr es, char *name);
00277 
00279 char *ExampleSpecGetClassValueName(ExampleSpecPtr es, int classNum);
00280 
00286 int ExampleSpecGetNumClasses(ExampleSpecPtr es);
00287 
00288 /*************************/
00289 /* Display routines      */
00290 /*************************/
00291 
00301 void ExampleSpecWrite(ExampleSpecPtr es, FILE *out);
00302 
00303 #endif /* EXAMPLESPECH */

Generated for VFML by doxygen hosted by SourceForge.net Logo