Referência ao ficheiro src/vapiOptions.c

#include "vapiTypes.h"
#include "vapiOptions.h"
#include "vapiMemory.h"
#include "vapiAux.h"

Diagrama de dependências de inclusão para vapiOptions.c:

Ir para o código fonte deste ficheiro.

Funções

vBoolean vapiOptionsCheck (vOptionsSettings *OptionsSettings, vOptions *Options)
 Checks the options data for invalid options .
vBoolean vapiOptionsGetBooleans (vOptions *Options, int position)
 Retrieves the boolean option from the position in the Array of Booleans.
char * vapiOptionsGetChars (vOptions *Options, int position)
 Retrieves the string from the position in the Array of Strings.
int vapiOptionsGetChoices (vOptions *Options, int position)
 Retrieves the number of the choice of the list of choices in the position required in the choices' list array.
double vapiOptionsGetFloats (vOptions *Options, int position)
 Retrieves the float from the position in the Array of floats.
int vapiOptionsGetInts (vOptions *Options, int position)
 Retrieves the integer from the position in the Array of integers.
int vapiOptionsGetTimes (vOptions *Options)
 Retrieves the number of repetitions.
vOptionsvapiOptionsInit (vOptionsSettings *OptionsSettings)
 Inits an Options Data Structure with default values.
vOptionsSettingsvapiOptionsSettingsInit ()
 Initiates an Options Settings structure with the default values.
void vOptionsFree (vOptions *Options, vOptionsSettings *OptionsSettings, vOptionsFreeCustom FreeCustom)
 Frees an Options Data structure.
void vOptionsSettingsFree (vOptionsSettings *OptionsSettings, vOptionsSettingsFreeCustom FreeCustom)
 Frees the Options Settings structure.


Documentação das funções

vBoolean vapiOptionsCheck ( vOptionsSettings OptionsSettings,
vOptions Options 
)

Checks the options data for invalid options .

Retorna:
Verdadeiro caso exista algum erro.

Definido na linha 242 do ficheiro vapiOptions.c.

Referências _vOptint::defaultValue, _vOptions::ints, _vOptionsSettings::ints, _vOptionsSettings::intsNumber, _vOptint::max e _vOptint::min.

Referenciado por vapiGtkWindowIOAdd_Add(), vapiIOConfiguredListFromXML(), vapiMacroFromXML() e vIOCheckIO().

00243 {
00244 
00245         int i;
00246         if (OptionsSettings->intsNumber)
00247         {
00248                 for (i = 0; i < OptionsSettings->intsNumber; i++)
00249                 {
00250 
00251                         if (Options->ints[i] <
00252                             OptionsSettings->ints[i].min
00253                             || Options->ints[i] >
00254                             OptionsSettings->ints[i].max)
00255                         {
00256                                 Options->ints[i] =
00257                                         OptionsSettings->ints[i].defaultValue;
00258 
00259                         }
00260                 }
00261         }
00262         if (OptionsSettings->floatsNumber)
00263         {
00264                 for (i = 0; i < OptionsSettings->floatsNumber; i++)
00265                 {
00266 
00267                         if (Options->floats[i] <
00268                             OptionsSettings->floats[i].min
00269                             || Options->floats[i] >
00270                             OptionsSettings->floats[i].max)
00271                         {
00272                                 Options->floats[i] =
00273                                         OptionsSettings->floats[i].
00274                                         defaultValue;
00275 
00276                         }
00277                 }
00278         }
00279         if (OptionsSettings->charsNumber)
00280         {
00281                 for (i = 0; i < OptionsSettings->charsNumber; i++)
00282                 {
00283 
00284                         if (strlen (Options->chars[i].ch) == 0)
00285                         {
00286                                 return vTRUE;
00287 
00288                         }
00289                 }
00290         }
00291         return vFALSE;
00292 }

Here is the caller graph for this function:

vBoolean vapiOptionsGetBooleans ( vOptions Options,
int  position 
)

