Now you can download a copy of these docs so you can use them offline! Download now

#include <Resource.h>

Inheritance diagram for Resource:
Collaboration diagram for Resource:

Public Member Functions

virtual ~Resource ()
 
uint32_t Allocate (const char *resourceDesc)
 
uint32_t Allocate (uint32_t index, const char *resourceDesc)
 
void Free (uint32_t index)
 
- Public Member Functions inherited from ErrorBase
virtual ErrorGetError ()
 Retrieve the current error. Get the current error information associated with this sensor.
 
virtual const ErrorGetError () const
 
virtual void SetErrnoError (const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (ErrorBase *rhs) const
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 

Static Public Member Functions

static void CreateResourceObject (Resource **r, uint32_t elements)
 
- Static Public Member Functions inherited from ErrorBase
static void SetGlobalError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static void SetGlobalWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static ErrorGetGlobalError ()
 

Additional Inherited Members

- Protected Member Functions inherited from ErrorBase
 ErrorBase ()
 Initialize the instance status to 0 for now.
 
- Protected Attributes inherited from ErrorBase
Error m_error
 
- Static Protected Attributes inherited from ErrorBase
static SEM_ID _globalErrorMutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
 
static Error _globalError
 

Detailed Description

The Resource class is a convenient way to track allocated resources. It tracks them as indicies in the range [0 .. elements - 1]. E.g. the library uses this to track hardware channel allocation.

The Resource class does not allocate the hardware channels or other resources; it just tracks which indices were marked in use by Allocate and not yet freed by Free.

Definition at line 23 of file Resource.h.

Constructor & Destructor Documentation

Resource::~Resource ( )
virtual

Delete the allocated array or resources. This happens when the module is unloaded (provided it was statically allocated).

Definition at line 52 of file Resource.cpp.

Member Function Documentation

uint32_t Resource::Allocate ( const char *  resourceDesc)

Allocate a resource. When a resource is requested, mark it allocated. In this case, a free resource value within the range is located and returned after it is marked allocated.

Definition at line 62 of file Resource.cpp.

uint32_t Resource::Allocate ( uint32_t  index,
const char *  resourceDesc 
)

Allocate a specific resource value. The user requests a specific resource value, i.e. channel number and it is verified unallocated, then returned.

Definition at line 82 of file Resource.cpp.

void Resource::CreateResourceObject ( Resource **  r,
uint32_t  elements 
)
static

Factory method to create a Resource allocation-tracker if needed.

Parameters
r– address of the caller's Resource pointer. If *r == NULL, this will construct a Resource and make *r point to it. If *r != NULL, i.e. the caller already has a Resource instance, this won't do anything.
elements– the number of elements for this Resource allocator to track, that is, it will allocate resource numbers in the range [0 .. elements - 1].

Definition at line 39 of file Resource.cpp.

void Resource::Free ( uint32_t  index)

Free an allocated resource. After a resource is no longer needed, for example a destructor is called for a channel assignment class, Free will release the resource value so it can be reused somewhere else in the program.

Definition at line 105 of file Resource.cpp.


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

Generated on Sat Apr 26 2014 12:26:46 for WPILibC++ by doxygen 1.8.6