xrootd
XrdClFSExecutor.hh
Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
00003 // Author: Lukasz Janyst <ljanyst@cern.ch>
00004 //------------------------------------------------------------------------------
00005 // XRootD is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // XRootD is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
00017 //------------------------------------------------------------------------------
00018 
00019 #ifndef __XRD_CL_FS_EXECUTOR_HH__
00020 #define __XRD_CL_FS_EXECUTOR_HH__
00021 
00022 #include "XrdCl/XrdClFileSystem.hh"
00023 #include "XrdCl/XrdClEnv.hh"
00024 #include "XrdCl/XrdClUtils.hh"
00025 #include <vector>
00026 #include <string>
00027 #include <map>
00028 
00029 namespace XrdCl
00030 {
00031   //----------------------------------------------------------------------------
00033   //----------------------------------------------------------------------------
00034   class FSExecutor
00035   {
00036     public:
00037       //------------------------------------------------------------------------
00039       //------------------------------------------------------------------------
00040       typedef std::vector<std::string> CommandParams;
00041 
00042       //------------------------------------------------------------------------
00044       //------------------------------------------------------------------------
00045       typedef XRootDStatus (*Command)( FileSystem          *fs,
00046                                        Env                 *env,
00047                                        const CommandParams &args );
00048 
00049       //------------------------------------------------------------------------
00054       //------------------------------------------------------------------------
00055       FSExecutor( const URL &url, Env *env = 0 );
00056 
00057       //------------------------------------------------------------------------
00059       //------------------------------------------------------------------------
00060       ~FSExecutor();
00061 
00062       //------------------------------------------------------------------------
00068       //------------------------------------------------------------------------
00069       bool AddCommand( const std::string &name, Command command );
00070 
00071       //------------------------------------------------------------------------
00078       //------------------------------------------------------------------------
00079       XRootDStatus Execute( const std::string &commandline );
00080 
00081       //------------------------------------------------------------------------
00083       //------------------------------------------------------------------------
00084       Env *GetEnv()
00085       {
00086         return pEnv;
00087       }
00088 
00089     private:
00090       typedef std::map<std::string, Command> CommandMap;
00091       FileSystem  *pFS;
00092       Env         *pEnv;
00093       CommandMap   pCommands;
00094   };
00095 }
00096 
00097 #endif // __XRD_CL_FS_EXECUTOR_HH__