00001 #ifndef TENTACLE_HELPER_CLASS
00002 #define TENTACLE_HELPER_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00030 #include "infoton.h"
00031 #include "tentacle.h"
00032
00033 #include <basis/byte_array.h>
00034
00036
00039 template <class contents>
00040 outcome reconstituter(const string_array &classifier, byte_array &packed_form,
00041 infoton * &reformed, contents *formal(junk))
00042 {
00043 contents *inf = new contents;
00044 if (!inf->unpack(packed_form)) {
00045 WHACK(inf);
00046 return tentacle::GARBAGE;
00047 }
00048 reformed = inf;
00049 reformed->set_classifier(classifier);
00050 return tentacle::OKAY;
00051 }
00052
00054
00056
00061 template <class contents>
00062 class tentacle_helper : public tentacle
00063 {
00064 public:
00065 tentacle_helper(const string_array &classifier, bool backgrounded,
00066 int motivational_rate = tentacle::DEFAULT_RATE)
00067 : tentacle(classifier, backgrounded, motivational_rate) {}
00068
00069 virtual ~tentacle_helper() {}
00071
00073 virtual outcome reconstitute(const string_array &classifier,
00074 byte_array &packed_form, infoton * &reformed) {
00075 return reconstituter(classifier, packed_form, reformed,
00076 (contents *)NIL);
00077 }
00078
00080
00085 virtual outcome consume(infoton &formal(to_chow),
00086 const octopus_request_id &formal(item_id), byte_array &transformed)
00087 { transformed.reset(); return NO_HANDLER; }
00088
00089 virtual void expunge(const octopus_entity &formal(to_remove)) {}
00091 };
00092
00093 #endif
00094