/usr/include/ga/GAParameter.h is in libga-dev 2.4.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | // $Header$
/* ----------------------------------------------------------------------------
parameters.h
mbwall 14jul95
Copyright (c) 1995 Massachusetts Institute of Technology
all rights reserved
DESCRIPTION:
Header for the parameters object used by the GA objects.
---------------------------------------------------------------------------- */
#ifndef _ga_parameters_h_
#define _ga_parameters_h_
#include <ga/gaconfig.h>
#include <ga/gatypes.h>
#include <ga/std_stream.h>
/* ----------------------------------------------------------------------------
This object is used for naming the parameters. We associate a fullname, a
short name, and a value with each parameter.
---------------------------------------------------------------------------- */
class GAParameter {
public:
enum Type {BOOLEAN, CHAR, STRING, INT, FLOAT, DOUBLE, POINTER};
public:
GAParameter(const char* fn, const char* sn, Type tp, const void* v);
GAParameter(const GAParameter& orig);
GAParameter& operator=(const GAParameter& orig){ copy(orig); return *this; }
virtual ~GAParameter();
void copy(const GAParameter&);
char* fullname() const { return fname; }
char* shrtname() const { return sname; }
const void* value() const
{ return (t==STRING ? val.sval : (t==POINTER ? val.pval : &val)); }
const void* value(const void* v)
{setvalue(v); return(t==STRING ? val.sval : (t==POINTER ? val.pval:&val));}
Type type() const { return t; }
protected:
char* fname;
char* sname;
union Value {
int ival;
char cval;
char* sval;
float fval;
double dval;
const void* pval;
} val;
Type t;
void setvalue(const void*);
};
/* ----------------------------------------------------------------------------
The parameter list is implemented as an array, but has the interface of a
list. Don't ask. You can traverse through the list to get the parameters that
you need. Be sure to check the type before you try to extract the value for
any specific parameter in the list.
---------------------------------------------------------------------------- */
class GAParameterList {
public:
GAParameterList();
GAParameterList(const GAParameterList&);
GAParameterList& operator=(const GAParameterList&);
virtual ~GAParameterList();
int size() const { return n; }
int get(const char*, void*) const;
int set(const char*, const void*);
int set(const char* s, int v) { return set(s, (void*)&v); }
int set(const char* s, unsigned int v) { return set(s, (void*)&v); }
int set(const char* s, char v) { return set(s, (void*)&v); }
int set(const char* s, const char* v) { return set(s, (void*)v); }
int set(const char* s, double v);
int add(const char*, const char*, GAParameter::Type, const void*);
int remove();
GAParameter& operator[](unsigned int i) const {return *(p[i]);}
GAParameter& next(){return *(p[((cur > n) ? cur=0 : ++cur)]);}
GAParameter& prev(){return *(p[((cur == 0) ? cur=n-1 : --cur)]);}
GAParameter& current() const {return *(p[cur]);}
GAParameter& first(){return *(p[cur=0]);}
GAParameter& last(){return *(p[cur=n-1]);}
GAParameter* operator()(const char* name);
int parse(int& argc, char **argv, GABoolean flag=gaTrue);
#ifdef GALIB_USE_STREAMS
int write(const char* filename) const;
int write(STD_OSTREAM & os) const;
int read(const char* filename, GABoolean flag=gaTrue);
int read(STD_ISTREAM & is, GABoolean flag=gaTrue);
#endif
protected:
unsigned int n, N, cur;
GAParameter **p;
};
#ifdef GALIB_USE_STREAMS
inline STD_OSTREAM & operator<< (STD_OSTREAM &os, const GAParameterList& plist)
{ plist.write(os); return os; }
inline STD_ISTREAM & operator>> (STD_ISTREAM& is, GAParameterList& plist)
{ plist.read(is); return is; }
#endif
#endif
|