CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Utilities/LStoreAdaptor/plugins/LStoreStorageMaker.cc

Go to the documentation of this file.
00001 #include "Utilities/StorageFactory/interface/StorageMaker.h"
00002 #include "Utilities/StorageFactory/interface/StorageMakerFactory.h"
00003 #include "Utilities/StorageFactory/interface/StorageFactory.h"
00004 #include "Utilities/LStoreAdaptor/interface/LStoreFile.h"
00005 #include "FWCore/Utilities/interface/Exception.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include <unistd.h>
00008 #include <iostream>
00009 
00010 class LStoreStorageMaker : public StorageMaker
00011 {
00012   public:
00015   virtual Storage *open (const std::string &proto,
00016              const std::string &path,
00017              int mode)
00018   {
00019         std::string fullpath = proto + ":" + path;
00020     return new LStoreFile (fullpath, mode);
00021   }
00022 
00023 /* I don't think this is necessary - Melo
00024   virtual void stagein (const std::string &proto, const std::string &path)
00025   {
00026     std::string fullpath(proto + ":" + path);
00027     XrdClientAdmin admin(fullpath.c_str());
00028     if (admin.Connect())
00029     {
00030       XrdOucString str(fullpath.c_str());
00031       XrdClientUrlSet url(str);
00032       admin.Prepare(url.GetFile().c_str(), kXR_stage | kXR_noerrs, 0);
00033     }
00034   }
00035 */
00036 
00037   virtual bool check (const std::string &proto,
00038               const std::string &path,
00039               IOOffset *size = 0)
00040   {
00041         std::string fullpath = proto + ":" + path;
00042         try {
00043                 LStoreFile fileObj( fullpath ); // = LStoreFile (fullpath);
00044                 *size = fileObj.position( 0, Storage::END );
00045         } catch ( cms::Exception & e) {
00046                 return false;
00047         }
00048         return true;
00049   }
00050 
00051 };
00052 DEFINE_EDM_PLUGIN (StorageMakerFactory, LStoreStorageMaker, "lstore");