Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
#include <MMAccessor.h>
Since MotionCommands must be checked out of the motion manager and then checked back in when they are done, this is a common source of errors, leading to deadlock. This class will check the motion out when it's created, and check it back in when it goes out of scope
It supports recursive checkin/checkouts.
Uses global motman
So, instead of doing things like this:
YourMotionCommand* ymc = dynamic_cast<YourMotionCommand*>(motman->checkoutMotion(your_mc_id)); //do 'stuff' with ymc, e.g.: ymc->rollOver(); motman->checkinMotion(your_mc_id);
MMAccessor<YourMotionCommand> mma(your_mc_id); //do 'stuff' with mma, e.g.: mma->rollOver();
//pre-stuff { MMAccessor<YourMotionCommand> mma(your_mc_id); //do 'stuff' with mma, e.g.: mma->rollOver(); } //post-stuff - has no knowledge of mma, out of its scope
See also the templated checkin(Ret_t ret) function for more examples of streamlined usage.
MMAccessor is a small class, you may consider passing it around instead of a MotionManager::MC_ID if appropriate. (Would be appropriate to avoid multiple checkin/outs in a row from different functions, but not as appropriate for storage and reuse of the same MMAccessor.
Definition at line 49 of file MMAccessor.h.
Public Member Functions | |
MMAccessor (MotionManager::MC_ID id, bool ckout=true) | |
constructor, checks out by default | |
MMAccessor (const MMAccessor &a) | |
copy constructor - will reference the same mc_id - checkin/checkouts are NOT independent between this and a - they will be linked | |
~MMAccessor () | |
destructor, checks in if needed | |
MMAccessor< MC_t > | operator= (const MMAccessor< MC_t > &a) |
allows assignment of MMAccessor's, similar to the copy constructor - the two MMAccessor's will control the same MotionCommand | |
MC_t * | checkout () |
So you can check out if not done by default (or you checked in already). | |
MC_t * | mc () const |
Returns the motion command's address so you can call functions. | |
void | checkin () |
Checks in the motion. | |
template<class Ret_t> Ret_t | checkin (Ret_t ret) |
Checks in the motion, passing through the value it is passed. | |
MC_t * | operator-> () |
smart pointer to the underlying MotionCommand | |
const MC_t * | operator-> () const |
smart pointer to the underlying MotionCommand | |
MC_t & | operator * () |
smart pointer to the underlying MotionCommand | |
const MC_t & | operator * () const |
smart pointer to the underlying MotionCommand | |
MC_t & | operator[] (int i) |
smart pointer to the underlying MotionCommand | |
const MC_t & | operator[] (int i) const |
smart pointer to the underlying MotionCommand | |
Protected Attributes | |
MotionManager::MC_ID | mc_id |
the MC_ID that this Accessor was constructed with | |
MC_t * | mcptr |
a pointer to the motion command, should always be valid even when not checked out so you can access member fields (which is reasonably safe) |
|
constructor, checks out by default
Definition at line 55 of file MMAccessor.h. References MMAccessor< MC_t >::checkout(), MMAccessor< MC_t >::mc_id, MMAccessor< MC_t >::mcptr, motman, and MotionManager::peekMotion(). |
|
copy constructor - will reference the same mc_id - checkin/checkouts are NOT independent between this and a - they will be linked
Definition at line 63 of file MMAccessor.h. References MMAccessor< MC_t >::mc_id, and MMAccessor< MC_t >::mcptr. |
|
destructor, checks in if needed
Definition at line 66 of file MMAccessor.h. References MMAccessor< MC_t >::checkin(), MotionManager::checkoutLevel(), MMAccessor< MC_t >::mc_id, and motman. |
|
Checks in the motion, passing through the value it is passed.
MMAccessor<myMC> mine(myMC_id); if(mine.mc()->foo()) //do something with motman here bool cond; {MMAccessor<myMC> mine(myMC_id); cond=mine.mc()->foo();} if(cond) //do something with motman here MMAccessor<myMC> mine(myMC_id); if(mine.checkin(mine.mc()->foo())) //do something with motman here Definition at line 117 of file MMAccessor.h. References MMAccessor< MC_t >::checkin(), and MMAccessor< MC_t >::mcptr. |
|
Checks in the motion. Don't forget, you can also just limit the scope using extra { }'s Definition at line 88 of file MMAccessor.h. References MotionManager::checkinMotion(), MMAccessor< MC_t >::mc_id, and motman. |
|
So you can check out if not done by default (or you checked in already). <
Definition at line 79 of file MMAccessor.h. References MotionManager::checkoutMotion(), MMAccessor< MC_t >::mc_id, MMAccessor< MC_t >::mcptr, and motman. |
|
Returns the motion command's address so you can call functions.
Definition at line 84 of file MMAccessor.h. References MMAccessor< MC_t >::mcptr. |
|
smart pointer to the underlying MotionCommand
Definition at line 126 of file MMAccessor.h. References MMAccessor< MC_t >::mc(). |
|
smart pointer to the underlying MotionCommand
Definition at line 125 of file MMAccessor.h. References MMAccessor< MC_t >::mc(). |
|
smart pointer to the underlying MotionCommand
Definition at line 124 of file MMAccessor.h. References MMAccessor< MC_t >::mc(). |
|
smart pointer to the underlying MotionCommand
Definition at line 123 of file MMAccessor.h. References MMAccessor< MC_t >::mc(). |
|
allows assignment of MMAccessor's, similar to the copy constructor - the two MMAccessor's will control the same MotionCommand
Definition at line 72 of file MMAccessor.h. References MMAccessor< MC_t >::mc_id, and MMAccessor< MC_t >::mcptr. |
|
smart pointer to the underlying MotionCommand
Definition at line 128 of file MMAccessor.h. References MMAccessor< MC_t >::mc(). |
|
smart pointer to the underlying MotionCommand
Definition at line 127 of file MMAccessor.h. References MMAccessor< MC_t >::mc(). |
|
the MC_ID that this Accessor was constructed with
Definition at line 131 of file MMAccessor.h. |
|
a pointer to the motion command, should always be valid even when not checked out so you can access member fields (which is reasonably safe)
Definition at line 132 of file MMAccessor.h. |
Tekkotsu v1.4 |
Generated Sat Jul 19 00:09:03 2003 by Doxygen 1.3.2 |