Changeset 240

Show
Ignore:
Timestamp:
04/08/09 17:45:44 (15 years ago)
Author:
bhilburn
Message:

First pass at making cbr.h readable.

Location:
vtcross/branches/fixingCBR/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • vtcross/branches/fixingCBR/src/cognitive_engines/cbr.c

    r238 r240  
    1 // 
    2 // Case-based reasoner 
    3 // 
    4  
     1/* Virginia Tech Cognitive Radio Open Source Systems 
     2 * Virginia Tech, 2009 
     3 * 
     4 * LICENSE INFORMATION GOES HERE 
     5 */ 
     6 
     7/* TODO description of this file 
     8 */ 
     9 
     10  
    511#include <stdlib.h> 
    612#include <string.h> 
     
    1016#include "vtcross/common.h" 
    1117 
     18 
     19/* TODO this appears to get used once in this entire file, so I'm making it 
     20 * static and private to this file. Is that okay?  */ 
     21static const char *ops_str[] = {"==", "!=", ">", ">=", "<", "<="}; 
    1222 
    1323// open a database or create a database if it does not exist 
  • vtcross/branches/fixingCBR/src/include/vtcross/cbr.h

    r238 r240  
    1 // 
    2 // Case-based reasoner 
    3 // 
    4 // 
    5 // TODO REDO THIS FILE 
     1/* Virginia Tech Cognitive Radio Open Source Systems 
     2 * Virginia Tech, 2009 
     3 * 
     4 * LICENSE INFORMATION GOES HERE 
     5 */ 
     6 
     7/* TODO description of this file 
     8 */ 
    69 
    710#ifndef CBR_H 
    811#define CBR_H 
    912 
     13 
    1014#include "sqlite3.h" 
    11 //#define CBR_LEN_FILENAME 64 
    1215 
     16 
     17/* TODO 
     18 */ 
    1319#define DATABASENAME "cactus_cbr" 
    1420 
    15 typedef struct cbr_s * cbr; 
    16  
    17 const char * ops_str[] = { 
    18     "==", "!=", ">", ">=", "<", "<="}; 
    19  
    20 // create the CBR 
    21 cbr cbr_create(char * _filename, char * _tablename, char * _cols[], unsigned int _len); 
    22  
    23 // free the CBR 
    24 void cbr_free(cbr _cbr); 
    25  
    26 // print databse/table 
    27 void cbr_print(cbr _cbr); 
    28  
     21/* TODO What exactly are these?? They don't appear to ever be used in the actual 
     22 * code? 
     23 */ 
    2924#define EQ 0    // equals 
    3025#define NE 1    // not equals 
     
    3328#define LT 4    // less than 
    3429#define LE 5    // less than or equal to 
    35 int cbr_search(cbr _cbr, char *_names[], int * _ops, float *_vals, unsigned int _n, float *_retvals); 
    3630 
    37 int cbr_add_row(cbr _cbr, char *_cols[], float *_vals, unsigned int _len); 
    3831 
     32 
     33/* TODO  Please explain me. 
     34 */ 
    3935struct cbr_s { 
    4036    char filename[64]; 
     
    4440    unsigned int num_columns; 
    4541}; 
     42 
     43typedef cbr_s * cbr; 
     44 
     45/* TODO I don't think these functions do what you want them to do.  The 
     46 * cbr_create is returning an object by value, which means the object that is 
     47 * being malloc'd in the cbr_create function is effectively a memory leak, since 
     48 * you lose the reference to that memory, and instead return a copy of the data 
     49 * in that memory space. */ 
     50cbr cbr_create(char * _filename, char * _tablename, char * _cols[], \ 
     51        unsigned int _len); 
     52void cbr_free(cbr _cbr); 
     53 
     54void cbr_print(cbr _cbr); 
     55 
     56int cbr_search(cbr _cbr, char *_names[], int * _ops, float *_vals, \ 
     57        unsigned int _n, float *_retvals); 
     58 
     59int cbr_add_row(cbr _cbr, char *_cols[], float *_vals, unsigned int _len); 
    4660 
    4761 
     
    6276 
    6377 
    64 // create database 
    65 cbr cbr_create(char * _filename, char * _tablename, char * _cols[], unsigned int _len); 
    66  
    67  
    68 // free space 
    69 void cbr_free(cbr _cbr); 
    70  
    71  
    7278// print  
    7379void cbr_print(cbr _cbr); 
     
    7581 
    7682// cbr search 
    77 int cbr_search( 
    78     cbr _cbr, 
    79     char *_names[], 
    80     int * _ops, 
    81     float *_vals, 
    82     unsigned int _n, 
    83     float *_retvals); 
    84  
     83int cbr_search(cbr _cbr, char *_names[], int * _ops, float *_vals, \ 
     84        unsigned int _n, float *_retvals); 
    8585 
    8686// update a row  
    87 int cbr_update(cbr _cbr, char *_where[], char*_set[], float *_wherevals, float *_setvals,  
    88                 unsigned int _wherelen, unsigned int _setlen); 
     87int cbr_update(cbr _cbr, char *_where[], char*_set[], float *_wherevals, \ 
     88        float *_setvals, unsigned int _wherelen, unsigned int _setlen); 
    8989 
    9090// cbr add a row