CommandParser.hpp

00001 /***************************************************************************
00002   tag: Peter Soetens  Mon Jan 19 14:11:26 CET 2004  CommandParser.hpp
00003 
00004                         CommandParser.hpp -  description
00005                            -------------------
00006     begin                : Mon January 19 2004
00007     copyright            : (C) 2004 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.ac.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 #ifndef COMMANDPARSER_HPP
00039 #define COMMANDPARSER_HPP
00040 
00041 #include "parser-types.hpp"
00042 #include "../PropertyBag.hpp"
00043 #include "CommonParser.hpp"
00044 #include "ExpressionParser.hpp"
00045 #include "PeerParser.hpp"
00046 
00047 #ifdef ORO_PRAGMA_INTERFACE
00048 #pragma interface
00049 #endif
00050 
00051 namespace RTT
00052 {
00053     class DispatchInterface;
00054     namespace detail {
00055 
00056 
00064   class CommandParser
00065   {
00066     // the object that the user wants to call a method on, in the
00067     // current call command..
00068     std::string mcurobject;
00069 
00070     // the method the user wants to call in the current call command..
00071     std::string mcurmethod;
00072 
00073       // dispatch the command per definition or let it be context dependent.
00074       bool mas_action;
00075 
00076     DispatchInterface* dcom;
00077     CommandInterface* retcommand;
00078     ConditionInterface* implicittermcondition;
00079     ConditionInterface* dispatchCond;
00080     TaskContext* peer;
00081 
00082     void seenmethodname( iter_t begin, iter_t end )
00083       {
00084         std::string methodname( begin, end );
00085         mcurmethod = methodname;
00086       };
00087 
00088     void seenstartofcall();
00089     void seennopcommand();
00090 
00091     void seencallcommand();
00092 
00093     rule_t objectmethod, command, callcommand, nopcommand, arguments;
00094 
00095     TaskContext* context;
00096     CommonParser& commonparser;
00097     ArgumentsParser* argsparser;
00098     ExpressionParser expressionparser;
00099       PeerParser peerparser;
00100   public:
00107       CommandParser( TaskContext* context, CommonParser& cp, bool as_action );
00108     ~CommandParser();
00109 
00110       bool foundObject() {
00111           return !mcurobject.empty();
00112       }
00113       bool foundMethod() {
00114           return !mcurmethod.empty();
00115       }
00116 
00117     rule_t& parser()
00118       {
00119         return command;
00120       };
00121 
00126       ConditionInterface* wrapCondition( ConditionInterface* );
00127 
00136       ConditionInterface* dispatchCondition();
00137 
00143     CommandInterface* getCommand()
00144       {
00145         return retcommand;
00146       }
00147 
00153     ConditionInterface* getImplTermCondition()
00154       {
00155         return implicittermcondition;
00156       }
00157 
00162       void reset();
00163   };
00164 }}
00165 
00166 #endif
Generated on Thu Dec 23 13:22:38 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3