Urbi SDK Remote for C++  2.7.5
uobject.hh File Reference
#include <libport/warning-push.hh>
#include <string>
#include <libport/cmath>
#include <libport/compiler.hh>
#include <libport/fwd.hh>
#include <libport/preproc.hh>
#include <libport/thread-pool.hh>
#include <libport/ufloat.h>
#include <libport/utime.hh>
#include <urbi/export.hh>
#include <urbi/fwd.hh>
#include <urbi/kernel-version.hh>
#include <urbi/input-port.hh>
#include <urbi/ucallbacks.hh>
#include <urbi/uevent.hh>
#include <urbi/utimer-callback.hh>
#include <urbi/uvar.hh>
#include <urbi/uobject-hub.hh>
#include <urbi/ucontext.hh>
#include <urbi/ustarter.hh>
#include <urbi/uobject.hxx>
#include <libport/warning-pop.hh>
Include dependency graph for uobject.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  urbi::LockSpec
 Extended locking model specifications. More...
class  urbi::UObject
 Main UObject class definition Each UObject instance corresponds to an URBI object. More...
struct  urbi::uvalue_caster< UObject * >

Namespaces

namespace  urbi
 

Global definition of the starterlist.


Defines

#define URBI_SDK_DEPRECATED   ATTRIBUTE_DEPRECATED
#define USE_VOID   1
#define URBI_UOBJECT_VERSION   2
#define UBindVarRename(Obj, X, Uname)   (X).init(__name, Uname, ctx_)
 Bind a variable to an object.
#define UBindVar(Obj, X)   UBindVarRename(Obj, X, #X)
#define UBindVars(Obj,...)   LIBPORT_VAARGS_APPLY(URBI_BINDVARS, Obj, __VA_ARGS__)
 Bind multiple variables in one call.
#define UBindEventRename(Obj, X, Uname)   (X).init(__name, Uname, ctx_)
 Bind an event to an object.
#define UBindEvent(Obj, X)   UBindEventRename(Obj, X, #X)
#define UBindEvents(Obj,...)   LIBPORT_VAARGS_APPLY(URBI_BINDEVENTS, Obj, __VA_ARGS__)
#define UOwned(X)   (X).setOwned()
 This macro inverts a UVar in/out accesses.
#define USensor(X)   UOwned(X)
 Backward compatibility.
#define CREATE_CLASS_LOCK
 Call me inside your class declaration if you need a LOCK_CLASS task lock.
#define URBI_CREATE_CALLBACK(Kind,...)   ::urbi::createUCallback(*this, 0, #Kind, this, __VA_ARGS__)
 Internal, might change, do not use it directly.
#define UBindFunctionRename(Obj, X, Uname)   URBI_CREATE_CALLBACK(function, (&Obj::X), __name + "." Uname)
 Bind the function X in current Urbi object to the C++ member function of same name.
#define UBindFunction(Obj, X)   UBindFunctionRename(Obj, X, #X)
#define UBindFunctions(Obj,...)   LIBPORT_VAARGS_APPLY(URBI_BINDFUNCTIONS, Obj, __VA_ARGS__)
#define UBindThreadedFunctionRename(Obj, X, Uname, LockMode)   UBindFunctionRename(Obj, X, Uname)->setAsync(getTaskLock(LockMode, Uname))
 Bind the function so that it gets executed in a separate thread.
#define UBindThreadedFunction(Obj, X, LockMode)   UBindThreadedFunctionRename(Obj, X, #X, LockMode)
#define UAt(Obj, X)   URBI_CREATE_CALLBACK(event, (&Obj::X), __name + "." #X)
 Registers a function X in current object that will be called each time the event of same name is triggered.
#define UThreadedAt(Obj, X, LockMode)   UAt(Obj, X)->setAsync(getTaskLock(LockMode, #X))
 Same as UAt() but executes the code in a separate thread.
