ubit
umessage.hpp
1 /************************************************************************
2  *
3  * umessage.hpp: Ubit Inter-Client Messages: see umservice.hpp
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _umessage_hpp_
18 #define _umessage_hpp_
19 #include <map>
20 #include <string>
21 #include <ubit/uelem.hpp>
22 #include <ubit/uattr.hpp>
23 namespace ubit {
24 
27 class UMessage {
28 public:
29  static void send(UHardwinImpl&, const char* message);
30  static void send(UHardwinImpl&, const UStr& message);
31 };
32 
33 /* ==================================================== ====== ======= */
36 class UMessagePort : public UElem {
37 public:
38  UMessagePort(const UStr& name);
39  const UStr& getName() {return name;}
40  const UStr& getValue() {return value;}
41 
42 private:
43  friend class UMessagePortMap;
44  UStr name, value;
45 };
46 
47 /* ==================================================== ====== ======= */
51 public:
52  UMessagePort& getMessagePort(const UStr& name);
53  UMessagePort* findMessagePort(const UStr& name);
54  void fireMessagePort(const char* data);
55 
56 private:
57  struct Comp {
58  bool operator()(const UStr* s1, const UStr* s2) const
59  {return s1->compare(*s2) < 0;}
60  };
61  typedef std::map<const UStr*, UMessagePort*, Comp> MessMap;
62  MessMap mess_map;
63  void _fireMessagePort(UMessageEvent&, const char* buf);
64 };
65 
66 }
67 #endif
68 /* ==================================================== [TheEnd] ======= */
69 /* ==================================================== [(c)Elc] ======= */
70 
Ubit Message.
Definition: umessage.hpp:27
Impl.
Definition: umessage.hpp:50
lightweight general purpose container.
Definition: uelem.hpp:44
Ubit Message Port.
Definition: umessage.hpp:36
Definition: uhardfont.hpp:31
Definition: uwinImpl.hpp:84
virtual int compare(const char *, bool ignore_case=false) const
compare strings lexicographically, ignores case if last argument is true.
Ubit String.
Definition: ustr.hpp:72
Ubit Message events.
Definition: uevent.hpp:462