Commit de2c8916 authored by Scott Snyder's avatar Scott Snyder Committed by Graeme Stewart
Browse files

Adjust for checkreq in AtlasPolicy-01-08-15 and fix other checkreq warnings....

Adjust for checkreq in AtlasPolicy-01-08-15 and fix other checkreq warnings. (CollectionBase-00-02-02)
parent 498978e1
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef COLLECTIONBASE_CATALOGCOLLECTIONCURSOR_H
#define COLLECTIONBASE_CATALOGCOLLECTIONCURSOR_H
#include "CollectionBase/ICollectionCursor.h"
#include <string>
#include <vector>
namespace pool {
class ISession;
class GuidContainer;
class ICollection;
class IFileCatalog;
class ICollectionQuery;
/**
* @class CatalogCollectionCursor CatalogCollectionCursor.h CollectionBase/CatalogCollectionCursor.h
*
* A cursor used to navigate over all collections registered in a collection catalog.
* Queries are possible using both collection level and row level metadata.
*/
class CatalogCollectionCursor : public ICollectionCursor
{
public:
/**
* Constructor.
*
* @param catalog Collection catalog manager.
* @param collectionLevelQuery Predicates for collection level queries.
* @param rowLevelQuery Predicates for row level queries.
* @param tokenOutputList Names of Token columns to be retrieved by row query.
* @param attribOutputList Names of attribute columns to be retrieved by row query.
* @param rowCacheSize Size of cache used to store rows retrieved by row query.
* @param session Database session.
*/
CatalogCollectionCursor( IFileCatalog& catalog,
std::string collectionLevelQuery = "",
std::string rowLevelQuery = "",
std::vector<std::string>* tokenOutputList = 0,
std::vector<std::string>* attribOutputList = 0,
int rowCacheSize = 0,
ISession* session = 0 );
/// Default destructor.
virtual ~CatalogCollectionCursor();
/// Advances the cursor to the next row of the query result set of the current collection.
virtual bool next();
/// Returns the event reference and associated metadata of the row pointed to by the cursor.
virtual const CollectionRowBuffer& currentRow() const;
/// Returns the event reference Token.
virtual const Token& eventRef() const;
/// Cleanup.
virtual void close();
private:
/// Collection catalog manager.
IFileCatalog& m_collectionCatalog;
/// Predicates for collection level query.
std::string m_collectionLevelQuery;
/// Predicates for row level query.
std::string m_rowLevelQuery;
/// Names of Token columns to be retreived by row query.
std::vector<std::string> m_tokenOutputList;
/// Names of attribute columns to be retreived by row query.
std::vector<std::string> m_attribOutputList;
/// Size of cache used to store rows retrieved by row query.
int m_rowCacheSize;
/// Database session.
ISession* m_session;
/// Container of collection catalog GUID's returned by query.
GuidContainer* m_guidContainer;
/// Current collection.
ICollection* m_collection;
/// Query object for current collection.
ICollectionQuery* m_query;
/// Current position in current collection.
ICollectionCursor* m_cursor;
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef COLLECTIONBASE_COLLECTIONBASENAMES_H
#define COLLECTIONBASE_COLLECTIONBASENAMES_H
#include <string>
namespace pool {
/**
* @class CollectionBaseNames CollectionBaseNames.h CollectionBase/CollectionBaseNames.h
*
* Utility class to define string literals for the CollectionBase package.
*/
class CollectionBaseNames
{
public:
/// The type name for objects of type pool::Token.
static std::string tokenTypeName();
/// The default name assigned to the event reference Token column of a collection.
static std::string defaultEventReferenceColumnName();
/// name of the key that holds CollectionID in the metadata
static std::string CollIDMdataKey();
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef COLLECTIONBASE_COLLECTIONCOLUMN_H
#define COLLECTIONBASE_COLLECTIONCOLUMN_H
#include "CollectionBase/ICollectionColumn.h"
#include "CoralBase/AttributeSpecification.h"
#include <typeinfo>
namespace pool {
/**
* @class CollectionColumn CollectionColumn.h CollectionBase/CollectionColumn.h
*
* An implementation of the ICollectionColumn interface for retrieving a description
* of a column of a collection.
*/
class CollectionColumn : virtual public pool::ICollectionColumn
{
public:
/// Default constructor.
CollectionColumn()
: m_name( "" ),
m_type( "" ),
m_fragmentName( "" ),
m_maxSize( 0 ),
m_sizeIsFixed( true ),
m_isUnique( false ),
m_id( 0 ) {}
/**
* Constructor that takes the column properties as input.
*
* @param name Name of column.
* @param type Data type of column.
* @param fragmentName Name of collection fragment that contains column.
* @param maxSize Maximum size of column data type.
* @param sizeIsFixed Flag to allow column data type to vary in size.
*/
CollectionColumn( const std::string& name,
const std::string& type,
std::string fragmentName = "",
int maxSize = 0,
bool sizeIsFixed = true )
: m_name( name ),
m_type( type ),
m_fragmentName( fragmentName ),
m_maxSize( maxSize ),
m_sizeIsFixed( sizeIsFixed ),
m_isUnique( false ),
m_id( 0 ) {}
/// Copy constructor.
CollectionColumn( const CollectionColumn& rhs )
: ICollectionColumn(),
m_name( rhs.m_name ),
m_type( rhs.m_type ),
m_fragmentName( rhs.m_fragmentName ),
m_maxSize( rhs.m_maxSize ),
m_sizeIsFixed( rhs.m_sizeIsFixed ),
m_isUnique( rhs.m_isUnique ),
m_id( rhs.m_id )
{}
/// Default destructor.
~CollectionColumn() {}
/// Assignment operator.
CollectionColumn& operator=( const CollectionColumn& rhs )
{
m_name = rhs.m_name;
m_type = rhs.m_type;
m_fragmentName = rhs.m_fragmentName;
m_maxSize = rhs.m_maxSize;
m_sizeIsFixed = rhs.m_sizeIsFixed;
m_isUnique = m_isUnique;
m_id = rhs.m_id;
return *this;
}
/// Equality operator.
bool operator==( const CollectionColumn& rhs ) const
{
return
m_name == rhs.m_name &&
m_type == rhs.m_type &&
// m_fragmentName == rhs.m_fragmentName && //MN - does not matter?
m_maxSize == rhs.m_maxSize &&
m_sizeIsFixed == rhs.m_sizeIsFixed &&
m_isUnique == rhs.m_isUnique
// && m_id == rhs.m_id //MN - does not matter?
;
}
/// Inequality operator.
bool operator!=( const CollectionColumn& rhs ) const
{
return !( *this == rhs );
}
/**
* Sets the name of the column.
*
* @param name Name of column.
*/
virtual void setName( const std::string& name ) { m_name = name; }
/**
* Sets the data type of the column.
*
* @param type Data type of column.
*/
virtual void setType( const std::string& type ) { m_type = type; }
/**
* Sets the data type of the column.
*
* @param type Data type of column.
*/
virtual void setType( const std::type_info& type )
{ m_type = coral::AttributeSpecification::typeNameForId( type ); }
/**
* Sets the name of the collection fragment that contains the column.
*
* @param name Name of collection fragment that contains column.
*/
virtual void setCollectionFragmentName( const std::string& fragmentName )
{ m_fragmentName = fragmentName; }
/**
* Sets the maximum size of the column data type. This method is useful for data
* of type string or blob.
*
* @param maxSize Maximum size of column data type.
*/
virtual void setMaxSize( int maxSize ) { m_maxSize = maxSize; }
/**
* Sets a flag indicating whether the size of the column data type may vary.
* This method is useful for data of type string or blob.
*
* @param sizeIsFixed Flag to allow column data type to vary in size.
*/
virtual void setSizeIsFixed( bool sizeIsFixed ) { m_sizeIsFixed = sizeIsFixed; }
/**
* If the column has an index, sets the uniqueness of index.
*
* @param isUnique Flag indicating whether index is unique.
*/
virtual void setIsUnique( bool isUnique ) { m_isUnique = isUnique; }
/// Sets the position of the column in its associated collection fragment.
virtual void setId( int id ) { m_id = id; }
/// Returns the user annotation for this column
virtual void setAnnotation( const std::string& anno ) { m_annotation = anno; }
/// Returns the name of the column.
virtual const std::string& name() const { return m_name; }
/// Returns the data type of the column.
virtual const std::string& type() const { return m_type; }
/// Returns the user annotation for this column
virtual const std::string& annotation() const { return m_annotation; }
/// Returns the name of the collection fragment that contains the column.
virtual const std::string& collectionFragmentName() const { return m_fragmentName; }
/**
* Returns the maximum size of the column data type. This information is useful for
* data of type string or blob.
*/
virtual int maxSize() const { return m_maxSize; }
/**
* Indicates whether the data type of the column can vary in size. This information
* is useful for data of type string or blob.
*/
virtual bool sizeIsFixed() const { return m_sizeIsFixed; }
/// If the column has an index, returns a flag indicating whether the index is unique.
virtual bool isUnique() const { return m_isUnique; }
/// Returns the position of the column in its associated collection fragment.
virtual int id() const { return m_id; }
private:
/// Name of column.
std::string m_name;
/// Data type of column.
std::string m_type;
/// User annotation
std::string m_annotation;
/// Name of collection fragment that contains column.
std::string m_fragmentName;
/// Maximum size of column data type.
int m_maxSize;
/// Flag indicating whether data type of column can vary in size.
bool m_sizeIsFixed;
/// Flag indicating whether index on column is unique.
bool m_isUnique;
/// Position of column in associated collection fragment.
int m_id;
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "CollectionBase/CollectionService.h"
#include "CollectionBase/ICollection.h"
#include "CollectionBase/ICollectionDescription.h"
#include "CollectionBase/CollectionDescription.h"
#include "CollectionBase/ICollectionSchemaEditor.h"
#include "CollectionBase/ICollectionDataEditor.h"
#include "CollectionBase/ICollectionColumn.h"
#include "CollectionBase/ICollectionQuery.h"
#include "CollectionBase/ICollectionCursor.h"
#include "CollectionBase/CollectionRowBuffer.h"
#include "CollectionBase/TokenList.h"
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef COLLECTIONBASE_COLLECTIONFACTORY_H
#define COLLECTIONBASE_COLLECTIONFACTORY_H
#include "CollectionBase/ICollection.h"
#include "CollectionBase/CollectionDescription.h"
#include "FileCatalog/FCCommon.h"
#include <string>
#include <vector>
namespace pool {
class ICollectionDescription;
class ISession;
class MetaDataEntry;
class ICollectionCursor;
class IFileCatalog;
/**
* @class CollectionFactory CollectionFactory.h CollectionFactory/CollectionFactory.h
*
* A plugin factory for the creation of storage technology specific collections or
* collection fragments, the latter of which contain a subset of the metadata of a
* full collection.
*/
class CollectionFactory
{
public:
/// Retrieves the collection factory singleton.
static CollectionFactory* get();
/**
* Creates an instance of a collection or collection fragment, given its storage technology
* type. If the collection or collection fragment does not exist a new one can be created.
* If it already exists it may be overwritten or opened for read or update transactions.
*
* @param type Storage technology type of collection or collection fragment.
* @param description Specification of collection or collection fragment properties.
* @param openMode Open mode for collection or collection fragment (CREATE, CREATE_AND_OVERWRITE, READ or UPDATE).
* @param session Reference to database session (only needed for implicit collections).
*/
virtual ICollection* create( const ICollectionDescription& description,
ICollection::OpenMode openMode,
ISession* session = 0 ) const;
/**
* Creates or overwrites a collection given a description of its properties, and registers
* it in a collection catalog. Throws an exception if the collection has been replicated,
* if an attempt is being made to overwrite an existing collection in CREATE open mode
* or if the object being registered is a collection fragment.
*
* @param description Specification of collection properties.
* @param collectionCatalog Collection catalog manager.
* @param overwrite Flag indicating whether to overwrite existing collection.
* @param logicalName Optional logical name assigned to collection in collection catalog.
* @param metadata Optional collection catalog metadata.
* @param session Reference to database session (place holder for factory).
*/
virtual ICollection* createAndRegister( const ICollectionDescription& description,
IFileCatalog* collectionCatalog,
bool overwrite = false,
std::string logicalName = "",
MetaDataEntry* metadata = 0,
ISession* session = 0 ) const;
/**
* Registers an existing collection in a collection catalog, given a specification of its
* properties. Throws an exception if the collection does not exist, if a collection has
* already been registered in the catalog with identical physical name, or if the object
* being registered is a collection fragment.
* NOTE: will open the collection - do NOT use if you opened the collection for update
* - see the other registerExisting() method
*
* @param description Specification of collection properties.
* @param collectionCatalog Collection catalog manager.
* @param logicalName Optional logical name assigned to collection in collection catalog.
* @param metadata Optional collection catalog metadata.
* @param session Reference to database session (place holder for factory).
*/
virtual bool registerExisting( const ICollectionDescription& description,
IFileCatalog* collectionCatalog,
std::string logicalName = "",
MetaDataEntry* metadata = 0,
ISession* session = 0 ) const;
/**
* Registers an existing collection in a collection catalog, but uses user-supplied
* exiting collection object
*
* @param collection The collection to register
* @param overwrite If true overwrite catalog entry for the same collection name
* @param collectionCatalog Collection catalog manager.
* @param logicalName Optional logical name assigned to collection in collection catalog.
* @param metadata Optional collection catalog metadata.
* @param session Reference to database session (place holder for factory).
*/
virtual bool registerExisting( ICollection* collection,
bool overwrite,
IFileCatalog* collectionCatalog,
std::string logicalName = "",
MetaDataEntry* metadata = 0,
ISession* session = 0 ) const;
/**
* Opens an existing collection for read or update transactions, given its physical name.
* Throws an exception if a collection with this physical name cannot be found in the catalog.
*
* @param physicalName Physical name of collection in collection catalog.
* @param collectionCatalog Collection catalog manager.
* @param openMode The mode in which to open the collection
* @param session Reference to database session (place holder for factory).
*/
virtual ICollection* openWithPhysicalName( const std::string& physicalName,
IFileCatalog* collectionCatalog,
ICollection::OpenMode openMode = pool::ICollection::READ,
ISession* session = 0 ) const;
/**
* Opens an existing collection for read or update transactions, given a logical name
* assigned to it in a collection catalog. Throws an exception if a collection with this
* logical name cannot be found in the catalog.
*
* @param LogicalName Logical name of collection in collection catalog.
* @param collectionCatalog Collection catalog manager.
* @param readOnly Flag indicating whether collection is opened for read or update.
* @param session Reference to database session (place holder for factory).
*/
virtual ICollection* openWithLogicalName( const std::string& logicalName,
IFileCatalog* collectionCatalog,
bool readOnly = true,
ISession* session = 0 ) const;
/**
* Opens an existing collection for read or update transactions, given the globally unique
* identifier used to register it in a collection catalog. Throws an exception if a collection
* with this GUID cannot be found in the catalog.
*
* @param guid Globally unique identifier of collection in collection catalog.
* @param catalog Collection catalog manager.
* @param readOnly Flag indicating whether collection is opened for read or update.
* @param session Reference to database session (place holder for factory).
*/
virtual ICollection* openWithGuid( const FileCatalog::FileID& guid,
IFileCatalog* collectionCatalog,
bool readOnly = true,
ISession* session = 0 ) const;
// resolve PHYSICAL_NAME, LOGICAL_NAME and GUID notation (using catalog)
virtual void resolveDescription( CollectionDescription& description, bool readOnly = true ) const;
virtual CollectionDescription descFromPhysicalName( const std::string& physicalName,
IFileCatalog* collectionCatalog,
bool readOnly ) const;
virtual CollectionDescription descFromLogicalName( const std::string& logicalName,
IFileCatalog* collectionCatalog,
bool readOnly ) const;
virtual CollectionDescription descFromGuid( const FileCatalog::FileID& guid,
IFileCatalog* collectionCatalog,
bool readOnly ) const;
/**
* Returns a cursor for the navigation over collections registered in a collection catalog.
* Queries are possible at both the collection and row levels.
*
* @param collectionCatalog Collection catalog manager.
* @param collectionLevelQuery Predicates for collection level query.
* @param rowLevelQuery Predicates for row level query.
* @param tokenOutputList Names of Token columns to be retrieved by row level query.
* @param attribOutputList Names of attribute columns to be retrieved by row level query.
* @param rowCacheSize Size of cache used to store rows retrieved by row level query.
* @param session Reference to database session (place holder for factory).
*/
virtual ICollectionCursor* getCatalogCollectionCursor( IFileCatalog* collectionCatalog,
std::string collectionLevelQuery = "",
std::string rowLevelQuery = "",
std::vector<std::string>* tokenOutputList = 0,
std::vector<std::string>* attribOutputList = 0,
int rowCacheSize = 0,
ISession* session = 0 ) const;
/// Read POOL_OUTMSG_LEVEL variable and set logging level accordingly
virtual void setOutputLevel() const;
/// set external file catalog (it will not be deleted)
/// pass 0 to reset the existing file catalog
void setDefaultCatalog( pool::IFileCatalog* catalog);
/// set write catalog (once it is set, it can only be changed by resetting)
void setWriteCatalog( const std::string &cat );
/// get the default file catalog
/// if there was no file catalog, new one will be created according
/// to environment variables POOL_COLLECTION_[WRITE|READ]_CATALOG
IFileCatalog* getDefaultCatalog() const;
private:
/// Default constructor.
CollectionFactory();
/// Default destructor.