1 #ifndef FILTER_SET_CLASS
2 #define FILTER_SET_CLASS
4 /*****************************************************************************\
7 * Author : Chris Koeritz
9 *******************************************************************************
10 * Copyright (c) 1996-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
18 #include <basis/astring.h>
19 #include <basis/definitions.h>
20 #include <basis/mutex.h>
21 #include <structures/set.h>
25 //! A simple object that wraps a templated set of ints.
26 class filter_set : public structures::set<int>, public virtual basis::root_object
30 //!< Constructs an empty set of filters.
32 virtual ~filter_set() {}
34 filter_set(const structures::set<int> &to_copy) : structures::set<int>(to_copy) {}
35 //!< Constructs a copy of the "to_copy" array.
37 DEFINE_CLASS_NAME("filter_set");
39 //! Adds a member to the filter set.
40 /*! The filter set is used to check all extended filter values passed to
41 log and print. if the special filters of ALWAYS_PRINT or NEVER_PRINT are
42 added, then either everything will be logged or nothing will be. */
43 virtual void add_filter(int new_filter) {
44 basis::auto_synchronizer l(c_lock);
48 //! Removes a member from the filter set.
49 virtual void remove_filter(int old_filter) {
50 basis::auto_synchronizer l(c_lock);
54 //! Returns true if the "filter_to_check" is a member of the filter set.
55 /*! If "filter_to_check" is ALWAYS_PRINT, this always returns true. If
56 the value is NEVER_PRINT, false is always returned. */
57 virtual bool member(int filter_to_check) {
58 if (filter_to_check == basis::ALWAYS_PRINT) return true;
59 if (filter_to_check == basis::NEVER_PRINT) return false;
60 return structures::set<int>::member(filter_to_check);
63 //! Resets the filter set to be empty.
64 virtual void clear_filters() {
65 basis::auto_synchronizer l(c_lock);