Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Search  

/home/mrm/Simex/src/se_message.h

Go to the documentation of this file.
00001 #ifndef Se_Message_Included
00002 #define Se_Message_Included
00003 
00004 #include "se_ipc.h"
00005 #include "se_data_vector.h"
00006 #include "se_data.h"
00007 #include "se_sim_data_vector.h"
00008 #include "se_sim_data.h"
00009 
00010 namespace Se{
00011 
00012 /*declarations*/
00013 
00014 class Message{
00015 
00016  public:
00017 
00018   /*****************
00019    *Enumerations
00020    *****************/
00021 
00022   enum Task{READ=1,
00023             WRITE=2};
00024   
00025   enum Type{UNDEFINED=3,
00026             SIMULATION_INFO=4,
00027             START=5,
00028             STEP=6,
00029             STEPN=7,
00030             STOP=8,
00031             RESET=9,
00032             SHOW=10,
00033             HIDE=11,
00034             EXEC=12,
00035             SIMULATION_DATA=13,
00036             CHANGE_DOUBLE_DATA=14};
00037 
00038  protected:
00039   
00040   /**************
00041    *Members
00042    **************/
00043 
00044   struct Ipc::msg_buf *msgb;
00045   int position;           //position = size in write mode
00046   int size;
00047   Type type;
00048   Task task;
00049   static const int Max_Size=Ipc::Max_Msg_Size;
00050   static const int Size_Incr=1000;
00051 
00052   /************************
00053    *Set and get variables
00054    ************************/
00055   /*TODO: Those functions should be used only by the pop and push functions*/
00056   /*TODO: Should use memcpy*/
00057   void set_variable(void *var, int size);
00058   void get_variable(void *var,int the_size);
00059 
00060   /**************************
00061    *Pop and push functions
00062    **************************/
00063   /*TODO: those functions should use set_variable and get_variable*/
00064   int pop_int();
00065   double pop_double();
00066   char *pop_string(int length);
00067   void pop_doubles(double *table,int table_size);
00068 
00069   void push_int(int i);
00070   void push_double(double d);
00071   void push_string(const char *the_string,int the_size);
00072   void push_string(String name);
00073   void push_doubles(double *table,int table_size);
00074   void push_data(Data *data);
00075   void push_data_vector(Data_Vector *data_vector);
00076   void push_data_descr(Data *data);
00077   void push_data_vector_descr(Data_Vector *data_vector);
00078 
00079  public:
00080  
00081   /*********************
00082    *Constructors
00083    *********************/
00084   Message(Task the_task);
00085 
00086   /******************************
00087    *Send and receive
00088    ******************************/
00089 
00090  protected:
00091   void send(int msq_id);
00092 
00093  public:
00094   void receive(int id);
00095 
00096  public:
00097   
00098   /*Composition of messages: write and read*/
00099   /*TODO: Those functions should be deleted*/
00100   /*
00101   void write(Type type);
00102   void write_simulation_info(int sim_id,int key);
00103   void write_data_vector_descr(Data_Vector *my_variables);
00104   void write_data_descr(Data *my_variable);
00105   void write_simulation_data(int sim_id);
00106   void write_data_vector(Data_Vector *my_data);
00107   void write_data(Data *my_data);
00108   void read_simulation_id(int *id);
00109   void read_simulation_data_vector(Data_Vector *the_data);
00110   Data *read_data(Data_Vector *the_data_vector);
00111   */
00112   /*till here*/
00113 
00114   /***************************************
00115    *Compose, send and read orders
00116    ***************************************/
00117   /*TODO: Those functions should not use get_variable and set_variable*/
00118   /*TODO: those functions should exusively use send and the pop and push
00119    *functions*/
00120   void send_order_step_n(int msq_id,int n);
00121   void send_order_simulation_info(int msq_id,int sim_id,int slave_msq_key,
00122                                   Data_Vector *my_variables);
00123   void send_order_simulation_data(int msq_id,int sim_id,
00124                                   Data_Vector *my_variables);
00125   void send_order_simple(int msq_id,
00126                          Message::Type type);
00127   void send_order_change_double_data(int msq_id,
00128                                      String name,
00129                                      double value);
00130 
00131   /************************/
00132 
00133   void read_order_step_n(int *n);
00134   /*read_order_simulation_info is in se_gtk_message.h*/
00135   /*read_order_simulation_data is in se_gtk_message.h*/
00136   /*TODO: todel*/
00137   void read_order_change_double_data(String *name,
00138                                      double *value);
00139   /*till here*/
00140   void read_order_change_double_data(Sim_Data_Vector *data_vector);
00141 
00142   /*********************
00143    *Get
00144    *********************/
00145  protected:
00146   int get_size();
00147  public:
00148   Type get_type();
00149 
00150   /********************
00151    *Print
00152    ********************/
00153   void print();
00154 };
00155 
00156 }
00157 #endif

Generated on Sat Jul 19 04:01:28 2003 for SIMEX by doxygen1.2.18