00001 #ifndef BUFFER_KEY_CLASS 00002 #define BUFFER_KEY_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : buffer_key * 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 "dll_buffers.h" 00019 00020 #include <data_struct/unique_id.h> 00021 00022 class buffer_id : public unique_int 00023 { 00024 public: 00025 buffer_id(int initial = 0) : unique_int(initial) {} 00026 }; 00027 00029 00031 00039 class BUFFERS_CLASS_STYLE buffer_key 00040 { 00041 public: 00042 // the "connection" should always be unique on a per program basis (in that 00043 // there is only one connection referred to by that identifier within this 00044 // application) and the "msg_id" should always be unique within that 00045 // connection's buffers. the "buffer_id" should be unique within this 00046 // program also, and should be sufficient to find the buffer (once the id 00047 // is set) from anywhere the buffer might be needed in this program. 00048 00049 buffer_id buff_id; 00050 int connection; 00051 int msg_id; 00052 00053 buffer_key(buffer_id buff = buffer_id(), int conn = 0, int msg = 0) 00054 : buff_id(buff), connection(conn), msg_id(msg) {} 00055 00056 istring text_form() const; 00058 00059 // these comparators allow keys to be related to each other. 00060 bool identical(const buffer_key &to_compare) const; 00062 bool same_buffer_id(const buffer_key &to_compare) const; 00064 bool same_connection(const buffer_key &to_compare) const; 00066 bool same_connection_and_message(const buffer_key &to_compare) const; 00068 }; 00069 00070 #endif 00071
1.5.1