00001 /* ==================================================== ======== ======= * 00002 * 00003 * umessage.hpp 00004 * Ubit Project 00005 * Author: Eric Lecolinet 00006 * Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs 00007 * (C) 1999-2006 / EricLecolinet / ENST Paris / http://www.enst.fr/~elc/ubit 00008 * 00009 * *********************************************************************** 00010 * COPYRIGHT NOTICE : 00011 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 00012 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 00013 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 00014 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 00015 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION. 00016 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS. 00017 * *********************************************************************** 00018 * ==================================================== [(c)Elc] ======= * 00019 * ==================================================== ======== ======= */ 00020 00021 #ifndef _umessage_hpp_ 00022 #define _umessage_hpp_ 00023 //pragma ident "@(#)umessage.hpp ubit:05.05.00" 00024 #include <map> 00025 #include <string> 00026 #include <ubit/uprop.hpp> 00027 namespace ubit { 00028 00029 /* ==================================================== ====== ======= */ 00032 class UMessage { 00033 public: 00034 static void send(UNatWin&, const char* message); 00035 static void send(UNatWin&, const UStr& message); 00036 }; 00037 00038 /* ==================================================== ====== ======= */ 00041 class UMessagePort : public UGroup { 00042 public: 00043 UMessagePort(const UStr& name); 00044 const UStr& getName() {return name;} 00045 const UStr& getValue() {return value;} 00046 00047 private: 00048 friend class UMessagePortMap; 00049 UStr name, value; 00050 }; 00051 00052 /* ==================================================== ====== ======= */ 00055 class UMessagePortMap { 00056 public: 00057 UMessagePort& getMessagePort(const UStr& name); 00058 UMessagePort* findMessagePort(const UStr& name); 00059 void fireMessagePort(UEvent&); 00060 void fireMessagePort(const char* data); 00061 00062 private: 00063 struct Comp { 00064 bool operator()(const UStr* s1, const UStr* s2) const 00065 {return s1->compare(*s2) < 0;} 00066 }; 00067 typedef std::map<const UStr*, UMessagePort*, Comp> MessMap; 00068 MessMap mess_map; 00069 void _fireMessagePort(UEvent& e, const char* buf); 00070 }; 00071 00072 } 00073 #endif 00074 /* ==================================================== [TheEnd] ======= */ 00075 /* ==================================================== [(c)Elc] ======= */ 00076