Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

variable.c

Go to the documentation of this file.
00001 #include "variable.h"
00002 
00003 #include "error.h"
00004 #include "defines.h"
00005 
00006 #include <stdlib.h>
00007 #include <string.h>
00008 
00009 
00021 void NewVariable(unsigned int type,char *name,Tvariable *v)
00022 {
00023   v->type=type;
00024 
00025   NEW(v->name,strlen(name)+1,char);
00026   strcpy(v->name,name);
00027 
00028   NewInterval(-INF,INF,&(v->is)); /*default range for the variable*/
00029 }
00030 
00031 
00032 void CopyVariable(Tvariable *v_dst,Tvariable *v_src)
00033 {
00034   v_dst->type=v_src->type;
00035 
00036   NEW(v_dst->name,strlen(v_src->name)+1,char);
00037   strcpy(v_dst->name,v_src->name);
00038 
00039   CopyInterval(&(v_dst->is),&(v_src->is));
00040 }
00041 
00042 unsigned int GetVariableType(Tvariable *v)
00043 {
00044   return(v->type);
00045 }
00046 
00047 char *GetVariableName(Tvariable *v)
00048 {
00049   return(v->name);
00050 }
00051 
00052 void SetVariableInterval(Tinterval *i,Tvariable *v)
00053 { 
00054   CopyInterval(&(v->is),i);
00055 }
00056 
00057 Tinterval *GetVariableInterval(Tvariable *v)
00058 {
00059   return(&(v->is));
00060 }
00061 
00062 void PrintVariable(FILE *f,Tvariable *v)
00063 {
00064   PRINT_VARIABLE_NAME(f,v->name);
00065   fprintf(f," : ");
00066   PrintInterval(f,&(v->is));
00067   fprintf(f,"\n");
00068 }
00069 
00070 void DeleteVariable(Tvariable *v)
00071 {
00072   free(v->name);
00073 }