Skip to content

Commit

Permalink
Add property map to ActionInterface to ease JSON schema generation fo…
Browse files Browse the repository at this point in the history
…r plugin actions
  • Loading branch information
tribal-tec committed Aug 8, 2018
1 parent 3bae1bc commit 14d305f
Show file tree
Hide file tree
Showing 9 changed files with 608 additions and 190 deletions.
51 changes: 51 additions & 0 deletions brayns/common/ActionInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#pragma once

#include <brayns/common/types.h>

#include <functional>
#include <string>

Expand Down Expand Up @@ -47,6 +49,55 @@ class ActionInterface
public:
virtual ~ActionInterface() = default;

/**
* Register an action with no parameter and no return value.
*
* @param desc description of the action/RPC
* @param action the action to perform on an incoming notification
*/
virtual void registerNotification(const RpcDescription& desc,
const std::function<void()>& action) = 0;

/**
* Register an action with a property map as the parameter and no return
* value.
*
* @param desc description of the action/RPC
* @param input the acceptable property map as the parameter for the RPC
* @param action the action to perform on an incoming notification
*/
virtual void registerNotification(
const RpcParameterDescription& desc, const PropertyMap& input,
const std::function<void(PropertyMap)>& action) = 0;

/**
* Register an action with a property map as the parameter and a property
* map as the return value.
*
* @param desc description of the action/RPC
* @param input the acceptable property map as the parameter for the RPC
* @param output the property map layout that is returned on a successful
* request
* @param action the action to perform on an incoming request
*/
virtual void registerRequest(
const RpcParameterDescription& desc, const PropertyMap& input,
const PropertyMap& output,
const std::function<PropertyMap(PropertyMap)>& action) = 0;

/**
* Register an action with no parameter and a property map as the return
* value.
*
* @param desc description of the action/RPC
* @param output the property map layout that is returned on a successful
* request
* @param action the action to perform on an incoming request
*/
virtual void registerRequest(
const RpcDescription& desc, const PropertyMap& output,
const std::function<PropertyMap()>& action) = 0;

/** Register an action with no parameter and no return value. */
void registerNotification(const std::string& name,
const std::function<void()>& action)
Expand Down
16 changes: 16 additions & 0 deletions brayns/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,22 @@ enum class DataType

class PropertyMap;
class PropertyObject;

/** Description for RPC with no parameter. */
struct RpcDescription
{
std::string methodName;
std::string methodDescription;
};

/** Description for RPC with one parameter. */
struct RpcParameterDescription
{
std::string methodName;
std::string methodDescription;
std::string paramName;
std::string paramDescription;
};
}

#endif // TYPES_H

0 comments on commit 14d305f

Please sign in to comment.