CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CondDBImport.cc
Go to the documentation of this file.
1 //
2 
3 //TO DO: add the comparison between stored object and input object - bool cond::serialization::equal( obj,read_back_copy )
4 #define IMPORT_PAYLOAD_CASE( TYPENAME ) \
5  if( inputTypeName == #TYPENAME ){ \
6  match = true; \
7  const TYPENAME& obj = *static_cast<const TYPENAME*>( inputPtr ); \
8  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() ); \
9  }
10 
11 #define IGNORE_FOR_IMPORT_CASE( TYPENAME ) \
12  if( inputTypeName == #TYPENAME ){ \
13  match = true; \
14  payloadId = 0; \
15  newInsert = false; \
16  std::cout <<"WARNING: typename "<<inputTypeName<<" will be skipped in the import."<<std::endl; \
17  }
18 
19 #define FETCH_PAYLOAD_CASE( TYPENAME ) \
20  if( payloadTypeName == #TYPENAME ){ \
21  auto payload = deserialize<TYPENAME>( payloadTypeName, data ); \
22  payloadPtr = payload; \
23  match = true; \
24  }
25 
29 #include "CondFormats.h"
30 //
31 #include <sstream>
32 
33 namespace cond {
34 
35  namespace persistency {
36 
37  cond::Hash import( const std::string& inputTypeName, const void* inputPtr, Session& destination ){
38  cond::Hash payloadId("");
39  bool newInsert = false;
40  bool match = false;
41  if( inputPtr ){
43  IMPORT_PAYLOAD_CASE( std::vector<unsigned long long> )
232  //IMPORT_PAYLOAD_CASE( PerformancePayload )
281  if( inputTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
282  match = true;
284  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
285  }
286  if( inputTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
287  match = true;
289  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
290  }
291 
292 
293  if( ! match ) throwException( "Payload type \""+inputTypeName+"\" is unknown.","import" );
294  }
295  return payloadId;
296  }
297 
298  std::pair<std::string,boost::shared_ptr<void> > fetch( const cond::Hash& payloadId, Session& session ){
299  boost::shared_ptr<void> payloadPtr;
301  std::string payloadTypeName;
302  bool found = session.fetchPayloadData( payloadId, payloadTypeName, data );
303  if( !found ) throwException( "Payload with id "+boost::lexical_cast<std::string>(payloadId)+" has not been found in the database.","fetchAndCompare" );
304  //std::cout <<"--> payload type "<<payloadTypeName<<" has blob size "<<data.size()<<std::endl;
305  bool match = false;
307  FETCH_PAYLOAD_CASE( std::vector<unsigned long long> )
473  //FETCH_PAYLOAD_CASE( PerformancePayload )
522 
523  //
524  if( payloadTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
525  auto payload = deserialize<PhysicsTools::Calibration::Histogram3D<double,double,double,double> >(payloadTypeName, data );
526  payloadPtr = payload;
527  match = true;
528  }
529  if( payloadTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
530  auto payload = deserialize<PhysicsTools::Calibration::Histogram2D<double,double,double> >(payloadTypeName, data );
531  payloadPtr = payload;
532  match = true;
533  }
534 
535 
536  if( ! match ) throwException( "Payload type \""+payloadTypeName+"\" is unknown.","fetch" );
537  return std::make_pair( payloadTypeName, payloadPtr );
538  }
539 
540  }
541 }
542 
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData)
Definition: Session.cc:168
Definition: ESGain.h:5
#define FETCH_PAYLOAD_CASE(TYPENAME)
Definition: CondDBImport.cc:19
Definition: DTT0.h:52
#define IMPORT_PAYLOAD_CASE(TYPENAME)
Definition: CondDBImport.cc:4
std::string Hash
Definition: Types.h:34
std::pair< std::string, boost::shared_ptr< void > > fetch(const cond::Hash &payloadId, Session &session)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11