infoton.h
Go to the documentation of this file.00001 #ifndef INFOTON_CLASS
00002 #define INFOTON_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <basis/contracts.h>
00019 #include <structures/string_array.h>
00020
00021 namespace octopi {
00022
00024
00028 class infoton
00029 : public virtual basis::packable,
00030 public virtual basis::clonable,
00031 public virtual basis::text_formable
00032 {
00033 public:
00034 infoton(const structures::string_array &classifier);
00036
00042
00043 infoton(const basis::astring &class_1);
00044 infoton(const basis::astring &class_1, const basis::astring &class_2);
00045 infoton(const basis::astring &class_1, const basis::astring &class_2, const basis::astring &cl_3);
00046
00047 infoton(const infoton &to_copy);
00049
00052 virtual ~infoton();
00053
00054 DEFINE_CLASS_NAME("infoton");
00055
00056 infoton &operator =(const infoton &to_copy);
00058
00060 const structures::string_array &classifier() const;
00062
00069 void set_classifier(const structures::string_array &new_classifier);
00071
00074
00075
00076 void set_classifier(const basis::astring &class_1);
00077 void set_classifier(const basis::astring &class_1, const basis::astring &class_2);
00078 void set_classifier(const basis::astring &class_1, const basis::astring &class_2,
00079 const basis::astring &cl_3);
00080
00081 bool check_classifier(const basis::astring &class_name, const basis::astring &caller);
00083
00086 virtual void pack(basis::byte_array &packed_form) const = 0;
00088
00090 virtual bool unpack(basis::byte_array &packed_form) = 0;
00092
00095 virtual void text_form(basis::base_string &state_fill) const = 0;
00097
00098 virtual clonable *clone() const = 0;
00100
00101 virtual int packed_size() const = 0;
00103
00107
00108 virtual basis::astring text_form() const { basis::astring fill; text_form(fill); return fill; }
00109
00111
00112
00113
00114
00115
00116 static void fast_pack(basis::byte_array &packed_form, const infoton &to_pack);
00118
00119 static bool fast_unpack(basis::byte_array &packed_form, structures::string_array &classifier,
00120 basis::byte_array &info);
00122
00125 static bool test_fast_unpack(const basis::byte_array &packed_form,
00126 int &packed_length);
00128
00135 static int fast_pack_overhead(const structures::string_array &classifier);
00137
00142 private:
00143 structures::string_array *_classifier;
00144 };
00145
00147
00149
00150 template <class contents>
00151 basis::clonable *cloner(const contents &this_obj) { return new contents(this_obj); }
00152
00153 }
00154
00155 #endif
00156