octopus.h

Go to the documentation of this file.
00001 #ifndef OCTOPUS_CLASS
00002 #define OCTOPUS_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : octopus                                                           *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2001-$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 
00022 // forward.
00023 class entity_data_bin;
00024 class filter_list;
00025 class infoton;
00026 class modula_oblongata;
00027 class octopus_entity;
00028 class octopus_request_id;
00029 class chaos;
00030 class safe_roller;
00031 class string_set;
00032 class tentacle;
00033 class time_stamp;
00034 
00036 
00046 class OCTOPUS_CLASS_STYLE octopus : public virtual object_base
00047 {
00048 public:
00049   octopus(const istring &name, int max_size_per_entity);
00051 
00057   virtual ~octopus();
00058 
00059   IMPLEMENT_CLASS_NAME("octopus");
00060 
00061   const istring &name() const;
00063 
00064   // tentacle management functions...
00065 
00066   outcome add_tentacle(tentacle *to_add, bool filter = false);
00068 
00078   outcome remove_tentacle(const string_array &group_name, tentacle * &free_me);
00080 
00085   outcome zap_tentacle(const string_array &group_name);
00087 
00088   // entity management methods...
00089 
00090   octopus_entity issue_identity();
00092 
00096   void expunge(const octopus_entity &to_remove);
00098 
00101   entity_data_bin &responses();
00103 
00105   // main functionality: restoring infotons, evaluating requests and
00106   // locating responses.
00107 
00108   outcome restore(const string_array &classifier, byte_array &packed_form,
00109           infoton * &reformed);
00111 
00115   outcome evaluate(infoton *request, const octopus_request_id &item_id,
00116           bool now = false);
00118 
00132   infoton *acquire_result(const octopus_entity &requester,
00133           octopus_request_id &original_id);
00135 
00141   infoton *acquire_specific_result(const octopus_request_id &original_id);
00143 
00146 
00147 
00148   // tentacle accessors: careful with these--you must always unlock after
00149   // you have locked.
00150 
00151   tentacle *lock_tentacle(const string_array &tentacle_name);
00153 
00156   void unlock_tentacle(tentacle *to_unlock);
00158 
00161   void lock_tentacles();
00163 
00164   // the following are only valid if the tentacle list is locked.
00165   int locked_tentacle_count();  
00166   tentacle *locked_get_tentacle(int indy);  
00167   void unlock_tentacles();  
00168 
00170 
00171   // used internally; don't mess with externally.
00172 
00173   void periodic_cleaning();
00175 
00176 private:
00177   istring *_name;  
00178   modula_oblongata *_tentacles;  
00179   mutex *_molock;  
00180   entity_data_bin *_responses;  
00181   int _disallow_removals;
00183 
00185   time_stamp *_next_cleaning;  
00186   mutex *_clean_lock;  
00187   filter_list *_filters;  
00188   safe_roller *_sequencer;  
00189   chaos *_rando;  
00190 
00191   // not accessible.
00192   octopus(const octopus &);
00193   octopus &operator =(const octopus &);
00194 };
00195 
00196 #endif
00197 

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