1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef RPCVARIABLE_H_
17 #define RPCVARIABLE_H_
24 *Class to read and set an attached variable using the RPC
28 class RPCVariable: public RPC {
33 *@param ptr Pointer to the variable to make accessible over RPC. Any type of
34 *variable can be connected
35 *@param name The name of that this object will be over RPC
38 RPCVariable(A * ptr, const char * name) : RPC(name) {
42 *Read the variable over RPC.
44 *@return The value of the variable
50 *Write a value to the variable over RPC
52 *@param The value to be written to the attached variable.
58 virtual const struct rpc_method *get_rpc_methods();
59 static struct rpc_class *get_rpc_class();
66 const rpc_method *RPCVariable<T>::get_rpc_methods() {
67 static const rpc_method rpc_methods[] = {
68 {"read" , rpc_method_caller<T, RPCVariable, &RPCVariable::read> },
69 {"write", rpc_method_caller<RPCVariable, T, &RPCVariable::write> },
76 rpc_class *RPCVariable<T>::get_rpc_class() {
77 static const rpc_function funcs[] = {
78 "new", rpc_function_caller<const char*, T, const char*, &RPC::construct<RPCVariable, T, const char*> > ,
81 static rpc_class c = {"RPCVariable", funcs, NULL};
87 #endif //RPCVARIABLE_H_