Commit 741004a4 authored by Andrea Valassi's avatar Andrea Valassi
Browse files

Take CoolKernel headers from the 30 branch


git-svn-id: file:///git/lcgcool.svndb/cool/tags/COOL_3_0_1@19065 4525493e-7705-40b1-a816-d608a930855b
parent 37453d2d
// $Id: ChannelId.h,v 1.5 2009-12-17 18:50:42 avalassi Exp $
#ifndef COOLKERNEL_CHANNELID_H
#define COOLKERNEL_CHANNELID_H
// Include files
#include "CoolKernel/types.h"
namespace cool {
/** @file ChannelId.h
*
* Type definition for the 'ID' of a channel in a COOL folder.
*
* @author Sven A. Schmidt and Andrea Valassi
* @date 2004-11-05
*///
// ChannelId.
typedef UInt32 ChannelId;
}
#endif
#ifndef COOLKERNEL_CHANNELSELECTION_H
#define COOLKERNEL_CHANNELSELECTION_H 1
// First of all, set/unset CORAL290, COOL300, COOL400 and COOL_HAS_CPP11 macros
#include "CoolKernel/VersionInfo.h"
// Include files
#include <limits>
#ifdef COOL400CPP11ENUM
#include <ostream>
#endif
#include <vector>
#include "CoolKernel/ChannelId.h"
namespace cool
{
/** @class ChannelSelection ChannelSelection.h
*
* Helper class to specify a selection of channels and their ordering
* for multi-channel bulk retrieval of IOVs.
*
* So far, only selection of IOVs _within a given tag_ is supported (the
* choice of the selected tag is made outside the ChannelSelection class).
* Within each channel, IOVs can be browsed ordered by 'iovSince',
* and there is only one IOV valid at any given validity time.
*
* @author Sven A. Schmidt, Andrea Valassi and Marco Clemencic
* @date 2005-08-08
*///
class ChannelSelection
{
friend class ChannelSelectionTest;
public:
/// Internal helper class for channel ranges. Ideally this class should
/// be private but PyCool dictionary generation does not like that!
class ChannelRange
{
public:
// Required by PyCool
#ifdef COOL290CO
ChannelRange()
: m_firstChannel( 0 ) // Fix Coverity UNINIT_CTOR (bug #95363)
, m_lastChannel( 0 ) {}
#else
ChannelRange() {}
#endif
ChannelRange( const ChannelId& firstChannel,
const ChannelId& lastChannel );
ChannelId firstChannel() const;
ChannelId lastChannel() const;
bool inRange( const ChannelId& channel ) const;
private:
ChannelId m_firstChannel;
ChannelId m_lastChannel;
};
/// There are two possible orders to browse IOVs (within a tag) across
/// many channels: 'order by channel, since' and 'order by since, channel'.
/// The second set of the ordering scheme lists the IOVs in reverse order.
#ifndef COOL400CPP11ENUM
enum Order
#else
enum class Order
#endif
{
channelBeforeSince, sinceBeforeChannel,
channelBeforeSinceDesc, sinceDescBeforeChannel
};
#ifdef COOL400CPP11ENUM
// Overloaded operator<< for cool::ChannelSelection::Order
inline friend std::ostream&
operator<<( std::ostream& s, const cool::ChannelSelection::Order& order )
{
return s << (int)order;
}
#endif
/// Constructor to (implicitly) select IOVs from *all* channels
/// with the given order (default is 'order by channel, since').
#ifndef COOL400CPP11ENUM
explicit ChannelSelection( const Order& order = channelBeforeSince );
#else
explicit ChannelSelection( const Order& order = Order::channelBeforeSince );
#endif
/// Constructor to select IOVs for a given channel. This constructor is
/// intended to be used to autoconvert ChannelId to a ChannelSelection.
ChannelSelection( const ChannelId& channel );
/// Constructor to select IOVs for channels within a given range
/// with the given order (default is 'order by channel, since').
ChannelSelection( const ChannelId& firstChannel,
const ChannelId& lastChannel,
#ifndef COOL400CPP11ENUM
const Order& order = channelBeforeSince
#else
const Order& order = Order::channelBeforeSince
#endif
);
/// Constructor to select IOVs with a given channel name.
ChannelSelection( const std::string& channelName,
#ifndef COOL400CPP11ENUM
const Order& order = channelBeforeSince
#else
const Order& order = Order::channelBeforeSince
#endif
);
/// Returns true if selecting all channels.
bool allChannels() const;
/// Returns the first selected channel
/// [std::numeric_limits<ChannelId>::min() if selecting all channels].
ChannelId firstChannel() const;
/// Returns the last selected channel
/// [std::numeric_limits<ChannelId>::max() if selecting all channels].
ChannelId lastChannel() const;
/// Returns the selection order.
Order order() const;
/// Construct a selection to select *all* channels with the given order.
static const
#ifndef COOL400CPP11ENUM
ChannelSelection all( const Order& order = channelBeforeSince );
#else
ChannelSelection all( const Order& order = Order::channelBeforeSince );
#endif
/// Returns true if the given channel is in the selection
bool inSelection( const ChannelId& channel ) const;
/// Returns true if the given channelName is in the selection
bool inSelection( const std::string& channelName ) const;
/// Returns true if the selection is contiguous
/// This is the case if every channel between the very first and the
/// last of the selection ranges is in the selection.
/// This method does not make any assumption about the granularity. The
/// only requirement is that operator++ at the end of an internal channel
/// range will step to the first channel of the next range and not 'land'
/// on a ChannelId outside the selection.
bool isContiguous() const;
/// Adds a channel range to the selection
/// For sake of simplicity, it is required that the range is added
/// to the front or the back of the existing selection without overlap.
void addRange( const ChannelId& firstChannel,
const ChannelId& lastChannel );
/// Adds a channel to the selection
void addChannel( const ChannelId& channel );
/// Returns true is the ChannelSelection is numeric.
bool isNumeric() const;
/// Returns the channel name list
const std::string& channelName() const;
/// Returns the beginning of a const range iterator
std::vector<ChannelRange>::const_iterator begin() const;
/// Returns the end of a const range iterator
std::vector<ChannelRange>::const_iterator end() const;
/// Returns the range count
unsigned int rangeCount() const;
private:
bool m_isNumeric;
bool m_allChannels;
std::vector<ChannelRange> m_ranges;
std::string m_channelName;
Order m_order;
};
}
#endif // COOLKERNEL_CHANNELSELECTION_H
#ifndef COOLKERNEL_COMPOSITESELECTION_H
#define COOLKERNEL_COMPOSITESELECTION_H 1
// First of all, set/unset CORAL290, COOL300, COOL400 and COOL_HAS_CPP11 macros
#include "CoolKernel/VersionInfo.h"
// Include files
#ifdef COOL400CPP11ENUM
#include <ostream>
#endif
#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).
#ifndef COOL400CPP11ENUM
enum Connective { AND, OR };
#else
enum class Connective { AND, OR };
// Overloaded operator<< for cool::CompositeSelection::Connective
inline friend std::ostream&
operator<<( std::ostream& s, const cool::CompositeSelection::Connective& c )
{
return s << (int)c;
}
#endif
/// Describe a logical connective.
static const std::string describe( 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,
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( Connective conn,
const std::vector<const IRecordSelection*>& selVec );
/// Connect another selection.
/// The input selection is cloned (the clone is owned by this instance).
void connect( Connective conn,
const IRecordSelection* sel );
/// Can the selection be applied to a record with the given specification?
bool canSelect( const IRecordSpecification& spec ) const;
/// Apply the selection to the given record.
bool select( const IRecord& record ) const;
/// Clone the record selection (and any objects referenced therein).
IRecordSelection* clone() const;
/// Logical connective between all connected selections.
Connective connective() const;
/// The number N of connected selections.
unsigned int size() const;
/// Return one of the connected selections by its index in [0, N-1].
const IRecordSelection* operator[] ( 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 );
/// Constructor with a default connective and no selections - for connect()
CompositeSelection( Connective conn );
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 // COOLKERNEL_COMPOSITESELECTION_H
// $Id: ConstRecordAdapter.h,v 1.22 2009-12-16 17:41:24 avalassi Exp $
#ifndef RELATIONALCOOL_CONSTRECORDADAPTER_H
#define RELATIONALCOOL_CONSTRECORDADAPTER_H 1
// Include files
#include "CoolKernel/IRecord.h"
#include "CoolKernel/RecordSpecification.h"
#include "CoralBase/AttributeList.h"
namespace cool
{
//--------------------------------------------------------------------------
/** @class ConstRecordAdapter ConstRecordAdapter.h
*
* Read-only wrapper of a constant coral::AttributeList reference,
* implementing the cool::IRecord interface. The adapter can only be
* used as long as the AttributeList is alive. The adapter creates
* its own RecordSpecification from one specified at construction time.
*
* All non-const methods throw: this is effectively a read-only class.
*
* The StorageType constraints on the data values of all fields
* are enforced in all copy constructors and assignment operators.
*
* @author Andrea Valassi and Marco Clemencic
* @date 2006-12-01
*///
class ConstRecordAdapter : public IRecord {
public:
virtual ~ConstRecordAdapter();
/// Constructor from a record spec and a _const_ AttributeList reference.
/// The AttributeList must have at least all the fields required by the
/// IRecordSpecification (with the correct name and storage type), but it
/// may have more: it is reinterpreted according to the new specification.
/// String attributes equal to NULL are considered equal to "".
ConstRecordAdapter( const IRecordSpecification& spec,
const coral::AttributeList& al );
/// Return the specification of this record.
const IRecordSpecification& specification() const;
/// Return a field in this record by its name (const).
const IField& operator[] ( const std::string& name ) const;
/// Return a field in this record by its index in [0, N-1] (const).
const IField& operator[] ( UInt32 index ) const;
/// Explicit conversion to a constant coral AttributeList reference.
/// The AttributeList returned by this method contains only the attributes
/// listed in the input IRecordSpecification, which may be fewer than
/// those contained in the wrapped constant AttributeList reference.
const coral::AttributeList& attributeList() const;
private:
/// Return a field in this record by its index in [0, N-1] (const).
const IField& field( UInt32 index ) const;
/// This method THROWS an exception because this is a read-only class.
IField& field( UInt32 index ); // THROWS...
private:
/// Default constructor is private
ConstRecordAdapter();
/// Copy constructor is private
ConstRecordAdapter( const ConstRecordAdapter& rhs );
/// Assignment operator is private
ConstRecordAdapter& operator=( const ConstRecordAdapter& rhs );
private:
/// The record specification.
RecordSpecification m_spec;
/// The record data (as an AttributeList const reference).
/// CONST REFERENCE: the adapter can only be used as long as this is alive!
const coral::AttributeList& m_attrList;
/// The IField wrappers for the individual data Attribute's.
std::vector< IField* > m_fields;
/// The AttributeList accessible via the attributeList public method.
coral::AttributeList m_publicAttrList;
};
}
#endif // RELATIONALCOOL_CONSTRECORDADAPTER_H
// $Id: DatabaseId.h,v 1.6 2006-04-03 17:02:19 avalassi Exp $
#ifndef COOLKERNEL_DATABASEID_H
#define COOLKERNEL_DATABASEID_H 1
#include <string>
namespace cool
{
/** @class DatabaseId DatabaseId.h
*
* Globally unique identifier of one "conditions database" instance.
*
* Recommended syntax without CORAL alias:
* "oracle://aTnsHost;schema=aUserName;dbname=aDbname";
* "mysql://aTcpHost;schema=aDatabase;dbname=aDbname";
* "sqlite://;schema=aFileName.db;dbname=aDbname";
*
* Recommended syntax with CORAL alias:
* "anAlias/aDbname";
*
* @author Andrea Valassi, Sven A. Schmidt and Marco Clemencic
* @date 2004-11-09
*///
typedef std::string DatabaseId;
}
#endif // COOLKERNEL_DATABASEID_H
This diff is collapsed.
#ifndef COOLKERNEL_FIELDSELECTION_H
#define COOLKERNEL_FIELDSELECTION_H 1
// First of all, set/unset CORAL290, COOL300, COOL400 and COOL_HAS_CPP11 macros
#include "CoolKernel/VersionInfo.h"
// Include files
#ifdef COOL400CPP11ENUM
#include <ostream>
#endif
#include "CoolKernel/FieldSpecification.h"
#include "CoolKernel/IRecordSelection.h"
#include "CoolKernel/Record.h"
namespace cool
{
//--------------------------------------------------------------------------
/** @class FieldSelection FieldSelection.h
*
* Simple selection on a data field.
*
* @author Andrea Valassi and Martin Wache
* @date 2008-07-28
*///
class FieldSelection : virtual public IRecordSelection
{
public:
/// Binary relation operator (comparison to a reference value).
#ifndef COOL400CPP11ENUM
enum Relation { EQ, NE, GT, GE, LT, LE };
#else
enum class Relation { EQ, NE, GT, GE, LT, LE };
// Overloaded operator<< for cool::FieldSelection::Relation
inline friend std::ostream&
operator<<( std::ostream& s, const cool::FieldSelection::Relation& rel )
{
return s << (int)rel;
}
#endif
/// Unary nullness operator (comparison to NULL).
#ifndef COOL400CPP11ENUM
enum Nullness { IS_NULL, IS_NOT_NULL };
#else
enum class Nullness { IS_NULL, IS_NOT_NULL };
// Overloaded operator<< for cool::FieldSelection::Nullness
inline friend std::ostream&
operator<<( std::ostream& s, const cool::FieldSelection::Nullness& nul )
{
return s << (int)nul;
}
#endif
/// Describe a binary relation operator.
static const std::string describe( Relation relation );
/// Describe a unary nullness operator.
static const std::string describe( Nullness nullness );
public:
/// Destructor.
virtual ~FieldSelection();
/// Constructor for comparison to non-NULL reference values.
template<typename T>
FieldSelection( const std::string& name,
const StorageType::TypeId typeId,
Relation relation,
const T& refValue );
/// Constructor for comparison to NULL.
FieldSelection( const std::string& name,
const StorageType::TypeId typeId,
Nullness nullness );
/// Can the selection be applied to a record with the given specification?
bool canSelect( const IRecordSpecification& spec ) const;
/// Apply the selection to the given record.
bool select( const IRecord& record ) const;
/// Clone the record selection (and any objects referenced therein).
IRecordSelection* clone() const;
/// Nullness operator for this selection.
/// Returns IS_NOT_NULL for comparisons to non-NULL reference values.
Nullness nullness() const;
/// Relation operator for this selection.
/// Returns EQ or NE for comparisons to NULL reference values.
Relation relation() const;
/// Reference value for this selection.
/// Returns a NULL field for comparisons to NULL reference values.
const IField& referenceValue() const;
private:
/// Standard constuctor is private
FieldSelection();
/// Copy constructor - reimplemented for the clone() method
FieldSelection( const FieldSelection& rhs );
/// Assignment operator is private
FieldSelection& operator=( const FieldSelection& rhs );
/// Initialize - extra checks for constructor of comparison to non-NULL.
void initialize();
private:
/// The reference value (as a Record with one and only one field).
/// The specification of the field is the one this selection can select.
/// For comparisons to NULL, this field is set to NULL.
Record m_refValue;
/// The relation to the ref value (eg. 'GT': is this field > ref value?).
/// For comparisons to NULL, this is set to 'EQ' or 'NE'.
Relation m_relation;
};
//---------------------------------------------------------------------------
template<typename T>
inline FieldSelection::FieldSelection( const std::string& name,
const StorageType::TypeId typeId,
Relation relation,
const T& refValue )
: m_refValue( FieldSpecification( name, typeId ) )
, m_relation( relation )
{
// Set the reference value and ensure that T and typeId are compatible
m_refValue[0].setValue( refValue );
// Extra cross-checks for constructor of comparison to non-NULL
initialize();
}
//---------------------------------------------------------------------------
}
#endif // COOLKERNEL_FIELDSELECTION_H