00001 /* 00002 * dsim_value.h 00003 * DSimEngine2 00004 * 00005 * Created by David Wilson on 3/16/09. 00006 * Copyright 2009 Princeton Satellite Systems. All rights reserved. 00007 * 00008 */ 00009 00010 #ifndef __DSIM_VALUE__ 00011 #define __DSIM_VALUE__ 00012 #include <MatrixLib/MatrixLib.h> 00013 #include <SDManip/SDManip.h> 00014 00015 class dsim_variable; 00016 class dsim_connection; 00017 00027 class dsim_value 00028 { 00029 public: 00031 dsim_value(); 00033 dsim_value(const dsim_value &base); 00035 dsim_value(int type,void *ptr); 00037 dsim_value(int value); 00039 dsim_value(double value); 00041 dsim_value(const ml_matrix &value); 00043 dsim_value(const char *value); 00044 ~dsim_value(); 00045 00047 dsim_value &operator=(const dsim_value &base); 00048 00050 bool valid() const; 00051 00055 int type() const { return _type; } 00059 void *raw_value() const { return _ptr; } 00060 00062 int int_value() const; 00064 double double_value() const; 00066 ml_matrix matrix_value() const; 00068 const char *string_value() const; 00069 00070 dsim_value &capture(); 00071 bool is_captured() const { return _owned; } 00072 00073 char *write_string() const; 00074 00075 private: 00076 dsim_value(sd_data_type_manager *tm,int type,sd_type_record *type_rec,void *ptr); 00077 dsim_value(sd_data_type_manager *tm,int type); 00078 bool parse_string(const char *str); 00079 sd_data_type_manager *_tm; 00080 int _type; 00081 sd_type_record *_type_rec; 00082 void *_ptr; 00083 bool _owned; 00084 friend class dsim_variable; 00085 friend class dsim_connection; 00086 }; 00087 00088 #endif