Resource Class Reference
#include <Resource.h>


Public Member Functions | |
| virtual | ~Resource () |
| UINT32 | Allocate (const char *resourceDesc) |
| UINT32 | Allocate (UINT32 index, const char *resourceDesc) |
| void | Free (UINT32 index) |
Static Public Member Functions | |
| static void | CreateResourceObject (Resource **r, UINT32 elements) |
Protected Member Functions | |
| Resource (UINT32 size) | |
Detailed Description
Track resources in the program. The Resource class is a convienent way of keeping track of allocated arbitrary resources in the program. Resources are just indicies that have an lower and upper bound that are tracked by this class. In the library they are used for tracking allocation of hardware channels but this is purely arbitrary. The resource class does not do any actual allocation, but simply tracks if a given index is currently in use.
WARNING: this should only be statically allocated. When the program loads into memory all the static constructors are called. At that time a linked list of all the "Resources" is created. Then when the program actually starts - in the Robot constructor, all resources are initialized. This ensures that the program is restartable in memory without having to unload/reload.
Definition at line 26 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 38 of file Resource.cpp.
| Resource::Resource | ( | UINT32 | elements | ) | [explicit, protected] |
Allocate storage for a new instance of Resource. Allocate a bool array of values that will get initialized to indicate that no resources have been allocated yet. The indicies of the resources are 0..size-1.
Definition at line 18 of file Resource.cpp.
Member Function Documentation
| UINT32 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 48 of file Resource.cpp.
| UINT32 Resource::Allocate | ( | UINT32 | 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 67 of file Resource.cpp.
| void Resource::Free | ( | UINT32 | 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 89 of file Resource.cpp.
The documentation for this class was generated from the following files:
Generated on Thu Jan 12 2012 22:35:35 for WPILibC++ by
1.7.1