Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00:34

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 //==============================================================================
0012 //
0013 // Package : Kernel
0014 //
0015 // Author  : M.Frank 10/10/00
0016 //
0017 //==============================================================================
0018 #ifndef KERNEL_SELECTSTATEMENT_H
0019 #define KERNEL_SELECTSTATEMENT_H
0020 
0021 // STL include files
0022 #include <string>
0023 
0024 // Framework include files
0025 #include "GaudiKernel/ISelectStatement.h"
0026 
0027 /** Class of a selection statement.
0028   A select statement can either contain
0029   - a string e.g. for refining an SQL statement
0030   - a function object, which will be called back
0031     in order to refine a selection.
0032     This happens in calling sequences like the following:
0033 
0034   bool MySelect::operator()(IValueLocator* l)   {
0035     float px, py, pz;
0036     if ( l->get("PX",px) && l->get("PY",py) && l->get("PZ",pz) )  {
0037       float mom = sqrt(px*px+py*py+pz*pz);
0038       return mom > 100.0 * GeV;
0039     }
0040     return false;
0041   }
0042 
0043     if "true" is returned, the object will be loaded completely.
0044 
0045     History:
0046     +---------+----------------------------------------------+--------+
0047     |    Date |                 Comment                      | Who    |
0048     +---------+----------------------------------------------+--------+
0049     | 21/10/99| Initial version.                             | MF     |
0050     +---------+----------------------------------------------+--------+
0051     Author:  M.Frank
0052     Version: 1.0
0053 */
0054 class GAUDI_API SelectStatement : public implements<ISelectStatement> {
0055 public:
0056   /// Standard Constructor initializing select string
0057   explicit SelectStatement( const std::string& s, long typ ) : m_select( s ), m_isActive( false ), m_type( typ ) {}
0058   /// Standard Constructor initializing select string
0059   explicit SelectStatement( const std::string& s ) : m_select( s ), m_isActive( false ), m_type( STRING ) {}
0060   /// Standard Constructor initializing function call
0061   explicit SelectStatement() : m_isActive( false ), m_type( FUNCTION ) {}
0062   /// Standard Destructor
0063   virtual ~SelectStatement() {}
0064   /// Access the type of the object
0065   long type() const override { return m_type; }
0066   /// Access the selection string
0067   const std::string& criteria() const override { return m_select; }
0068   /// Set the type
0069   void setCriteria( const std::string& crit ) override {
0070     m_select = crit;
0071     ( m_select.length() > 0 ) ? m_type |= STRING : m_type &= ~STRING;
0072   }
0073   /// Change activity flag
0074   void setActive( bool flag = true ) override { m_isActive = flag; }
0075   /// Check if selection is active
0076   bool isActive() const override { return m_isActive; }
0077   /// Stupid default implementation
0078   virtual bool operator()( void* /* val */ ) override { return true; }
0079 
0080 protected:
0081   /// Select string
0082   std::string m_select;
0083   /// Activation flag
0084   bool m_isActive;
0085   /// Type identifier
0086   long m_type;
0087 };
0088 #endif // KERNEL_SELECTSTATEMENT_H