Retrieves the boolean option from the position in the Array of Booleans.

Parâmetros:
Options Dados das opções
position Posição no array
Retorna:
o valor verdadeiro ou falso

Definido na linha 149 do ficheiro vapiOptions.c.

Referências _vOptions::booleans, _vOptions::booleansNumber e vFALSE.

Referenciado por vapiCountObjects() e vapiSelectRegion().

00150 {
00151         if (Options->booleansNumber > 0 && position < Options->booleansNumber)
00152         {
00153                 return Options->booleans[position];
00154         }
00155         else
00156         {
00157                 return vFALSE;
00158         }
00159 }

Here is the caller graph for this function:

char * vapiOptionsGetChars ( vOptions Options,
int  position 
)

Retrieves the string from the position in the Array of Strings.

Parâmetros:
Options Option's data
position Position in the array
Retorna:
An integer for the string or character
Aviso:
The returned pointer shall not be freed
Tarefa:
this function should return NULL if the string is non existent, but the application is not ready to handle that

Definido na linha 131 do ficheiro vapiOptions.c.

Referências _vChar::ch, _vOptions::chars e _vOptions::charsNumber.

Referenciado por FileAsDigitalInput().

00132 {
00133         if (Options->charsNumber > 0 && position < Options->charsNumber)
00134         {
00135                 return Options->chars[position].ch;
00136         }
00137         else
00138         {
00139                 return " ";
00140         }
00141 }

Here is the caller graph for this function:

int vapiOptionsGetChoices ( vOptions Options,
int  position 
)

Retrieves the number of the choice of the list of choices in the position required in the choices' list array.

Parâmetros:
Options Dados das opções
position Posição no array
Retorna:
o índice da opção seleccionada

Definido na linha 167 do ficheiro vapiOptions.c.

Referências _vOptions::choices e _vOptions::choicesNumber.

Referenciado por vapiCompareFloat(), vapiCompareInt() e vapiSmooth().

00168 {
00169         if (Options->choicesNumber > 0 && position < Options->choicesNumber)
00170         {
00171                 return Options->choices[position];
00172         }
00173         else
00174         {
00175                 return 0;
00176         }
00177 }

Here is the caller graph for this function:

double vapiOptionsGetFloats ( vOptions Options,
int  position 
)

Retrieves the float from the position in the Array of floats.

Parâmetros:
Options Option's data
position Position in the array
Retorna:
The value that is in the double numbers array, at the required position

Definido na linha 110 do ficheiro vapiOptions.c.

Referências _vOptions::floats e _vOptions::floatsNumber.

Referenciado por vapiColourFilter(), vapiCompareFloat(), vapiTemplateMatch() e vapiTimerWait().

00111 {
00112         if (Options->floatsNumber > 0 && position < Options->floatsNumber)
00113         {
00114                 return Options->floats[position];
00115         }
00116         else
00117         {
00118                 return 0;
00119         }
00120 }

Here is the caller graph for this function:

int vapiOptionsGetInts ( vOptions Options,
int  position 
)

Retrieves the integer from the position in the Array of integers.

Parâmetros:
Options option's data
position Position in the array
Retorna:
The value that is in the integer numbers array, at the required position

Definido na linha 92 do ficheiro vapiOptions.c.

Referências _vOptions::ints e _vOptions::intsNumber.

Referenciado por vapiCompareFloat(), vapiCompareInt(), vapiFlip(), vapiJumpToConditional(), vapiMarkPoints(), vapiSelectRegion(), vapiSmooth() e vapiThreshold().

00093 {
00094         if (Options->intsNumber > 0 && position < Options->intsNumber)
00095         {
00096                 return Options->ints[position];
00097         }
00098         else
00099         {
00100                 return 0;
00101         }
00102 }

Here is the caller graph for this function:

int vapiOptionsGetTimes ( vOptions Options  ) 

Retrieves the number of repetitions.

Parâmetros:
Options Dados das opções
Retorna:
número de vezes que uma operação deve ser executada
Aviso:
esta função deve desaparecer, visto que se trata de uma opção custom.

