Go to the documentation of this file.00001 #ifndef CondCore_IOVService_IOVEditor_h
00002 #define CondCore_IOVService_IOVEditor_h
00003
00004 #include "CondCore/IOVService/interface/IOVProxy.h"
00005
00006 #include "CondCore/DBCommon/interface/Time.h"
00007 #include "CondFormats/Common/interface/IOVSequence.h"
00008
00009
00010
00011
00012
00016
00017
00018
00019
00020
00021 namespace cond{
00022
00023 class IOVElement;
00024 class IOVSequence;
00025
00026 class IOVImportIterator {
00027 public:
00028 explicit IOVImportIterator( boost::shared_ptr<cond::IOVProxyData>& destIov );
00029
00030 virtual ~IOVImportIterator();
00031
00032 void setUp( cond::IOVProxy& sourceIov, cond::Time_t since, cond::Time_t till, bool outOfOrder, size_t bulkSize = 1 );
00033
00034 void setUp( cond::DbSession& sourceSess, const std::string& sourceIovToken, cond::Time_t since, cond::Time_t till,
00035 bool outOfOrder, size_t bulkSize = 1 );
00036
00037 void setUp( cond::IOVProxy& sourceIov, size_t bulkSize = 1 );
00038
00039 void setUp( cond::DbSession& sourceSess, const std::string& sourceIovToken, size_t bulkSize = 1 );
00040
00041 bool hasMoreElements();
00042
00043 size_t importMoreElements();
00044
00045 size_t importAll();
00046
00047 private:
00048 cond::IOVProxy m_sourceIov;
00049 boost::shared_ptr<cond::IOVProxyData> m_destIov;
00050 cond::Time_t m_lastSince;
00051 size_t m_bulkSize;
00052 IOVSequence::const_iterator m_cursor;
00053 IOVSequence::const_iterator m_till;
00054 };
00055
00056 class IOVEditor{
00057 public:
00058
00059
00060 explicit IOVEditor(cond::DbSession& dbSess);
00061
00062
00063 IOVEditor( cond::DbSession& dbSess, const std::string& token);
00064
00066 ~IOVEditor();
00067
00068 void reload();
00069
00070 void load( const std::string& token );
00071
00072 bool createIOVContainerIfNecessary();
00073
00074
00075 std::string create( cond::TimeType timetype );
00076
00077
00078 std::string create(cond::TimeType timetype, cond::Time_t lastTill, const std::string& metadata );
00079
00080
00081 std::string create(cond::TimeType timetype, cond::Time_t lastTill );
00082
00084 unsigned int insert( cond::Time_t tillTime, const std::string& payloadToken );
00085
00088 unsigned int append( cond::Time_t sinceTime, const std::string& payloadToken );
00089
00091 unsigned int freeInsert( cond::Time_t sinceTime, const std::string& payloadToken );
00092
00094 void bulkAppend( std::vector< std::pair<cond::Time_t, std::string > >& values );
00095
00096 void bulkAppend(std::vector< cond::IOVElement >& values);
00097
00098
00099 void stamp(std::string const & icomment, bool append=false);
00100
00102 void editMetadata( std::string const & metadata, bool append=false);
00103
00105 void setScope( cond::IOVSequence::ScopeType scope );
00106
00108 void updateClosure( cond::Time_t newtillTime );
00109
00110
00111 unsigned int truncate(bool withPayload=false);
00112
00113
00114 void deleteEntries( bool withPayload=false);
00115
00116
00117 size_t import( cond::DbSession& sourceSess, const std::string& sourceIovToken );
00118
00119
00120 boost::shared_ptr<IOVImportIterator> importIterator();
00121
00122 TimeType timetype() const;
00123
00124 std::string const & token() const;
00125
00126 cond::IOVProxy proxy();
00127
00128 private:
00129
00130 bool validTime(cond::Time_t time, cond::TimeType timetype) const;
00131 bool validTime(cond::Time_t time) const;
00132
00133 void debugInfo(std::ostream & co) const;
00134 void reportError(std::string message) const;
00135 void reportError(std::string message, cond::Time_t time) const;
00136
00137 private:
00138
00139 bool m_isLoaded;
00140 boost::shared_ptr<cond::IOVProxyData> m_iov;
00141 };
00142 }
00143 #endif