tentacle_helper.h

Go to the documentation of this file.
00001 #ifndef TENTACLE_HELPER_CLASS
00002 #define TENTACLE_HELPER_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : tentacle_helper                                                   *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2002-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
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 

Generated on Fri Nov 21 04:29:52 2008 for HOOPLE Libraries by  doxygen 1.5.1