[brlcad-commits] SF.net SVN: brlcad: [31678] rt^3/trunk/src/g3d/Commands.h
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <ma...@us...> - 2008-07-01 11:05:44
|
Revision: 31678 http://brlcad.svn.sourceforge.net/brlcad/?rev=31678&view=rev Author: mafm Date: 2008-07-01 04:05:53 -0700 (Tue, 01 Jul 2008) Log Message: ----------- Adding a couple of commands (quit, set log level) Added Paths: ----------- rt^3/trunk/src/g3d/Commands.h Added: rt^3/trunk/src/g3d/Commands.h =================================================================== --- rt^3/trunk/src/g3d/Commands.h (rev 0) +++ rt^3/trunk/src/g3d/Commands.h 2008-07-01 11:05:53 UTC (rev 31678) @@ -0,0 +1,99 @@ +/* C O M M A N D S . H + * BRL-CAD + * + * Copyright (c) 2008 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + +/** @file Commands.h + * + * @author Manuel A. Fernandez Montecelo <ma...@us...> + * + * @brief + * Implementation of commands. + */ + + +#include "Application.h" + +#include "CommandInterpreter.h" + + +/** @brief Quit the application + * + * @author Manuel A. Fernandez Montecelo <ma...@us...> + */ +class CommandQuit : public Command +{ +public: + CommandQuit() : Command("quit", "Quit the application", "") { } + + virtual void execute(std::vector<std::string>& args, CommandOutput& out) { + if (args.size() > 0) { + out.appendLine("Command doesn't accept arguments, ignoring"); + } + + Application::instance().quit(); + } +}; + + +/** @brief Set log message level. + * + * @author Manuel A. Fernandez Montecelo <ma...@us...> + */ +class CommandSetLogLevel : public Command +{ +public: + CommandSetLogLevel() : + Command("loglevel", "Set the log message level", "Argument is first letter of Debug, Info, Warning, Error, Fatal") + { + _argNames.push_back("level"); + } + + virtual void execute(std::vector<std::string>& args , CommandOutput& out) { + if (args.size() != 1) { + out.appendLine("This command needs exactly one argument"); + return; + } + + Logger::Level l = static_cast<Logger::Level>(0); // invalid level + char firstChar = args[0][0]; + if (firstChar == 'D') { + l = Logger::DEBUG; + } else if (firstChar == 'I') { + l = Logger::INFO; + } else if (firstChar == 'W') { + l = Logger::WARNING; + } else if (firstChar == 'E') { + l = Logger::ERROR; + } else if (firstChar == 'F') { + l = Logger::FATAL; + } + + Logger::setLevelFilter(l); + } +}; + + +// Local Variables: *** +// mode: C++ *** +// tab-width: 8 *** +// c-basic-offset: 2 *** +// indent-tabs-mode: t *** +// End: *** +// ex: shiftwidth=2 tabstop=8 + Property changes on: rt^3/trunk/src/g3d/Commands.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |