infoton.h

Go to the documentation of this file.
00001 #ifndef INFOTON_CLASS
00002 #define INFOTON_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : infoton                                                           *
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 
00018 #include "dll_octopus.h"
00019 
00020 #include <basis/object_base.h>
00021 #include <basis/packable.h>
00022 
00024 
00028 class OCTOPUS_CLASS_STYLE infoton
00029 : public packable, public clonable, public virtual object_base
00030 {
00031 public:
00032   infoton(const string_array &classifier);
00034 
00040   // takes care of the most common cases of 1, 2 & 3 level classifiers.
00041   infoton(const istring &class_1);
00042   infoton(const istring &class_1, const istring &class_2);
00043   infoton(const istring &class_1, const istring &class_2, const istring &cl_3);
00044 
00045   infoton(const infoton &to_copy);
00047 
00050   virtual ~infoton();
00051 
00052   IMPLEMENT_CLASS_NAME("infoton");
00053 
00054   infoton &operator =(const infoton &to_copy);
00056 
00058   const string_array &classifier() const;
00060 
00067   void set_classifier(const string_array &new_classifier);
00069 
00072   // these are also dangerous if you're not careful; they mimic the
00073   // string constructors.
00074   void set_classifier(const istring &class_1);
00075   void set_classifier(const istring &class_1, const istring &class_2);
00076   void set_classifier(const istring &class_1, const istring &class_2,
00077           const istring &cl_3);
00078 
00079   bool check_classifier(const istring &class_name, const istring &caller);
00081 
00084   virtual void pack(byte_array &packed_form) const = 0;
00086 
00088   virtual bool unpack(byte_array &packed_form) = 0;
00090 
00093   virtual clonable *clone() const = 0;
00095 
00096   virtual int packed_size() const = 0;
00098 
00102 
00103 
00104   // This defines the wire format for a flattened infoton.  It is in essence
00105   // a packet header format which all infotons must adhere to to ensure that
00106   // they can be successfully unflattened when appropriate item managers are
00107   // available.
00108   static void fast_pack(byte_array &packed_form, const infoton &to_pack);
00110 
00111   static bool fast_unpack(byte_array &packed_form, string_array &classifier,
00112           byte_array &info);
00114 
00117   static bool test_fast_unpack(const byte_array &packed_form,
00118           int &packed_length);
00120 
00127   static int fast_pack_overhead(const string_array &classifier);
00129 
00134 private:
00135   string_array *_classifier;  
00136 };
00137 
00139 
00141 
00142 template <class contents>
00143 clonable *cloner(const contents &this_obj) { return new contents(this_obj); }
00144 
00145 #endif
00146 

Generated on Thu Nov 20 04:29:01 2008 for HOOPLE Libraries by  doxygen 1.5.1