Commit 2b3a8894 authored by Andrea Valassi's avatar Andrea Valassi Committed by cdelort
Browse files

Move old trunk to trunk/src

git-svn-id: https://svnweb.cern.ch/trac/lcgcool/changeset/19472 4525493e-7705-40b1-a816-d608a930855b
parent c06d3bdc
#ifndef COOLAPPLICATION_APPLICATION_H
#define COOLAPPLICATION_APPLICATION_H 1
// First of all, enable or disable the COOL290 API extensions (see bug #92204)
#include "CoolKernel/VersionInfo.h"
// Include files
#include "CoolApplication/IApplication.h"
namespace cool
{
/**********************************************************************
** NB: this class should only be used in _STANDALONE_ applications **
** that cannot retrieve the IDatabaseSvc as a plugin because they **
** do not directly manage the loading of plugins into contexts. **
***********************************************************************
*
* @class Application Application.h
*
* COOL application class.
*
* This class takes care of loading all plugins needed to run COOL, using
* the relevant plugin technology. The implementation details (presently
* based on SEAL, later on CORAL or ROOT) are hidden from the public API.
*
* @author Andrea Valassi, Sven A. Schmidt and Marco Clemencic
* @date 2007-01-17
*///
/// AV 18.01.2007 - do NOT use virtual inheritance here!
/// For reasons that are still unclear, this makes it impossible to fetch
/// the COOL database service (the concrete RalDatabaseSvc is loaded and
/// instantiated, but it cannot be dynamic cast to an IDatabaseSvc...?
/// AV 05.07.2007 - removed all unnecessary virtual inheritance (task #4879).
//class Application : virtual public IApplication
class Application : public IApplication
{
public:
/// Constructor from a CORAL ConnectionService (if one is provided,
/// the user is responsible to keep it alive until the application is
/// alive; if none is provided, a new own one is created if necessary).
Application( coral::IConnectionService* connSvc = 0 );
/// Destructor.
virtual ~Application();
/// Retrieve a reference to the COOL database service.
IDatabaseSvc& databaseService()
{
return m_application->databaseService();
}
/// Get the output level threshold for COOL (and CORAL) messages.
/// *** WARNING: this may actually return a shared (static) value. ***
MSG::Level outputLevel()
{
return m_application->outputLevel();
}
/// Set the output level threshold for COOL (and CORAL) messages.
/// *** WARNING: this may actually change a shared (static) value. ***
void setOutputLevel( MSG::Level level )
{
m_application->setOutputLevel( level );
}
/// Get the SEAL context (if any) associated with this application.
/// *** WARNING: throws an exception for applications not using SEAL. ***
seal::Context* context() const
{
return m_application->context();
}
/// Get the CORAL connection service (if any) used in this application.
/// *** WARNING: throws an exception for applications not using CORAL. ***
coral::IConnectionService& connectionSvc() const
{
return m_application->connectionSvc();
}
#ifdef COOL290CO
private:
/// Copy constructor is private (fix Coverity MISSING_COPY bug #95363)
Application( const Application& rhs );
/// Assignment operator is private (fix Coverity MISSING_ASSIGN bug #95363)
Application& operator=( const Application& rhs );
#endif
private:
/// Privately owned implementation class to which all calls are delegated.
IApplication* m_application;
};
}
#endif // COOLAPPLICATION_APPLICATION_H
#ifndef COOLAPPLICATION_DATABASESVCFACTORY_H
#define COOLAPPLICATION_DATABASESVCFACTORY_H 1
namespace cool
{
// Forward declarations
class IDatabaseSvc;
/**********************************************************************
** NB: this class should only be used in _STANDALONE_ applications **
** that cannot retrieve the IDatabaseSvc as a plugin because they **
** do not directly manage the loading of plugins into contexts. **
***********************************************************************
*
* @class DatabaseSvcFactory DatabaseSvcFactory.h
*
* Factory of standalone DatabaseSvc instances.
*
* This class takes care of loading all plugins needed to run COOL, using
* the relevant plugin technology. The implementation details (presently
* based on SEAL, later on CORAL or ROOT) are hidden from the public API.
*
* The application used to retrieve the service is a singleton owned by the
* class: the same service is returned by successive calls to databaseSvc().
*
* @author Andrea Valassi and Sven A. Schmidt
* @date 2004-12-08
*///
class DatabaseSvcFactory {
public:
/// Retrieve a reference to the COOL database service.
static IDatabaseSvc& databaseService();
};
}
#endif // COOLAPPLICATION_DATABASESVCFACTORY_H
#ifndef COOLAPPLICATION_IAPPLICATION_H
#define COOLAPPLICATION_IAPPLICATION_H 1
// Header was moved to CoolKernel in COOL 2.6.0 to remove cyclic dependencies
// The CoolApplication copy is kept for backward compatibility in the user API
#include "CoolKernel/IApplication.h"
#endif // COOLAPPLICATION_IAPPLICATION_H
#ifndef COOLAPPLICATION_MESSAGELEVELS_H
#define COOLAPPLICATION_MESSAGELEVELS_H 1
// Header was moved to CoolKernel in COOL 2.6.0 to remove cyclic dependencies
// The CoolApplication copy is kept for backward compatibility in the user API
#include "CoolKernel/MessageLevels.h"
#endif // COOLAPPLICATION_MESSAGELEVELS_H
package CoolApplication
#============================================================================
# Public dependencies and build rules
#============================================================================
use CoolKernel v*
use RelationalCool v*
#----------------------------------------------------------------------------
# Library
#----------------------------------------------------------------------------
apply_pattern include_dir_policy
apply_pattern lcg_shared_library
#============================================================================
# Private dependencies and build rules
#============================================================================
private
###macro_append use_linkopts ' $(Boost_linkopts_thread)'
# Link the CORAL libraries
apply_tag NEEDS_CORAL_BASE
# Fake target for tests
action tests "echo No tests in this package"
macro_remove cmt_actions_constituents "tests"
# Fake target for utilities
action utilities "echo No utilities in this package"
macro_remove cmt_actions_constituents "utilities"
# Fake target for examples
action examples "echo No examples in this package"
macro_remove cmt_actions_constituents "examples"
This diff is collapsed.
// Include files
//#include <iostream>
#include "CoolApplication/Application.h"
#include "../RelationalCool/src/CoralApplication.h"
// Namespace
using namespace cool;
// Message output
//#define COUT std::cout << "__cool::Application "
//#define ENDL std::endl
//-----------------------------------------------------------------------------
Application::Application( coral::IConnectionService* connSvc )
{
//COUT << "Application(): ** START **" << std::endl;
m_application = new CoralApplication( connSvc );
//COUT << "Application(): *** END ***" << ENDL;
}
//-----------------------------------------------------------------------------
Application::~Application()
{
//COUT << "~Application(): ** START **" << ENDL;
delete m_application;
//COUT << "~Application(): *** END ***" << ENDL;
}
//-----------------------------------------------------------------------------
// Include files
#include <memory>
#include "CoolApplication/Application.h"
#include "CoolApplication/DatabaseSvcFactory.h"
// Namespace
using namespace cool;
//-----------------------------------------------------------------------------
IDatabaseSvc&
DatabaseSvcFactory::databaseService()
{
/*
static std::auto_ptr<Application> pApp;
if ( ! pApp.get() ) {
pApp.reset( new Application() );
}
return pApp->databaseService();
*///
static Application app;
return app.databaseService();
}
//-----------------------------------------------------------------------------
#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
#ifndef RELATIONALCOOL_CONSTRECORDADAPTER_H
#define RELATIONALCOOL_CONSTRECORDADAPTER_H 1
// Include files
#include "CoolKernel/IRecord.h"
#include "CoolKernel/RecordSpecification.h"