packable_tree.h

Go to the documentation of this file.
00001 #ifndef PACKABLE_TREE_CLASS
00002 #define PACKABLE_TREE_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : packable_tree                                                     *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1992-$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 "tree.h"
00019 
00020 #include <basis/packable.h>
00021 
00022 namespace nodes {
00023 
00024 // forward.
00025 class packable_tree_factory;
00026 
00028 
00029 class packable_tree : public tree, public packable
00030 {
00031 public:
00032   packable_tree();
00034 
00035   virtual ~packable_tree();
00037 
00038   void recursive_pack(byte_array &packed_form) const;
00040   
00041   static packable_tree *recursive_unpack(byte_array &packed_form,
00042            packable_tree_factory &creator);
00044 
00047   // these pack and unpack methods must be implemented by the derived tree.
00048 
00049   virtual void pack(byte_array &packed_form) const = 0;
00051 
00052   virtual bool unpack(byte_array &packed_form) = 0;
00054 
00055 private:
00056   static void packit(byte_array &packed_form,
00057           const packable_tree *current_node);
00058 };
00059 
00061 
00062 class packable_tree_factory
00063 {
00064 public:
00065   virtual ~packable_tree_factory();
00066   virtual packable_tree *create() = 0;
00068 
00070 };
00071 
00072 } // namespace.
00073 
00074 #endif
00075 

Generated on Fri Nov 28 04:29:17 2008 for HOOPLE Libraries by  doxygen 1.5.1