Definido na linha 185 do ficheiro vapiOptions.c.

Referências _vOptions::CustomOptions e _vEffectOptions::times.

Referenciado por vapiDilate() e vapiErode().

00186 {
00187         vEffectOptions *CustomOptions = Options->CustomOptions;
00188         return CustomOptions->times;
00189 }

Here is the caller graph for this function:

vOptions * vapiOptionsInit ( vOptionsSettings OptionsSettings  ) 

Inits an Options Data Structure with default values.

Parâmetros:
OptionsSettings Options definitions

Definido na linha 11 do ficheiro vapiOptions.c.

Referências _vOptions::booleansNumber, _vOptionsSettings::booleansNumber, _vOptions::charsNumber, _vOptionsSettings::charsNumber, _vOptions::choicesNumber, _vOptionsSettings::chooseNumber, _vOptfloat::defaultValue, _vOptint::defaultValue, _vOptions::floats, _vOptionsSettings::floats, _vOptions::floatsNumber, _vOptionsSettings::floatsNumber, _vOptions::ints, _vOptionsSettings::ints, _vOptions::intsNumber e _vOptionsSettings::intsNumber.

Referenciado por vapiGtkWindowIOAdd_Add(), vapiGtkWindowIOAddSelectIO(), vapiGtkWindowIOConfiguredSaveChanges(), vapiIOConfiguredListFromXML() e vapiOperationOptionsInit().

00012 {
00013         int i;
00014         vOptions *Options = malloc (sizeof (vOptions));
00015 
00016         /*
00017          * Definir o numero de cada tipo mesmo na estrtura de opções, 
00018          * Por forma a ajudar a robustez.
00019          */
00020         Options->floatsNumber = OptionsSettings->floatsNumber;
00021         Options->intsNumber = OptionsSettings->intsNumber;
00022         Options->charsNumber = OptionsSettings->charsNumber;
00023         Options->booleansNumber = OptionsSettings->booleansNumber;
00024         Options->choicesNumber = OptionsSettings->chooseNumber;
00025 
00026 
00027         /*
00028          * Definição e alocação de espaço de acordo com as necessidades da operação.
00029          */
00030         if (OptionsSettings->floatsNumber)
00031         {
00032                 Options->floats =
00033                         malloc (OptionsSettings->floatsNumber *
00034                                 sizeof (double));
00035                 for (i = 0; i < OptionsSettings->floatsNumber; i++)
00036                 {
00037                         Options->floats[i] =
00038                                 OptionsSettings->floats[i].defaultValue;
00039                 }
00040         }
00041         if (OptionsSettings->intsNumber)
00042         {
00043                 Options->ints =
00044                         malloc (OptionsSettings->intsNumber * sizeof (int));
00045                 for (i = 0; i < OptionsSettings->intsNumber; i++)
00046                 {
00047                         Options->ints[i] =
00048                                 OptionsSettings->ints[i].defaultValue;
00049                 }
00050         }
00051 
00052         if (OptionsSettings->charsNumber)
00053         {
00054                 Options->chars =
00055                         malloc (OptionsSettings->charsNumber *
00056                                 sizeof (vChar));
00057                 for (i = 0; i < OptionsSettings->charsNumber; i++)
00058                 {
00059                         Options->chars[i].ch = "";
00060                 }
00061         }
00062         if (OptionsSettings->chooseNumber)
00063         {
00064                 Options->choices =
00065                         malloc (OptionsSettings->chooseNumber * sizeof (int));
00066                 for (i = 0; i < OptionsSettings->chooseNumber; i++)
00067                 {
00068                         Options->choices[i] =
00069                                 OptionsSettings->choose[i].defaultOption;
00070                 }
00071         }
00072         if (OptionsSettings->booleansNumber)
00073         {
00074                 Options->booleans =
00075                         malloc (OptionsSettings->booleansNumber *
00076                                 sizeof (vBoolean));
00077                 for (i = 0; i < OptionsSettings->booleansNumber; i++)
00078                 {
00079                         Options->booleans[i] =
00080                                 OptionsSettings->booleans[i].defaultValue;
00081                 }
00082         }
00083         return Options;
00084 }

