added lwes-filter-listener
[lwes.git] / src / lwes_event_type_db.h
blob633048fd280ec134a49210c6e91fb14b6778b394
1 /*======================================================================*
2 * Copyright (C) 2008 Light Weight Event System *
3 * All rights reserved. *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301 USA. *
19 *======================================================================*/
20 #ifndef __LWES_EVENT_TYPE_DB
21 #define __LWES_EVENT_TYPE_DB
23 #include "lwes_types.h"
25 #include <stdio.h> /* for FILENAME_MAX */
26 #include <stdlib.h> /* for malloc */
27 #include <string.h>
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 /*! \file lwes_event_type_db.h
34 * \brief Functions for an event specification file database
36 * This is used in cases where you want to restrict the events allowed
37 * to be emitted or listened to to a particular esf file
40 /*! \struct lwes_event_type_db_attribute lwes_event_type_db.h
41 * \brief The attributes stored in the database
43 struct lwes_event_type_db_attribute
45 /*! An event */
46 struct lwes_event *event;
49 /*! \struct lwes_event_type_db lwes_event_type_db.h
50 * \brief The data base itself
52 struct lwes_event_type_db
54 /*! holds the file name which describes the database (aka, the esf file) */
55 char esf_filename[FILENAME_MAX];
56 /*! holds a hash of event descriptions by the event name
57 for events which are described in the esf file */
58 struct lwes_hash *events;
61 /*! \brief Creates the memory for the event_type_db.
63 * This creates memory which should be freed with lwes_event_type_db_destroy
65 * \param[in] filename the path to the file containing the esf description
67 * \see lwes_event_type_db_destroy
69 * \return the newly created db on success, NULL on failure
71 struct lwes_event_type_db *
72 lwes_event_type_db_create
73 (const char *filename);
75 /*! \brief Cleanup the memory for the event_type_db.
77 * This frees the memory created by lwes_event_type_db_create.
79 * \param[in] db the db to free
81 * \return 0 on success, a negative number on failure
83 int
84 lwes_event_type_db_destroy
85 (struct lwes_event_type_db *db);
87 /*! \brief Add an an event name to the database
89 * \param[in] db the db to add the event name to
90 * \param[in] event_name the name of an event
92 * \return 0 if the add is successful, a negative number on failure
94 int
95 lwes_event_type_db_add_event
96 (struct lwes_event_type_db *db,
97 LWES_SHORT_STRING event_name);
99 /*! \brief Add an attribute name to an event name of the database
101 * \param[in] db the db to add the attr_name into
102 * \param[in] event_name the name of an event
103 * \param[in] attr_name the name of an attribute
104 * \param[in] type the type of the attribute
106 * \return 0 if the add is successful, a negative number on failure
109 lwes_event_type_db_add_attribute
110 (struct lwes_event_type_db *db,
111 LWES_SHORT_STRING event_name,
112 LWES_SHORT_STRING attr_name,
113 LWES_SHORT_STRING type);
115 /*! \brief Check for an event in the database
117 * \param[in] db the db to check for the event in
118 * \param[in] event_name the name of an event
120 * \return 1 if the event is in the db, 0 if it is not
123 lwes_event_type_db_check_for_event
124 (struct lwes_event_type_db *db,
125 LWES_SHORT_STRING event_name);
127 /*! \brief Check for an attribute in an event in the database
129 * \param[in] db the db to check
130 * \param[in] attr_name the attribute name to check for
131 * \param[in] event_name the event name to check in
133 * \return 1 if the attribute is in the event in the db, 0 if it is not
136 lwes_event_type_db_check_for_attribute
137 (struct lwes_event_type_db *db,
138 LWES_CONST_SHORT_STRING attr_name,
139 LWES_CONST_SHORT_STRING event_name);
141 /*! \brief Check the type of an attribute in an event in the db
143 * \param[in] db the db to check
144 * \param[in] type_value the type to check against
145 * \param[in] attr_name the attribute name to check for
146 * \param[in] event_name the event name to check in
148 * \return 1 if the attribute in the event in the db is of the asked for type,
149 * 0 if it is not of the specified type
152 lwes_event_type_db_check_for_type
153 (struct lwes_event_type_db *db,
154 LWES_BYTE type_value,
155 LWES_CONST_SHORT_STRING attr_name,
156 LWES_CONST_SHORT_STRING event_name);
158 #ifdef __cplusplus
160 #endif
162 #endif /* __LWES_EVENT_TYPE_DB */