Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ers::FilterStream Class Reference

filtering stream More...

#include <FilterStream.h>

Inheritance diagram for ers::FilterStream:

ers::Stream ers::Stream List of all members.

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 Issuereceive ()
 Receives an issue from the stream.
virtual Issuereceive ()
 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

FilterStreamfactory (const std::string &parameters)
FilterStreamfactory (const std::string &include_str, const ::std::string &exclude_str, const std::string &target_str)
FilterStreamfactory (const std::string &parameters)
 factory method for unparsed information
FilterStreamfactory (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
Streamm_target_stream_ptr
 chained target stream
Streamm_target_stream_ptr
 chained target stream

Detailed Description

filtering 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

If the include list is empty, the second condition is not applied. This stream should only be used for severity levels where filtering makes sense, i.e warning, debugs, etc... The syntax to request a filter stream is the following:
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.

See also:
ers::StreamFactory
Author:
Matthias Wiesmann
Version:
1.0


Constructor & Destructor Documentation

ers::FilterStream::FilterStream  )  [protected]
 

Disabled empty constructor

00072                               : ers::Stream() {
00073 } // FilterStream

ers::FilterStream::FilterStream const FilterStream other  )  [protected]
 

Disabled copy constructor

00079                                                        : ers::Stream(other) {
00080 } // FilterStream

ers::FilterStream::FilterStream ers::Stream target_ptr,
const std::vector< std::string > &  include_list,
const std::vector< std::string > &  exclude_list
 

Constructor

Parameters:
target_ptr pointer to the target stream, the target pointer is assumed to be allocated on the stack and owned by the current object, i.e it will be deleted upon destruction
include_list collection of strings, at least one of these strings need to be present in the qualifiers in order for the Issue to be accepted.
exclude_list collection of strings, no qualifier of the Issue must match those in this collection in order for the Issue to be accepted.
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

ers::FilterStream::~FilterStream  ) 
 

destructor

Destructor

00105                                {
00106     delete(m_target_stream_ptr) ; 
00107 } // FilterStream

ers::FilterStream::FilterStream  )  [protected]
 

ers::FilterStream::FilterStream const FilterStream other  )  [protected]
 

ers::FilterStream::FilterStream Stream target_ptr,
const std::vector< std::string > &  include_list,
const std::vector< std::string > &  exclude_list
 

ers::FilterStream::~FilterStream  ) 
 

destructor


Member Function Documentation

FilterStream* ers::FilterStream::factory const std::string &  parameters  )  [static]
 

FilterStream* ers::FilterStream::factory const std::string &  include_str,
const ::std::string &  exclude_str,
const std::string &  target_str
[static]
 

ers::FilterStream * ers::FilterStream::factory const std::string &  params  )  [static]
 

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 factory method.

Parameters:
params single string describing the requested filter stream
Returns:
pointer to newly heap allocated instance of FilterStream
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

ers::FilterStream * ers::FilterStream::factory const std::string &  include_str,
const ::std::string &  exclude_str,
const std::string &  target_str
[static]
 

factory method for partially parse information

Builds a stream out of a set of parameters

Parameters:
include_str string containing all the coma separated include qualifiers
exclude_str string containing all the coma separated exclude qualifiers
target_str string containing the key for the target stream, i.e the stream where accepted Issues are sent.
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

virtual bool ers::FilterStream::is_accept const Issue issue_ptr  )  [virtual]
 

filter method

bool ers::FilterStream::is_accept const Issue issue_ptr  )  [virtual]
 

filter method

Filtering method This method checks if an Issue is to be accepted or not.

Parameters:
issue_ptr the issue to check
Returns:
true if the Issue passes filtering, false otherwise.
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

ers::Stream::operator std::string  )  const [inherited]
 

ers::Stream::operator std::string  )  const [inherited]
 

00035                                     {
00036     std::ostringstream stream ; 
00037     print_to(stream); 
00038     return stream.str(); 
00039 } // to string 

virtual void ers::FilterStream::print_to std::ostream stream  )  const [virtual]
 

Reimplemented from ers::Stream.

void ers::FilterStream::print_to std::ostream stream  )  const [virtual]
 

Prints stream description to stream

Parameters:
stream STL target 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

virtual Issue* ers::Stream::receive  )  [virtual, inherited]
 

Receives an issue from the stream.

Reimplemented in ers::FIFOStream, and ers::FIFOStream.

ers::Issue * ers::Stream::receive  )  [virtual, inherited]
 

Receives an issue from the stream.

Reads an isssue on the stream

Returns:
the issue that has been read
Note:
This implementation always returns a null pointer

Reimplemented in ers::FIFOStream, and ers::FIFOStream.

00055                              {
00056     return 0 ; 
00057 } // receive

virtual void ers::FilterStream::send const Issue issue_ptr  )  [virtual]
 

send method

Reimplemented from ers::Stream.

void ers::FilterStream::send const Issue issue_ptr  )  [virtual]
 

send method

Send method basically calls is_accept to check if the issue is accepted. If this is the case, the send method on the target is called with issue_ptr.

Parameters:
issue_ptr pointer to the issue to send.

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


Member Data Documentation

const char* const ers::FilterStream::EXCLUDE_TAG [static]
 

tag used to mark the start of the exclude list

const char *const ers::FilterStream::EXCLUDE_TAG = "!" [static]
 

tag used to mark the start of the exclude list

const char* const ers::FilterStream::FILTER_STREAM_TAG [static]
 

tag used to identity this stream

const char *const ers::FilterStream::FILTER_STREAM_TAG = "filter" [static]
 

tag used to identity this stream

Tag used to identify the stream

const char* const ers::FilterStream::INCLUDE_TAG [static]
 

tag used to mark the start of the include list

const char *const ers::FilterStream::INCLUDE_TAG = "?" [static]
 

tag used to mark the start of the include list

std::vector<std::string> ers::FilterStream::m_exclude [protected]
 

exclude list

std::vector<std::string> ers::FilterStream::m_exclude [protected]
 

exclude list

std::vector<std::string> ers::FilterStream::m_include [protected]
 

include list

std::vector<std::string> ers::FilterStream::m_include [protected]
 

include list

Stream* ers::FilterStream::m_target_stream_ptr [protected]
 

chained target stream

Stream* ers::FilterStream::m_target_stream_ptr [protected]
 

chained target stream

const char* const ers::Stream::NULL_STREAM_KEY [static, inherited]
 

Key for discard stream

const char *const ers::Stream::NULL_STREAM_KEY = "null" [static, inherited]
 

Key for discard stream

const char* const ers::FilterStream::SEPARATORS [static]
 

separators between include and exclude qualifiers

const char *const ers::FilterStream::SEPARATORS = "," [static]
 

separators between include and exclude qualifiers

const char* const ers::FilterStream::TARGET_TAG [static]
 

tag used to mark the target stream

const char *const ers::FilterStream::TARGET_TAG = "@" [static]
 

tag used to mark the target stream


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:19:37 2011 for BOSS6.5.5 by  doxygen 1.3.9.1