00001 #ifndef IDENTITY_TENTACLE_IMPLEMENTATION_FILE
00002 #define IDENTITY_TENTACLE_IMPLEMENTATION_FILE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "identity_tentacle.h"
00019 #include "identity_infoton.h"
00020 #include "octopus.h"
00021
00022 #include <basis/log_base.h>
00023 #include <data_struct/string_hash.h>
00024 #include <mechanisms/time_stamp.h>
00025
00026 #undef LOG
00027 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger(), s)
00028
00029
00030
00031
00033
00034 identity_tentacle::identity_tentacle(octopus &parent)
00035 : tentacle_helper<identity_infoton>(identity_infoton::identity_classifier(),
00036 false),
00037 _parent(parent)
00038 {}
00039
00040 identity_tentacle::~identity_tentacle() {}
00041
00042 outcome identity_tentacle::reconstitute(const string_array &classifier,
00043 byte_array &packed_form, infoton * &reformed)
00044 {
00045 if (classifier != identity_infoton::identity_classifier())
00046 return NO_HANDLER;
00047
00048 return reconstituter(classifier, packed_form, reformed,
00049 (identity_infoton *)NIL);
00050 }
00051
00052 outcome identity_tentacle::consume(infoton &to_chow,
00053 const octopus_request_id &item_id, byte_array &transformed)
00054 {
00055 FUNCDEF("consume");
00056 transformed.reset();
00057 identity_infoton *inf = dynamic_cast<identity_infoton *>(&to_chow);
00058 if (!inf) {
00059
00060
00061
00062
00063
00064
00065
00066 bool uhhh = true;
00067
00068 if (uhhh) {
00069
00070 return PARTIAL;
00071 }
00072 #ifdef DEBUG_IDENTITY_TENTACLE
00073 LOG(istring("denying infoton ") + item_id.mangled_form());
00074 #endif
00075
00076 return DISALLOWED;
00077 }
00078
00079 #ifdef DEBUG_IDENTITY_TENTACLE
00080 LOG(istring("old name, storing under: ") + item_id.mangled_form());
00081 #endif
00082
00083
00084 inf->_new_name = _parent.issue_identity();
00085
00086 #ifdef DEBUG_IDENTITY_TENTACLE
00087 LOG(istring("new name: ") + inf->_new_name.mangled_form());
00088 #endif
00089
00090 if (!store_product((infoton *)inf->clone(), item_id))
00091 return NO_SPACE;
00092 return OKAY;
00093 }
00094
00095
00096 #endif //IDENTITY_TENTACLE_IMPLEMENTATION_FILE
00097