#define UAtEnd(Obj, X, Fun)   URBI_CREATE_CALLBACK(eventend, (&Obj::X), (&Obj::Fun), __name + "." #X)
 Registers a function X in current object that will be called each time the event of same name is triggered, and a function fun called when the event ends.
#define UThreadedAtEnd(Obj, X, Fun, LockMode)   UAtEnd(Obj, X, Fun)->setAsync(getTaskLock(LockMode, #X))
#define URegister(Hub)
 Register current object to the UObjectHub named Hub.
#define URBI(A)   uobject_unarmorAndSend(# A)
 Send unquoted Urbi commands to the server.
#define URBI_SEND_C(C, Args)
 Send Args (which is given to a stream and therefore can use <<) to C.
#define URBI_SEND_C_FLUSH(C, Args)
 Send Args (which is given to a stream and therefore can use <<) to C, then flush.
#define URBI_SEND(Args)   URBI_SEND_C(URBI(()), Args)
 Send Args (which is given to a stream and therefore can use <<) to the server.
#define URBI_SEND_COMMAND_C(C, Args)   URBI_SEND_C_FLUSH(C, Args << ';')
 Send "\a Args ; \n" to C.
#define URBI_SEND_COMMAND(Args)   URBI_SEND_COMMAND_C(URBI(()), Args)
#define URBI_SEND_PIPED_COMMAND_C(C, Args)   URBI_SEND_C(C, Args << "|\n")
 Send "\a Args | \n" to C.
#define URBI_SEND_PIPED_COMMAND(Args)   URBI_SEND_PIPED_COMMAND_C(URBI(()), Args)
#define URBI_SEND_COMMA_COMMAND_C(C, Args)   URBI_SEND_C_FLUSH(C, Args << ',')
#define URBI_SEND_COMMA_COMMAND(Args)   URBI_SEND_COMMA_COMMAND_C(URBI(()), Args)

Typedefs

typedef int urbi::UReturn

Enumerations

enum  urbi::LockMode {
  urbi::LOCK_NONE, urbi::LOCK_FUNCTION, urbi::LOCK_INSTANCE, urbi::LOCK_CLASS,
  urbi::LOCK_MODULE
}
 Locking model. More...

Functions

UObjectHub * urbi::getUObjectHub (const std::string &n)
UObject * urbi::getUObject (const std::string &n)
void urbi::uobject_unarmorAndSend (const char *str)
 Send Urbi code (ghost connection in plugin mode, default connection in remote mode).
void urbi::send (const char *str)
void urbi::send (const std::string &str)
void urbi::send (const void *buf, size_t size)
 Send buf to the connection hosting the UObject.
UObjectMode urbi::getRunningMode ()
bool urbi::isPluginMode ()
bool urbi::isRemoteMode ()
void urbi::setThreadLimit (size_t nThreads)
 Set maximum number of threads to use for threaded calls (0=unlimited).
std::string urbi::getFilteredHostname ()
 Return current hostname mangled to fit into an urbiscript variable name.
UValue & urbi::operator, (UValue &a, const UObject *b)

Variables

static const LockSpec urbi::LOCK_FUNCTION_DROP = LockSpec(LOCK_FUNCTION, 1)
 LockSpec that prevents parallel calls to the function, and drops all subsequent calls while one is running.
static const LockSpec urbi::LOCK_FUNCTION_KEEP_ONE = LockSpec(LOCK_FUNCTION, 2)
 LockSpec that prevents parallel calls to the function, and drops all subsequent calls while one is running but one.

Detailed Description

Definition in file uobject.hh.


Define Documentation

#define CREATE_CLASS_LOCK
Value:
virtual                                       \
  libport::ThreadPool::rTaskLock                \
  getClassTaskLock()                            \
  {                                             \
    static libport::ThreadPool::rTaskLock       \
      tl(new libport::ThreadPool::TaskLock);    \
    return tl;                                  \
  }