Here is the caller graph for this function:

vOptionsSettings * vapiOptionsSettingsInit (  ) 

Initiates an Options Settings structure with the default values.

Definido na linha 314 do ficheiro vapiOptions.c.

Referências _vOptionsSettings::booleansNumber, _vOptionsSettings::charsNumber, _vOptionsSettings::chooseNumber, _vOptionsSettings::floatsNumber e _vOptionsSettings::intsNumber.

Referenciado por vapiCreateIO() e vapiOperationInit().

00315 {
00316         vOptionsSettings *OptionsSettings =
00317                 malloc (sizeof (vOptionsSettings));
00318         OptionsSettings->floatsNumber = 0;
00319         OptionsSettings->intsNumber = 0;
00320         OptionsSettings->charsNumber = 0;
00321         OptionsSettings->chooseNumber = 0;
00322         OptionsSettings->booleansNumber = 0;
00323         return OptionsSettings;
00324 }

Here is the caller graph for this function:

void vOptionsFree ( vOptions Options,
vOptionsSettings OptionsSettings,
vOptionsFreeCustom  FreeCustom 
)

Frees an Options Data structure.

Além de libertar a estrtura vOptions, liberta também as custom.
Parâmetros:
OptionsSettings Definições das opções
FreeCustom Função para libertar a estura que alberga os dados estendidos.

Definido na linha 197 do ficheiro vapiOptions.c.

Referências _vChar::ch, _vOptions::chars, _vOptionsSettings::charsNumber, _vOptions::floats, _vOptionsSettings::floatsNumber, _vOptions::ints, _vOptionsSettings::intsNumber e vCharFreeChar().

Referenciado por vapiGtkWindowIOAdd_Add(), vapiGtkWindowIOAddSelectIO(), vapiGtkWindowIOConfiguredSaveChanges(), vapiIOListFreeConfigured() e vOperationOptionsFree().

00199 {
00200         int i;
00201 
00202         if (OptionsSettings->floatsNumber)
00203         {
00204                 free (Options->floats);
00205         }
00206         if (OptionsSettings->intsNumber)
00207         {
00208                 free (Options->ints);
00209         }
00210         if (OptionsSettings->charsNumber)
00211         {
00212                 for (i = 0; i < OptionsSettings->charsNumber; i++)
00213                 {
00214                         if (strlen (Options->chars[i].ch) > 0)
00215                         {
00216                                 vCharFreeChar (&Options->chars[i]);
00217                         }
00218                 }
00219                 free (Options->chars);
00220         }
00221         if (OptionsSettings->chooseNumber)
00222         {
00223                 free (Options->choices);
00224         }
00225         if (OptionsSettings->booleansNumber)
00226         {
00227                 free (Options->booleans);
00228         }
00229         if (FreeCustom != NULL)
00230         {
00231                 FreeCustom (Options, OptionsSettings);
00232         }
00233         free (Options);
00234 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vOptionsSettingsFree ( vOptionsSettings OptionsSettings,
vOptionsSettingsFreeCustom  FreeCustom 
)

Frees the Options Settings structure.

Além de libertar a estrtura vOptionsSettings, liberta também a custom.
Parâmetros:
OptionsSettings Definições das opções
FreeCustom Função para libertar a estutura de estendidos.

Definido na linha 300 do ficheiro vapiOptions.c.

Referenciado por vapiFreeIO().

00302 {
00303         if (FreeCustom != NULL)
00304         {
00305                 FreeCustom (OptionsSettings);
00306         }
00307         free (OptionsSettings);
00308 
00309 }

Here is the caller graph for this function:


Gerado em Tue Jul 24 10:39:23 2007 para Vapi por  doxygen 1.5.1