Device Class Reference

#include <device.h>

List of all members.


Detailed Description

Encapsulates a device (i.e., a driver bound to an interface) A device describes an instantiated driver/interface combination. Drivers may support more than one interface, and hence appear more than once in the device table.


Public Member Functions

 Device (player_devaddr_t addr, Driver *driver)
 Constructor addr : Device address driver : Pointer to the underlying driver.
 ~Device ()
 Destructor.
int Subscribe (MessageQueue *sub_queue)
 Subscribe the given queue to this device. 0 on success, non-zero otherwise.
int Unsubscribe (MessageQueue *sub_queue)
 Unsubscribe the given queue from this device. 0 on success, non-zero otherwise.
void PutMsg (MessageQueue *resp_queue, uint8_t type, uint8_t subtype, void *src, size_t len, double *timestamp)
 Send a message to this device. This method is the basic way of sending a message to a device. The header will be assembled and the message will get pushed on to the underlying driver's InQueue. resp_queue : Where to push any reply (e.g., your InQueue) type : Message type subtype : Message subtype src : Message payload len : Length of the message payload timestamp : If non-NULL, the timestamp to attach to the message; otherwise, the current time is filled in.
void PutMsg (MessageQueue *resp_queue, player_msghdr_t *hdr, void *src)
 Send a message to this device (short form) This form of PutMsg is useful if you already have the message header assembled (e.g., when you're forwarding a message). resp_queue Where to push any reply hdr The message header. src The message body (its size is stored in hdr->size).
MessageRequest (MessageQueue *resp_queue, uint8_t type, uint8_t subtype, void *src, size_t len, double *timestamp, bool threaded=true)
 Make a request of another device. This method send a request message to a device and waits for the reply. resp_queue : Where to push the reply (e.g., your InQueue) type : Message type (usually PLAYER_MSGTYPE_REQ). subtype : Message subtype (interface-specific) src : Message body len : Length of src. timestamp : If non-NULL, the timestamp to attach to the request; otherwise, the current time is filled in. threaded : True if the caller is executing in its own thread, false otherwise It is is crucial that threaded be set correctly. If you call this method from within Setup() or Shutdown(), or if your driver does not run in its own thread, then threaded must be false. Deadlocks will otherwise result. A pointer to the reply message. The caller is responsible for deleting this pointer.

Static Public Member Functions

static bool MatchDeviceAddress (player_devaddr_t addr1, player_devaddr_t addr2)
 Compare two addresses This static method returns true if all 4 components of the two addresses match exactly. It's useful in Driver::ProcessMessage when you're deciding how to handle a message.

Public Attributes

Devicenext
 Next entry in the device table (this is a linked-list).
player_devaddr_t addr
 Address for this device.
char drivername [PLAYER_MAX_DRIVER_STRING_LEN]
 The string name for the underlying driver.
Driverdriver
 Pointer to the underlying driver.
MessageQueue ** queues
 Linked list of subscribed queues.
size_t len_queues
 Length of queues.

The documentation for this class was generated from the following file:

Last updated 12 September 2005 21:38:45