![]() |
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 00004 #ifndef __PARAMETER_H 00005 #define __PARAMETER_H 00006 00007 #include <string> 00008 #include <stdarg.h> 00009 00010 #include <dolfin/constants.h> 00011 #include <dolfin/FunctionPointer.h> 00012 #include <dolfin/VFunctionPointer.h> 00013 #include <dolfin/BCFunctionPointer.h> 00014 #include <dolfin/utils.h> 00015 00016 #define PARAMETER_IDENTIFIER_LENGTH 128 00017 00018 using std::string; 00019 00020 namespace dolfin { 00021 00022 // A small class for internal use in Settings 00023 class Parameter{ 00024 public: 00025 00026 enum Type { REAL, INT, BOOL, STRING, FUNCTION, VFUNCTION, BCFUNCTION, NONE }; 00027 00028 Parameter(); 00029 Parameter(Type type, const char *identifier, va_list aptr); 00030 00031 ~Parameter(); 00032 00033 void clear(); 00034 00035 void set(Type type, const char *identifier, va_list aptr); 00036 void set(const char *identifier, va_list aptr); 00037 void get(va_list aptr); 00038 00039 bool matches(const char* identifier); 00040 bool matches(string identifier); 00041 bool changed(); 00042 00043 void operator= (const Parameter &p); 00044 00045 // Needed for ShortList 00046 void operator= (int zero); 00047 bool operator! () const; 00048 00049 // Type cast, enable assignment to type from Parameter 00050 operator real() const; 00051 operator int() const; 00052 operator unsigned int() const; 00053 operator bool() const; 00054 operator string() const; 00055 operator const char*() const; 00056 operator function() const; 00057 operator vfunction() const; 00058 operator bcfunction() const; 00059 00060 // Friends 00061 friend class XMLFile; 00062 00063 // Output 00064 friend LogStream& dolfin::operator<<(LogStream& stream, const Parameter& p); 00065 00066 private: 00067 00068 // A description of the parameter 00069 string identifier; 00070 00071 // Values 00072 real val_real; 00073 int val_int; 00074 bool val_bool; 00075 string val_string; 00076 function val_function; 00077 vfunction val_vfunction; 00078 bcfunction val_bcfunction; 00079 00080 // True iff the default value was changed 00081 bool _changed; 00082 00083 // Type of data 00084 Type type; 00085 00086 }; 00087 00088 } 00089 00090 #endif
![]()
Documentation automatically generated with Doxygen on 10 Sep 2004.