Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / tt / slib / mp_s_pattern.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
24 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
25 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
26 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
27 /*%%  $XConsortium: mp_s_pattern.h /main/3 1995/10/23 11:57:50 rswiston $                                                        */
28 /* -*-C++-*-
29  *
30  * @(#)mp_s_pattern.h   1.7 29 Jul 1993
31  *
32  * Tool Talk Message Passer (MP) - mp_s_pattern.h
33  * 
34  * Copyright (c) 1990, 1992 by Sun Microsystems, Inc.
35  * 
36  * This file implements the server side of the _Tt_pattern object.
37  */
38
39 #ifndef _MP_S_PATTERN_H
40 #define _MP_S_PATTERN_H
41
42 #include "mp/mp_pattern.h"
43 #include "mp/mp_arg_utils.h"
44 #include "mp_ptype_utils.h"
45 #include "mp_s_pattern_utils.h"
46 #include "mp_signature_utils.h"
47
48 class _Tt_msg_trace;
49 class _Tt_s_message;
50
51 class _Tt_s_pattern : public _Tt_pattern {
52       public:
53         _Tt_s_pattern();
54         _Tt_s_pattern(const _Tt_signature_ptr &sig);
55         virtual ~_Tt_s_pattern();
56
57         int                     match(
58                                         const _Tt_s_message        &m,
59                                         const _Tt_msg_trace        &trace
60                                 ) const;
61         Tt_status               add_arg(const _Tt_arg_ptr &arg);
62         Tt_status               join_context(const _Tt_msg_context &context);
63         Tt_status               quit_context(const _Tt_msg_context &context);
64         _Tt_ptype_ptr           &generating_ptype(); // ptype it was generated
65                                                      // by declaring
66         _Tt_ptype_ptr           &generating_ptype(_Tt_ptype_ptr &pt); // set it
67         int                     is_from_ptype(); // true if generated by
68                                                  // declaring a ptype
69         unsigned int            timestamp() const
70                                         { return _timestamp; }
71         void                    set_timestamp(unsigned int stamp)
72                                         { _timestamp = stamp; }
73
74       protected:
75         // server-only methods that aid in matching patterns and
76         // messages. 
77         int                     match_field(
78                                         int                         val,
79                                         const _Tt_int_rec_list_ptr &pvals,
80                                         int                        &tm,
81                                         const _Tt_msg_trace        &trace,
82                                         const char                 *failure_note
83                                 ) const;
84         int                     match_field(
85                                         const _Tt_string           &val,
86                                         const _Tt_string_list_ptr  &pvals,
87                                         int                        &tm,
88                                         const _Tt_msg_trace        &trace,
89                                         const char                 *failure_note
90                                 ) const;
91         int                     match_scopes(
92                                         const _Tt_message          &m,
93                                         int                        &tm,
94                                         const _Tt_msg_trace        &trace
95                                 ) const;
96         int                     match_args(
97                                         const _Tt_message          &m,
98                                         int                        &tm,
99                                         const _Tt_msg_trace        &trace
100                                 ) const;
101         int                     match_contexts(
102                                         const _Tt_message          &m,
103                                         int                        &tm,
104                                         const _Tt_msg_trace        &trace
105                                 ) const;
106       private:
107         _Tt_ptype_ptr           _generating_ptype;
108         unsigned int            _timestamp;
109
110         friend class            _Tt_mp;
111         friend class            _Tt_message;
112 };
113 #include "mp_s_pattern_inlines.h"
114
115 #endif                          /* _MP_S_PATTERN_H */