00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __DSIM_VARIABLE_RECORD_H__
00011 #define __DSIM_VARIABLE_RECORD_H__
00012
00013 #include <SDManip/SDManip.h>
00014 #include <set>
00015 #include <map>
00016 #include "dsim_variable.h"
00017 class dsim_simulation;
00018 class dsim_integrator;
00019
00020 class dsim_variable_record
00021 {
00022 public:
00023 dsim_variable_record(dsim_simulation *sim,dsim_variable::dsim_variable_usage usage,const char *val_name,int data_type,void *init_value,int rows,int cols,const char *units,const char *description);
00024 ~dsim_variable_record();
00025
00026 void increment(dsim_variable *val);
00027 void decrement(dsim_variable *val);
00028
00029 inline const char *name() const { return _name; };
00030 inline const char *units() const { return _units; };
00031 inline const char *description() const { return _description; };
00032 inline bool exported() const { return _exported; };
00033 inline int nominal_rows() const { return _rows; };
00034 inline int nominal_columns() const { return _cols; };
00035
00036 dsim_variable value(bool force_writable);
00037
00038 void set_attribute(const char *name,const char *value);
00039 bool has_attribute(const std::string &name);
00040 std::string get_attribute(const std::string &name);
00041 std::map<std::string,std::string>::iterator attribute_iterator();
00042 std::map<std::string,std::string>::iterator end_attribute_iterator();
00043
00044 void start_integration();
00045 void finish_integration();
00046
00047 private:
00048
00049 sd_data_type_manager *_tm;
00050 int _type;
00051 sd_type_record *_type_rec;
00052 void *_ptr;
00053 void *_cointeg_ptr;
00054 void *_deriv;
00055
00056 void *base_ptr() { return _ptr; }
00057 void *cointeg_ptr() { return (_is_integrating&&_cointeg_ptr)?_cointeg_ptr:_ptr; }
00058
00059
00060 char *_name;
00061 char *_units;
00062 char *_description;
00063 int _rows;
00064 int _cols;
00065 dsim_variable::dsim_variable_usage _usage;
00066 bool _exported;
00067 bool _telemetry;
00068 bool _command;
00069 bool _changed;
00070 bool _is_integrating;
00071
00072
00073 std::map<std::string,std::string> attributes;
00074
00075
00076 std::set<dsim_variable *> subscribers;
00077
00078
00079 void *_integration_ptr;
00080
00081 friend class dsim_variable;
00082 friend class dsim_integrator;
00083 };
00084
00085 #endif