Call me inside your class declaration if you need a LOCK_CLASS task lock.

Definition at line 97 of file uobject.hh.

#define UAt (   Obj,
 
)    URBI_CREATE_CALLBACK(event, (&Obj::X), __name + "." #X)

Registers a function X in current object that will be called each time the event of same name is triggered.

The function will be called only if the number of arguments match between the function prototype and the Urbi event.

Definition at line 146 of file uobject.hh.

#define UAtEnd (   Obj,
  X,
  Fun 
)    URBI_CREATE_CALLBACK(eventend, (&Obj::X), (&Obj::Fun), __name + "." #X)

Registers a function X in current object that will be called each time the event of same name is triggered, and a function fun called when the event ends.

The function will be called only if the number of arguments match between the function prototype and the Urbi event.

Definition at line 160 of file uobject.hh.

#define UBindEvent (   Obj,
 
)    UBindEventRename(Obj, X, #X)

Definition at line 76 of file uobject.hh.

#define UBindEventRename (   Obj,
  X,
  Uname 
)    (X).init(__name, Uname, ctx_)

Bind an event to an object.

These macros can only be called from within a class inheriting from UObject. They bind the UEvent X within the object to a variable with uName as variable name in the corresponding Urbi object.

Definition at line 73 of file uobject.hh.

#define UBindEvents (   Obj,
  ... 
)    LIBPORT_VAARGS_APPLY(URBI_BINDEVENTS, Obj, __VA_ARGS__)

Definition at line 79 of file uobject.hh.

#define UBindFunction (   Obj,
 
)    UBindFunctionRename(Obj, X, #X)
#define UBindFunctionRename (   Obj,
  X,
  Uname 
)    URBI_CREATE_CALLBACK(function, (&Obj::X), __name + "." Uname)

Bind the function X in current Urbi object to the C++ member function of same name.

The return value and arguments must be of a basic integral or floating types, char *, std::string, UValue, UBinary, USound or UImage, or any type that can cast to/from UValue.

Definition at line 116 of file uobject.hh.

#define UBindFunctions (   Obj,
  ... 
)    LIBPORT_VAARGS_APPLY(URBI_BINDFUNCTIONS, Obj, __VA_ARGS__)

Definition at line 122 of file uobject.hh.

#define UBindThreadedFunction (   Obj,
  X,
  LockMode 
)    UBindThreadedFunctionRename(Obj, X, #X, LockMode)

Definition at line 138 of file uobject.hh.

#define UBindThreadedFunctionRename (   Obj,
  X,
  Uname,
  LockMode 
)    UBindFunctionRename(Obj, X, Uname)->setAsync(getTaskLock(LockMode, Uname))

Bind the function so that it gets executed in a separate thread.

Parameters:
Objthe UObject class name
Xthe unquoted function name
Unamethe urbiscript name of the method
LockMode(LockMode or LockSpec) which lock to use. This lock can be used to prevent multiple parallel execution of functions. If you use only a LockMode, operations that cannot execute in parallel will be queued. A LockSpec can be used to specify the maximum queue size.

Definition at line 135 of file uobject.hh.

Referenced by UMachine::init().

#define UBindVar (   Obj,
 
)    UBindVarRename(Obj, X, #X)
#define UBindVarRename (   Obj,
  X,
  Uname 
)    (X).init(__name, Uname, ctx_)

Bind a variable to an object.

These macros can only be called from within a class inheriting from UObject. They bind the UVar X within the object to a variable with Uname as variable name in the corresponding Urbi object.

Definition at line 57 of file uobject.hh.

#define UBindVars (   Obj,
  ... 
)    LIBPORT_VAARGS_APPLY(URBI_BINDVARS, Obj, __VA_ARGS__)

Bind multiple variables in one call.

Definition at line 64 of file uobject.hh.

#define UOwned (   X)    (X).setOwned()

