CompositeSelection.h 3.2 KB
Newer Older
1
// $Id: CompositeSelection.h,v 1.2 2008-07-30 15:20:50 avalassi Exp $
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef COOLKERNEL_COMPOSITESELECTION_H
#define COOLKERNEL_COMPOSITESELECTION_H 1
#ifdef COOL260

// Include files
#include <vector>
#include "CoolKernel/IRecordSelection.h"

namespace cool
{

  //--------------------------------------------------------------------------

  /** @class CompositeSelection CompositeSelection.h
   *
   *  Composite selection on a data record obtained by the conjuction (AND) 
   *  or disjunction (OR) of several simplere record selections.
   *
   *  @author Andrea Valassi and Martin Wache
   *  @date   2008-07-30
   */

  class CompositeSelection : virtual public IRecordSelection
  {

  public:

    /// Logical connectives (logical operations).
    enum Connective{ AND, OR };    

    /// Describe a logical connective.
    static const std::string describe( const Connective conn );
    
  public:

    /// Destructor.
    virtual ~CompositeSelection();
 
    /// Constructor for connecting two selections.
    /// Each input selection is cloned (the clone is owned by this instance).
    CompositeSelection( const IRecordSelection* sel1,
                        const Connective conn,
                        const IRecordSelection* sel2 );
    
    /// Constructor for connecting any number of selections.
    /// The vector must contain at least two selections.
    /// Each input selection is cloned (the clone is owned by this instance).
    CompositeSelection( const Connective conn,
                        const std::vector<const IRecordSelection*> selVec );
    
52
53
54
55
56
    /// Connect another selection.
    /// The input selection is cloned (the clone is owned by this instance).
    void connect( const Connective conn,
                  const IRecordSelection* sel );
    
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    /// Can the selection be applied to a record with the given specification?
    const bool canSelect( const IRecordSpecification& spec ) const;

    /// Apply the selection to the given record.
    const bool select( const IRecord& record ) const;
    
    /// Clone the record selection (and any objects referenced therein).
    IRecordSelection* clone() const;

    /// Logical connective between all connected selections.
    const Connective connective() const;

    /// The number N of connected selections.
    const unsigned int size() const;

    /// Return one of the connected selections by its index in [0, N-1].
    const IRecordSelection* operator[] ( const unsigned int index ) const;

  private:

    /// Standard constuctor is private
    CompositeSelection();
    
    /// Copy constructor - reimplemented for the clone() method
    CompositeSelection( const CompositeSelection& rhs );
    
    /// Assignment operator is private
    CompositeSelection& operator=( const CompositeSelection& rhs );
            
86
87
88
    /// Constructor with a default connective and no selections - for connect()
    CompositeSelection( const Connective conn );
    
89
90
91
92
93
94
95
96
97
98
99
100
101
102
  private:

    /// The logical connective between connected selections.
    Connective m_conn;

    /// The vector of connected selections.
    /// These are clones (owned by this instance) of the user-given selections.
    std::vector<IRecordSelection*> m_selVec;

  };
  
}
#endif
#endif // COOLKERNEL_COMPOSITESELECTION_H