Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:11

0001 // -*- C++ -*-
0002 //
0003 // This file is part of HepMC
0004 // Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
0005 //
0006 #ifndef HEPMC3_SEARCH_FILTEATTRIBUTE_H
0007 #define HEPMC3_SEARCH_FILTEATTRIBUTE_H
0008 ///
0009 /// @file FilterAttribute.h
0010 /// @brief Definition of \b class ATTRIBUTE
0011 ///
0012 /// @class HepMC3::ATTRIBUTE
0013 /// @brief Filter for the attributes
0014 ///
0015 /// Used to construct filters that can check if an attribute exists
0016 /// or to compare against other attribute.
0017 ///
0018 /// @ingroup searchengine
0019 #include <string>
0020 #include <memory>
0021 #include "HepMC3/Filter.h"
0022 #include "HepMC3/Attribute.h"
0023 
0024 namespace HepMC3 {
0025 /** Deprecated */
0026 using std::string;
0027 
0028 class ATTRIBUTE : public Filter {
0029 //
0030 // Constructors
0031 //
0032 public:
0033     /// @brief Default constructor
0034     ///
0035     /// Provides the name of the attribute used in by the filter
0036     ATTRIBUTE(const std::string &name):Filter(ATTRIBUTE_EXISTS, name) {}
0037 
0038 //
0039 // Operators
0040 //
0041 public:
0042     /// @brief Compare if this attribute is equal to other attribute
0043     Filter& operator==(std::shared_ptr<Attribute> &at) {
0044         m_attribute = ATTRIBUTE_IS_EQUAL;
0045         at->to_string(m_attribute_str);
0046         return *this;
0047     }
0048 
0049     /// @brief Compare if this attribute is not equal to other attribute
0050     Filter& operator!=(std::shared_ptr<Attribute> &at) {
0051         m_bool_value = !m_bool_value;
0052         m_attribute  = ATTRIBUTE_IS_EQUAL;
0053         at->to_string(m_attribute_str);
0054         return *this;
0055     }
0056 
0057     /// @brief Compare if string version of this attribute is equal value
0058     Filter& operator==(const std::string &value) {
0059         m_attribute     = ATTRIBUTE_IS_EQUAL;
0060         m_attribute_str = value;
0061         return *this;
0062     }
0063 
0064     /// @brief Compare if string version of this attribute is not equal value
0065     Filter& operator!=(const std::string &value) {
0066         m_bool_value    = !m_bool_value;
0067         m_attribute     = ATTRIBUTE_IS_EQUAL;
0068         m_attribute_str = value;
0069         return *this;
0070     }
0071 
0072     /// @brief Negate logic of the result (eg. check if attribute does not exist)
0073     Filter& operator!() {
0074         m_bool_value = !m_bool_value;
0075         return *this;
0076     }
0077 };
0078 
0079 } // namespace HepMC3
0080 
0081 #endif