00001 #ifndef TENTACLE_CLASS
00002 #define TENTACLE_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "dll_octopus.h"
00019
00020 #include <basis/byte_array.h>
00021
00022
00023 class entity_data_bin;
00024 class infoton;
00025 class octopus;
00026 class octopus_entity;
00027 class octopus_request_id;
00028 class pod_motivator;
00029 class queueton;
00030
00032
00033 class OCTOPUS_CLASS_STYLE tentacle : public virtual object_base
00034 {
00035 public:
00036 tentacle(const string_array &group_name, bool backgrounded,
00037 int motivational_rate = tentacle::DEFAULT_RATE);
00039
00045 virtual ~tentacle();
00046
00047 enum constants { DEFAULT_RATE = 40 };
00048
00049 IMPLEMENT_CLASS_NAME("tentacle");
00050
00051 const string_array &group() const;
00053
00056 bool backgrounding() const { return _backgrounded; }
00058
00059 int motivational_rate() const;
00061
00062 enum outcomes {
00063 OKAY = common::OKAY,
00064 NOT_FOUND = common::NOT_FOUND,
00065 ALREADY_EXISTS = common::EXISTING,
00066 BAD_INPUT = common::BAD_INPUT,
00067 NO_SPACE = common::NO_SPACE,
00068 GARBAGE = common::GARBAGE,
00069 DISALLOWED = common::DISALLOWED,
00070
00071 NO_HANDLER = common::NO_HANDLER,
00072 PARTIAL = common::PARTIAL,
00073 ENCRYPTION_MISMATCH = common::ENCRYPTION_MISMATCH
00075 };
00076
00077 static const char *outcome_name(const outcome &to_name);
00079
00081
00082
00083
00084 virtual outcome reconstitute(const string_array &classifier,
00085 byte_array &packed_form, infoton * &reformed) = 0;
00087
00093 virtual outcome consume(infoton &to_chow, const octopus_request_id &item_id,
00094 byte_array &transformed) = 0;
00096
00121 virtual void expunge(const octopus_entity &to_remove) = 0;
00123
00128
00129
00130 outcome enqueue(infoton *to_chow, const octopus_request_id &item_id);
00132
00138 infoton *next_request(octopus_request_id &item_id);
00140
00145 bool store_product(infoton *product, const octopus_request_id &original_id);
00147
00154
00155
00156
00157
00158 void attach_storage(entity_data_bin &storage);
00160
00163 void detach_storage();
00165
00166 void propel_arm();
00168
00169 private:
00170 string_array *_group;
00171 queueton *_pending;
00172 mutex *_input_guard;
00173 pod_motivator *_action;
00174 entity_data_bin *_products;
00175 bool _backgrounded;
00176
00177
00178 tentacle(const tentacle &);
00179 tentacle &operator =(const tentacle &);
00180 };
00181
00182 #endif
00183