00001 #ifndef ENTITY_DEFINITIONS_GROUP
00002 #define ENTITY_DEFINITIONS_GROUP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "dll_octopus.h"
00019 #include "infoton.h"
00020
00021 #include <basis/byte_array.h>
00022 #include <basis/istring.h>
00023 #include <basis/set.cpp>
00024 #include <data_struct/amorph.h>
00025 #include <data_struct/unique_id.h>
00026 #include <mechanisms/time_stamp.h>
00027
00029
00033 class OCTOPUS_CLASS_STYLE octopus_entity : public packable
00034 {
00035 public:
00036 octopus_entity();
00037
00038 octopus_entity(const istring &hostname, int process_id, int sequencer,
00039 int add_in);
00041
00045 octopus_entity(const octopus_entity &to_copy);
00046
00047 ~octopus_entity();
00048
00049 octopus_entity &operator = (const octopus_entity &to_copy);
00050
00051 bool blank() const;
00053
00054
00055 bool operator == (const octopus_entity &that) const;
00056 bool operator != (const octopus_entity &that) const
00057 { return ! (*this == that); }
00058
00059 istring hostname() const;
00060 int process_id() const;
00061 int sequencer() const;
00062 int add_in() const;
00063
00064 void hostname(const istring &new_host);
00065 void process_id(int id);
00066 void sequencer(int seq);
00067 void add_in(int add);
00068
00069 istring mangled_form() const;
00071
00072 istring text_form() const;
00074
00075 inline istring to_text() const { return mangled_form(); }
00077 static octopus_entity from_text(const istring &to_convert);
00079
00080 static void breakout(const istring &mangled_form, istring &hostname,
00081 int &process_id, int &sequencer, int &add_in);
00083
00084 int packed_size() const;
00086
00087 virtual void pack(byte_array &packed_form) const;
00088 virtual bool unpack(byte_array &packed_form);
00089
00090 private:
00091 istring *_hostname;
00092 int _pid;
00093 int _sequencer;
00094 int _add_in;
00095 };
00096
00098
00100
00108 class OCTOPUS_CLASS_STYLE octopus_request_id : public packable
00109 {
00110 public:
00111 octopus_entity _entity;
00112 int _request_num;
00113
00114 inline octopus_request_id() : _entity(), _request_num(0) {}
00115
00116 inline octopus_request_id(const octopus_entity &entity, int request_num)
00117 : _entity(entity), _request_num(request_num) {}
00118
00119 static octopus_request_id randomized_id();
00121
00124 inline bool operator == (const octopus_request_id &that) const
00125 { return (_entity == that._entity)
00126 && (_request_num == that._request_num); }
00127 inline bool operator != (const octopus_request_id &that) const
00128 { return (_entity != that._entity)
00129 || (_request_num != that._request_num); }
00130
00131 bool blank() const;
00133
00134 int packed_size() const;
00136
00137 istring mangled_form() const;
00138
00139 istring text_form() const;
00140
00141 inline istring to_text() const { return mangled_form(); }
00142 static octopus_request_id from_text(const istring &to_convert);
00143
00144 virtual void pack(byte_array &packed_form) const;
00145 virtual bool unpack(byte_array &packed_form);
00146 };
00147
00149 class octopus_request_id_set : public basis::set<octopus_request_id>
00150 {
00151 public:
00152 octopus_request_id_set() {}
00153
00154 octopus_request_id_set(const basis::set<octopus_request_id> &orig)
00155 : basis::set<octopus_request_id>(orig) {}
00156 };
00157
00159
00161
00163 class infoton_id_pair
00164 {
00165 public:
00166 infoton *_data;
00167 octopus_request_id _id;
00168
00169 infoton_id_pair(infoton *data, const octopus_request_id &id)
00170 : _data(data), _id(id) {}
00171
00172 ~infoton_id_pair() {
00173 delete _data;
00174 _data = NIL;
00175 }
00176 };
00177
00179 class infoton_list : public amorph<infoton_id_pair> {};
00180
00181 #endif
00182