RPCInterface.hh 4.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
//=============================================================================
//
//                               OpenFlipper
//        Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
//                           www.openflipper.org
//
//-----------------------------------------------------------------------------
//
//                                License
//
//  OpenFlipper is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  OpenFlipper 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 OpenFlipper.  If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
//   $Revision$
//   $Author$
//   $Date$
//
//=============================================================================




//
// C++ Interface: RPCInterface
//
// Description:
//
//
// Author: Jan Moebius <jan_moebius@web.de>, (C) 2007
//

#ifndef RPCINTERFACE_HH
#define RPCINTERFACE_HH

Jan Möbius's avatar
Jan Möbius committed
47 48
#include <OpenFlipper/BasePlugin/RPCWrappers.hh>

49 50 51 52
/** Interface for all Plugins which do remote procedure calls ( and cross plugin calls)
*/
class RPCInterface {

53
   public:
Jan Möbius's avatar
Jan Möbius committed
54

55 56 57 58
      /// Destructor
      virtual ~RPCInterface() {};

   signals :
59 60 61 62 63

     /** Check if the plugin exists in the current Environment \n
       * @param _pluginName Name of the Plugin (has to be the clean version .. no Spaces etc)
       * @param _exists found or not
       */
Dirk Wilden's avatar
Dirk Wilden committed
64
    virtual void pluginExists( QString /*_pluginName*/ , bool& /*_exists*/  ) {};
65 66 67 68 69 70 71


    /** Check if a plugin exists and provides the given function \n
       * @param _pluginName Name of the Plugin (has to be the clean version .. no Spaces etc)
       * @param _functionName requested function
       * @param _exists found or not
       */
Dirk Wilden's avatar
Dirk Wilden committed
72
    virtual void functionExists( QString /*_pluginName*/ , QString /*_functionName*/ , bool& /*_exists*/  ) {};
73 74 75 76 77 78 79

    /** Execute the function of the given plugin \n
       *
       * @param _pluginName Name of the Plugin (has to be the clean version .. no Spaces etc)
       * @param _functionName requested function
       * @param _success Function call succeeded
    */
Dirk Wilden's avatar
Dirk Wilden committed
80
    virtual void call( QString /*_pluginName*/ , QString /*_functionName*/ , bool& /*_success*/  ) {};
81 82 83 84 85 86 87

    /** Executes the given expression.
     * No checks are performed if the remote function is available.
     *
     * @param _expression command to execute
     * @param _success successfull execution?
     */
Dirk Wilden's avatar
Dirk Wilden committed
88
    virtual void call( QString /*_expression*/ , bool& /*_success*/  ) {};
89 90 91 92 93 94 95 96 97 98 99

    /** Executes the given expression and returns the result
     *  No checks are performed if the remote function is available.
     *  if an error occurs the result contains an invalid QVariant
     *
     * ex. getValue("databaseplugin.tableExists(\"meshes\")", result) )
     *     result.toBool() == true
     *
     * @param _expression command to execute
     * @param _result The return value of the command
     */
Dirk Wilden's avatar
Dirk Wilden committed
100
    virtual void getValue( QString /*_expression*/ , QVariant& /*_result*/  ) {};
101

Dirk Wilden's avatar
Dirk Wilden committed
102
    virtual void getPlugin( QString /*_name*/, QObject* & /*_plugin*/  ) {};
Dirk Wilden's avatar
Dirk Wilden committed
103

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
};

Q_DECLARE_INTERFACE(RPCInterface,"OpenFlipper.RPCInterface/1.0")

#endif // RPCINTERFACE_HH



//   std::cerr << "RPC Test : " << std::endl;
//
//   bool ok = false;
//   emit pluginExists( "colorplugin" , ok );
//
//   if ( ok )
//     std::cerr << "Found plugin" << std::endl;
//
//   emit functionExists( "colorplugin" , "slotTest(int)" , ok  );
//
//   if ( ok )
//     std::cerr << "Found Function" << std::endl;
//
//   ok = false;
//
//   emit call( "colorplugin.slotTest( 15 )",ok);
//
//   if ( ok )
//     std::cerr << "Execution ok" << std::endl;