// BLCMDload.cc /* This source file is part of G4beamline, http://g4beamline.muonsinc.com Copyright (C) 2003,2004,2005,2006 by Tom Roberts, all rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html */ #ifdef USE_SHARED_OBJECTS #include "BLCommand.hh" #include "BLLoad.hh" /** class BLCMDload implements the load command to load a * shared object. * **/ class BLCMDload : public BLCommand { public: BLCMDload(); G4String commandName() { return "load"; } int command(BLArgumentVector& argv, BLArgumentMap& namedArgs); // no arguments. }; BLCMDload defineLoad; BLCMDload::BLCMDload() { registerCommand(BLCMDTYPE_CONTROL); setSynopsis("load a shared object."); setDescription("load requires one argument, the file to load." "If no '/' or '\\' is present in the name, it will be " "searched for in the usual way. " "Normally no extension is used (.so, .dylib, or .dll); " "this function then appends those extensions in order until a " "file is found. Loading an already loaded shared object " "does nothing (no error)."); } int BLCMDload::command(BLArgumentVector& argv, BLArgumentMap& namedArgs) { if(argv.size() != 1 || namedArgs.size() != 0) { printError("Invalid load command"); return -1; } if(BLLoad::load(argv[0])) { printf("load: loaded '%s'\n",argv[0].c_str()); } else { printError("Cannot load shared object '%s': %s\n", argv[0].c_str(),BLLoad::errorString()); return -1; } return 0; } #else int BLCMDload_dummy; #endif // USE_SHARED_OBJECTS