HepMC event record
include/HepMC/Search/FilterAttribute.h
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014 The HepMC collaboration (see AUTHORS for details)
5 //
6 #ifndef HEPMC_SEARCH_FILTEATTRIBUTE_H
7 #define HEPMC_SEARCH_FILTEATTRIBUTE_H
8 ///
9 /// @file FilterAttribute.h
10 /// @brief Definition of \b class ATTRIBUTE
11 ///
12 /// @class HepMC::ATTRIBUTE
13 /// @brief Filter for the attributes
14 ///
15 /// Used to construct filters that can check if an attribute exists
16 /// or to compare against other attribute. See @ref search_engine for details
17 /// and examples of its use.
18 ///
19 /// @ingroup search_engine
20 #include "HepMC/Search/Filter.h"
21 #include "HepMC/Attribute.h"
22 #include <string>
23 
24 namespace HepMC {
25 
26 using std::string;
27 
28 class ATTRIBUTE : public Filter {
29 //
30 // Constructors
31 //
32 public:
33  /// @brief Default constructor
34  ///
35  /// Provides the name of the attribute used in by the filter
36  ATTRIBUTE(const string &name):Filter(ATTRIBUTE_EXISTS,name) {}
37 
38 //
39 // Operators
40 //
41 public:
42 
43  /// @brief Compare if this attribute is equal to other attribute
44  Filter& operator==( shared_ptr<Attribute> &at ) {
45  m_attribute = ATTRIBUTE_IS_EQUAL;
46  at->to_string(m_attribute_str);
47  return *this;
48  }
49 
50  /// @brief Compare if this attribute is not equal to other attribute
51  Filter& operator!=( shared_ptr<Attribute> &at ) {
53  m_attribute = ATTRIBUTE_IS_EQUAL;
54  at->to_string(m_attribute_str);
55  return *this;
56  }
57 
58  /// @brief Compare if string version of this attribute is equal value
59  Filter& operator==( const std::string &value ) {
60  m_attribute = ATTRIBUTE_IS_EQUAL;
61  m_attribute_str = value;
62  return *this;
63  }
64 
65  /// @brief Compare if string version of this attribute is not equal value
66  Filter& operator!=( const std::string &value ) {
68  m_attribute = ATTRIBUTE_IS_EQUAL;
69  m_attribute_str = value;
70  return *this;
71  }
72 
73  /// @brief Negate logic of the result (eg. check if attribute does not exist)
76  return *this;
77  }
78 };
79 
80 } // namespace HepMC
81 
82 #endif
bool m_bool_value
Filter parameter for boolean-type filter.
ATTRIBUTE(const string &name)
Default constructor.
Class used to define filters for search engine.
Filter & operator==(const std::string &value)
Compare if string version of this attribute is equal value.
Filter & operator!()
Negate logic of the result (eg. check if attribute does not exist)
FilterAttributeParam m_attribute
Attribute value (if attribute parameter type)
Filter & operator!=(const std::string &value)
Compare if string version of this attribute is not equal value.
string m_attribute_str
Filter parameter for attribute-type filters.
Filter & operator==(shared_ptr< Attribute > &at)
Compare if this attribute is equal to other attribute.
Filter & operator!=(shared_ptr< Attribute > &at)
Compare if this attribute is not equal to other attribute.
Definition of template class SmartPointer.