00001 #ifndef CROMPISH_PAX_GROUP
00002 #define CROMPISH_PAX_GROUP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <basis/chaos.h>
00023 #include <basis/string_array.h>
00024 #include <cromp/cromp_transaction.h>
00025 #include <geometric/screen_rectangle.h>
00026 #include <octopus/infoton.h>
00027 #include <octopus/tentacle_helper.h>
00028
00029 using namespace geometric;
00030
00031 class bubble : public infoton
00032 {
00033 public:
00034 bubble(int data_segment_size = 0, const screen_rectangle &boundaries
00035 = screen_rectangle(), int color = 0)
00036
00037
00038
00039 : infoton(bubble_classing()), _data()
00040 { reset(data_segment_size, boundaries, color); }
00041
00042 const string_array &bubble_classing() {
00043 static istring bubbs[2] = { "bubble", "rubble" };
00044 static string_array barray(2, bubbs);
00045 return barray;
00046 }
00047
00048 void reset(int data_segment_size, const screen_rectangle &boundaries,
00049 int color) {
00050 _color = color;
00051 _bounds = boundaries;
00052 _data.reset(data_segment_size);
00053 }
00054
00055 int data_length() const { return _data.length(); }
00056
00057 clonable *clone() const { return cloner<bubble>(*this); }
00058
00059 byte_array &data() { return _data; }
00060
00061 int non_data_overhead() const { return packed_size() - _data.length(); }
00062
00063 virtual void pack(byte_array &packed_form) const {
00064 basis::attach(packed_form, _color);
00065 _bounds.pack(packed_form);
00066 basis::attach(packed_form, _data);
00067 }
00068
00069 int packed_size() const {
00070 return _data.length() + 2 * sizeof(int)
00071 + sizeof(int)
00072 + 4 * sizeof(int);
00073 }
00074
00075 virtual bool unpack(byte_array &packed_form) {
00076 if (!basis::detach(packed_form, _color)) return false;
00077 if (!_bounds.unpack(packed_form)) return false;
00078 if (!basis::detach(packed_form, _data)) return false;
00079 return true;
00080 }
00081
00082 private:
00083 screen_rectangle _bounds;
00084 int _color;
00085 byte_array _data;
00086 };
00087
00089
00090 class bubbles_tentacle : public tentacle_helper<bubble>
00091 {
00092 public:
00093 bubbles_tentacle(bool backgrounded)
00094 : tentacle_helper<bubble>(bubble().classifier(), backgrounded)
00095 {}
00096 };
00097
00098 #endif
00099