This macro inverts a UVar in/out accesses.

After this call is made, writes by this module affect the sensed value, and reads read the target value. Writes by other modules and Urbi code affect the target value, and reads get the sensed value. Without this call, all operations affect the same underlying variable.

Definition at line 89 of file uobject.hh.

#define URBI (   A)    uobject_unarmorAndSend(# A)

Send unquoted Urbi commands to the server.

Add an extra layer of parenthesis for safety.

Definition at line 184 of file uobject.hh.

#define URBI_CREATE_CALLBACK (   Kind,
  ... 
)    ::urbi::createUCallback(*this, 0, #Kind, this, __VA_ARGS__)

Internal, might change, do not use it directly.

Definition at line 108 of file uobject.hh.

#define URBI_SDK_DEPRECATED   ATTRIBUTE_DEPRECATED

Definition at line 43 of file uobject.hh.

#define URBI_SEND (   Args)    URBI_SEND_C(URBI(()), Args)

Send Args (which is given to a stream and therefore can use <<) to the server.

Definition at line 207 of file uobject.hh.

#define URBI_SEND_C (   C,
  Args 
)
Value:
do {                                            \
    libport::BlockLock bl((C).sendBufferLock);  \
    (C) << Args;                                \
  } while (false)

Send Args (which is given to a stream and therefore can use <<) to C.

Definition at line 191 of file uobject.hh.

#define URBI_SEND_C_FLUSH (   C,
  Args 
)
Value:
do {                                            \
    libport::BlockLock bl((C).sendBufferLock);  \
    (C) << Args << std::endl;                   \
  } while (false)

Send Args (which is given to a stream and therefore can use <<) to C, then flush.

Definition at line 199 of file uobject.hh.

#define URBI_SEND_COMMA_COMMAND (   Args)    URBI_SEND_COMMA_COMMAND_C(URBI(()), Args)

Definition at line 230 of file uobject.hh.

#define URBI_SEND_COMMA_COMMAND_C (   C,
  Args 
)    URBI_SEND_C_FLUSH(C, Args << ',')
#define URBI_SEND_COMMAND (   Args)    URBI_SEND_COMMAND_C(URBI(()), Args)

Definition at line 214 of file uobject.hh.

#define URBI_SEND_PIPED_COMMAND (   Args)    URBI_SEND_PIPED_COMMAND_C(URBI(()), Args)

Definition at line 224 of file uobject.hh.

#define URBI_SEND_PIPED_COMMAND_C (   C,
  Args 
)    URBI_SEND_C(C, Args << "|\n")
#define URBI_UOBJECT_VERSION   2

Definition at line 50 of file uobject.hh.

#define URegister (   Hub)
Value:
do {                                                            \
    objecthub = ::urbi::baseURBIStarterHub::find(#Hub);         \
    if (objecthub)                                              \
      objecthub->addMember(this);                               \
    else                                                        \
    {                                                           \
      GD_CATEGORY(Urbi.UObject);                                \
      GD_FERROR("Error: hub name '%s' is unknown",  #Hub);      \
    }                                                           \
  } while (0)

Register current object to the UObjectHub named Hub.

Definition at line 167 of file uobject.hh.

#define USE_VOID   1

Definition at line 48 of file uobject.hh.

#define USensor (   X)    UOwned(X)

Backward compatibility.

Definition at line 93 of file uobject.hh.

Referenced by sensor::sensor().

#define UThreadedAt (   Obj,
  X,
  LockMode 
)    UAt(Obj, X)->setAsync(getTaskLock(LockMode, #X))

Same as UAt() but executes the code in a separate thread.

Definition at line 150 of file uobject.hh.

#define UThreadedAtEnd (   Obj,
  X,
  Fun,
  LockMode 
)    UAtEnd(Obj, X, Fun)->setAsync(getTaskLock(LockMode, #X))

Definition at line 163 of file uobject.hh.