X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FExecutor.hh;h=d089083113176b545e54b723f1d97ea88ea801e1;hb=2d5a1fd2cef2d84e16226a7336948f524fbb71c6;hp=189eece2c3702e6c7ac93b614fd86dff3db03681;hpb=9ff18548815d10140e83fba6ed2d573fe556c346;p=senf.git diff --git a/Console/Executor.hh b/Console/Executor.hh index 189eece..d089083 100644 --- a/Console/Executor.hh +++ b/Console/Executor.hh @@ -38,7 +38,21 @@ namespace senf { namespace console { - /** \brief + /** \brief Execute config/console commands + + The Executor interprets parsed config/console commands and executes them. It manages the + current execution context (current directory, directory stack and so on). + + The executor is normally called directly by the parser callback for each command. + + Executing the built-in 'exit' command will throw Executor::ExitException. This exception + (which is not derived from std::exception since it's not a real exception) must be handled + by the caller. + + All directories are managed using weak pointers. If any of the directories expires (current + directory, directory stack, last directory) it will be replaced with the root + directory. Directories expire when they are destructed or when they are detached from the + config tree root node. */ class Executor : boost::noncopyable @@ -51,7 +65,8 @@ namespace console { typedef boost::iterator_range< ParseCommandInfo::argument_iterator> Arguments; - struct ExitException {}; // NOT derived from std::exception ! + /// Thrown by built-in 'exit' command + struct ExitException {}; /////////////////////////////////////////////////////////////////////////// //\/name Structors and default members @@ -62,15 +77,19 @@ namespace console { ///\} /////////////////////////////////////////////////////////////////////////// - bool operator()(ParseCommandInfo const & command, std::ostream & output); - DirectoryNode & cwd() const; + void operator()(ParseCommandInfo const & command, std::ostream & output); + ///< Execute command + /**< Output will be written to \a output. */ + DirectoryNode & cwd() const; ///< Current working directory protected: private: - DirectoryNode & traverseTo(ParseCommandInfo::argument_value_type const & path); - CommandNode & traverseToCommand(ParseCommandInfo::CommandPathRange const & path); + GenericNode & traverseNode(ParseCommandInfo::argument_value_type const & path); + DirectoryNode & traverseDirectory(ParseCommandInfo::argument_value_type const & path); + CommandNode & traverseCommand(ParseCommandInfo::CommandPathRange const & path); + struct InvalidPathException {}; struct InvalidDirectoryException {}; struct InvalidCommandException {};