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
// $Id: Exception.h,v 1.58 2012-07-08 20:02:33 avalassi Exp $
#ifndef COOLKERNEL_EXCEPTION_H
#define COOLKERNEL_EXCEPTION_H 1
// First of all, enable or disable the COOL290 API extensions (bug #92204)
#include "CoolKernel/VersionInfo.h"
// Include files
#include <sstream>
#include <exception>
#include "CoolKernel/ChannelId.h"
#include "CoolKernel/ValidityKey.h"
namespace cool {
//--------------------------------------------------------------------------
/** @class Exception Exception.h
*
* Top-level base exception class of the COOL package.
* Derived from std::exception.
*
* @author Andrea Valassi, Sven A. Schmidt and Marco Clemencic
* @date 2004-10-27
*///
class Exception : public std::exception {
public:
/// Constructor
explicit Exception( const std::string& message,
const std::string& domain )
: m_message( message )
, m_domain( domain ) {}
/// Destructor
virtual ~Exception() throw() {}
/// Error reporting method
virtual const char* what() const throw()
{
return m_message.c_str();
}
/// Return the error domain
virtual const std::string& domain() const
{
return m_domain;
}
protected:
/// Set the error message
virtual void setMessage( const std::string& message )
{
m_message = message;
}
private:
std::string m_message;
std::string m_domain;
};
//--------------------------------------------------------------------------
/** @class DatabaseNotOpen
*
* Exception thrown when a database is not open.
*///
class DatabaseNotOpen : public Exception {
public:
/// Constructor
explicit DatabaseNotOpen( const std::string& domain )
: Exception( "The database is not open", domain ) {}
/// Destructor
virtual ~DatabaseNotOpen() throw() {}
};
//--------------------------------------------------------------------------
/** @class DatabaseDoesNotExist
*
* Exception thrown when a database does not exist.
*///
class DatabaseDoesNotExist : public Exception {
public:
/// Constructor
explicit DatabaseDoesNotExist( const std::string& domain )
: Exception( "The database does not exist", domain ) {}
/// Destructor
virtual ~DatabaseDoesNotExist() throw() {}
};
//--------------------------------------------------------------------------
/** @class DatabaseOpenInReadOnlyMode
*
* Exception thrown when attempting to update a database
* that is open in read-only mode.
*///
class DatabaseOpenInReadOnlyMode : public Exception {
public:
/// Constructor
explicit DatabaseOpenInReadOnlyMode( const std::string& domain )
: Exception
( "The database is open in read-only mode and cannot be updated",
domain ) {}
/// Destructor
virtual ~DatabaseOpenInReadOnlyMode() throw() {}
};
//--------------------------------------------------------------------------
/** @class NodeExists
*
* Exception thrown during folder or folderset creation when
* a folder or folder set with that name already exists.
*///
class NodeExists : public Exception {
public:
/// Constructor
explicit NodeExists( const std::string& fullPath,
const std::string& domain )
: Exception( "Node " + fullPath + " already exists", domain ) {}
/// Destructor
virtual ~NodeExists() throw() {}
};
//--------------------------------------------------------------------------
/** @class NodeNotFound
*
* Exception thrown when a node with a given name, id and/or other
* properties cannot be found (e.g. a node with a given id does not exist,