00001 #ifndef CONTRACTS_GROUP 00002 #define CONTRACTS_GROUP 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : contracts * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 1989-$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 00022 #include "outcome.h" 00023 00024 namespace basis { 00025 00026 // forward declarations. 00027 class base_string; 00028 00030 00032 00033 class attribute : public virtual root_object 00034 { 00035 public: 00036 virtual const root_object &get() const = 0; 00037 virtual void set(const root_object &new_value) = 0; 00038 }; 00039 00041 00043 class equalizable : public virtual root_object 00044 { 00045 public: 00046 virtual bool equal_to(const equalizable &s2) const = 0; 00048 virtual bool operator == (const equalizable &s2) const { return equal_to(s2); } 00050 }; 00051 00053 00055 00056 class orderable : public virtual equalizable 00057 { 00058 public: 00059 virtual bool less_than(const orderable &s2) const = 0; 00061 virtual bool operator < (const orderable &s2) const { return less_than(s2); } 00063 }; 00064 00066 00068 00069 class base_logger : public virtual root_object 00070 { 00071 public: 00072 virtual outcome log(const base_string &info, int filter) = 0; 00074 00076 }; 00077 00079 00081 #define DEFINE_FILTER(NAME, CURRENT_VALUE, INFO_STRING) NAME = CURRENT_VALUE 00082 00084 enum root_logging_filters { 00085 DEFINE_FILTER(NEVER_PRINT, -1, "This diagnostic entry should be dropped and never seen"), 00086 DEFINE_FILTER(ALWAYS_PRINT, 0, "This diagnostic entry will always be shown or recorded") 00087 }; 00088 00090 00092 00097 class base_synchronizer : public virtual root_object 00098 { 00099 public: 00100 virtual void establish_lock() = 0; 00101 virtual void repeal_lock() = 0; 00102 }; 00103 00105 00107 00108 class clonable : public virtual root_object 00109 { 00110 public: 00111 virtual clonable *clone() const = 0; 00112 }; 00113 00115 00117 00122 class nameable : public virtual root_object 00123 { 00124 public: 00125 virtual const char *class_name() const = 0; 00127 00131 }; 00132 00134 00136 00141 class text_formable : public virtual nameable 00142 { 00143 public: 00144 virtual const char *class_name() const = 0; // forwarded requirement from nameable. 00145 00146 virtual void text_form(base_string &state_fill) const = 0; 00148 00150 }; 00151 00153 00155 00160 class hoople_standard : public virtual text_formable, public virtual equalizable 00161 { 00162 public: 00163 // this is a union class and has no extra behavior beyond its bases. 00164 }; 00165 00167 00169 00170 class text_streamable : public virtual nameable 00171 { 00172 public: 00173 virtual bool produce(base_string &target) const = 0; 00175 00179 virtual bool consume(const base_string &source) = 0; 00181 00183 }; 00184 00185 } //namespace. 00186 00187 #endif 00188
1.6.3