#include <FilterStream.h>
Inheritance diagram for ers::FilterStream:
Public Member Functions | |
FilterStream (Stream *target_ptr, const std::vector< std::string > &include_list, const std::vector< std::string > &exclude_list) | |
FilterStream (Stream *target_ptr, const std::vector< std::string > &include_list, const std::vector< std::string > &exclude_list) | |
virtual bool | is_accept (const Issue *issue_ptr) |
filter method | |
virtual bool | is_accept (const Issue *issue_ptr) |
filter method | |
operator std::string () const | |
operator std::string () const | |
virtual void | print_to (std::ostream &stream) const |
virtual void | print_to (std::ostream &stream) const |
virtual Issue * | receive () |
Receives an issue from the stream. | |
virtual Issue * | receive () |
Receives an issue from the stream. | |
virtual void | send (const Issue *issue_ptr) |
send method | |
virtual void | send (const Issue *issue_ptr) |
send method | |
~FilterStream () | |
destructor | |
~FilterStream () | |
destructor | |
Static Public Member Functions | |
FilterStream * | factory (const std::string ¶meters) |
FilterStream * | factory (const std::string &include_str, const ::std::string &exclude_str, const std::string &target_str) |
FilterStream * | factory (const std::string ¶meters) |
factory method for unparsed information | |
FilterStream * | factory (const std::string &include_str, const ::std::string &exclude_str, const std::string &target_str) |
factory method for partially parse information | |
Static Public Attributes | |
const char *const | EXCLUDE_TAG |
tag used to mark the start of the exclude list | |
const char *const | EXCLUDE_TAG = "!" |
tag used to mark the start of the exclude list | |
const char *const | FILTER_STREAM_TAG |
tag used to identity this stream | |
const char *const | FILTER_STREAM_TAG = "filter" |
tag used to identity this stream | |
const char *const | INCLUDE_TAG |
tag used to mark the start of the include list | |
const char *const | INCLUDE_TAG = "?" |
tag used to mark the start of the include list | |
const char *const | NULL_STREAM_KEY |
const char *const | NULL_STREAM_KEY = "null" |
const char *const | SEPARATORS |
separators between include and exclude qualifiers | |
const char *const | SEPARATORS = "," |
separators between include and exclude qualifiers | |
const char *const | TARGET_TAG |
tag used to mark the target stream | |
const char *const | TARGET_TAG = "@" |
tag used to mark the target stream | |
Protected Member Functions | |
FilterStream (const FilterStream &other) | |
FilterStream () | |
FilterStream (const FilterStream &other) | |
FilterStream () | |
Protected Attributes | |
std::vector< std::string > | m_exclude |
exclude list | |
std::vector< std::string > | m_exclude |
exclude list | |
std::vector< std::string > | m_include |
include list | |
std::vector< std::string > | m_include |
include list | |
Stream * | m_target_stream_ptr |
chained target stream | |
Stream * | m_target_stream_ptr |
chained target stream |
This stream offers basic filtering capacities It basically hooks up in front of another stream and filters the data output. Filtering is based on two list and include list and and exclude list To be accepted an Issue needs two match two criteria
filter:filter:?include_qualifier1,include_qualifier2!exclude_qualifier1,exclude_qualifier2@stream_identifier
The stream_identifier can be any stream_key used by the ERS system (including a second filter).For more information on associating a stream to a severity level, see the documentation on the StreamFactory class.
|
Disabled empty constructor 00072 : ers::Stream() { 00073 } // FilterStream
|
|
Disabled copy constructor 00079 : ers::Stream(other) { 00080 } // FilterStream
|
|
Constructor
00093 : ers::Stream() { 00094 ERS_CHECK_PTR(target_ptr); 00095 m_target_stream_ptr = target_ptr ; 00096 m_include = include_list ; 00097 m_exclude = exclude_list ; 00098 } // FilterStream
|
|
destructor Destructor 00105 { 00106 delete(m_target_stream_ptr) ; 00107 } // FilterStream
|
|
|
|
|
|
|
|
destructor
|
|
|
|
|
|
factory method for unparsed information
Builds a stream out of a key string. This method parses the string and calls a more specialised version of the
00057 { 00058 std::string::size_type include_start = params.find(INCLUDE_TAG); 00059 std::string::size_type exclude_start = params.find(EXCLUDE_TAG); 00060 std::string::size_type target_start = params.find(TARGET_TAG); 00061 std::string include_str = params.substr(include_start+1,exclude_start-1); 00062 std::string exclude_str = params.substr(exclude_start+1,target_start-exclude_start-1); 00063 std::string target_str = params.substr(target_start+1); 00064 // ERS_DEBUG_0("include: '%s' exclude: '%s' target '%s'",include_str.c_str(),exclude_str.c_str(), target_str.c_str()); 00065 return factory(include_str,exclude_str,target_str); 00066 } // factory
|
|
factory method for partially parse information Builds a stream out of a set of parameters
00043 { 00044 ers::Stream *target_stream = ers::StreamFactory::instance()->create_stream(target_str); 00045 std::vector<std::string> include_list = ers::Core::tokenize(include_str,SEPARATORS); 00046 std::vector<std::string> exclude_list = ers::Core::tokenize(exclude_str,SEPARATORS); 00047 return new FilterStream(target_stream,include_list,exclude_list); 00048 } // factory
|
|
filter method
|
|
filter method Filtering method This method checks if an Issue is to be accepted or not.
00115 { 00116 ERS_CHECK_PTR(issue_ptr); 00117 std::string qualifiers = issue_ptr->get_value(ers::Issue::QUALIFIER_LIST_KEY) ; 00118 if (! qualifiers.empty()) { // we check if qualifiers are in exclude list 00119 std::vector<std::string>::const_iterator e_pos ; 00120 for(e_pos = m_exclude.begin();e_pos!=m_exclude.end();e_pos++) { 00121 std::string::size_type conflict = qualifiers.find(*e_pos) ; 00122 if (conflict!=std::string::npos) { 00123 return false ; 00124 } // found conflict 00125 } // for 00126 } // there are some qualifiers 00127 if (! m_include.empty()) { 00128 std::vector<std::string>::const_iterator i_pos ; 00129 for(i_pos = m_include.begin();i_pos!=m_include.end();i_pos++) { 00130 std::string::size_type match = qualifiers.find(*i_pos) ; 00131 if (match!=std::string::npos) { 00132 return true ; 00133 } // found match 00134 } // for 00135 return false ; 00136 } // include list contains items 00137 return true ; 00138 } // is_accept
|
|
|
|
00035 { 00036 std::ostringstream stream ; 00037 print_to(stream); 00038 return stream.str(); 00039 } // to string
|
|
Reimplemented from ers::Stream. |
|
Prints stream description to stream
Reimplemented from ers::Stream. 00162 { 00163 stream << FILTER_STREAM_TAG << ':' ; 00164 std::vector<std::string>::const_iterator i_pos ; 00165 stream << INCLUDE_TAG ; 00166 for(i_pos = m_include.begin();i_pos!=m_include.end();i_pos++) { 00167 if (i_pos!=m_include.begin()) { 00168 stream << SEPARATORS ; 00169 } // if not first 00170 stream << *i_pos ; 00171 } // for include 00172 stream << EXCLUDE_TAG ; 00173 std::vector<std::string>::const_iterator e_pos ; 00174 for(e_pos = m_exclude.begin();e_pos!=m_exclude.end();e_pos++) { 00175 if (e_pos!=m_exclude.begin()) { 00176 stream << SEPARATORS ; 00177 } // if not first 00178 stream << *e_pos ; 00179 } // for exclude 00180 stream << TARGET_TAG ; 00181 stream << *m_target_stream_ptr ; 00182 } // print_to
|
|
Receives an issue from the stream.
Reimplemented in ers::FIFOStream, and ers::FIFOStream. |
|
Receives an issue from the stream. Reads an isssue on the stream
Reimplemented in ers::FIFOStream, and ers::FIFOStream. 00055 { 00056 return 0 ; 00057 } // receive
|
|
send method
Reimplemented from ers::Stream. |
|
send method
Send method basically calls
Reimplemented from ers::Stream. 00147 { 00148 ERS_CHECK_PTR(issue_ptr); 00149 ERS_CHECK_PTR(m_target_stream_ptr); 00150 if (is_accept(issue_ptr)) { 00151 // ERS_DEBUG_3("accepted %s:",issue_ptr->what()); 00152 m_target_stream_ptr->send(issue_ptr); 00153 } else { 00154 // ERS_DEBUG_3("rejected %s:",issue_ptr->what()); 00155 } 00156 } // send
|
|
tag used to mark the start of the exclude list
|
|
tag used to mark the start of the exclude list
|
|
tag used to identity this stream
|
|
tag used to identity this stream Tag used to identify the stream |
|
tag used to mark the start of the include list
|
|
tag used to mark the start of the include list
|
|
exclude list
|
|
exclude list
|
|
include list
|
|
include list
|
|
chained target stream
|
|
chained target stream
|
|
Key for discard stream |
|
Key for discard stream |
|
separators between include and exclude qualifiers
|
|
separators between include and exclude qualifiers
|
|
tag used to mark the target stream
|
|
tag used to mark the target stream
|