Despite threat of overhead, each Writable value will have to carry a string identifying who holds the lock, if anyone. WriteMode tells us who can write to it, ConsumeMode tracks what type the local process is, and ModeStatus is a way for the supplier to inform consumers that it cannot grant their request. In that case, the supplier trumps the consumers, setting the value to something sensibly close to the request.
There is, of course, still the danger of a race condition here, where two processes try to change the consumemode value at the same time. In such a case, the one that sets it later will probably win, but it could become a mess. Need to think about it a bit.
Definition at line 57 of file WritableType.H.
Public Member Functions | |
Writable () | |
Writable (Type _value) | |
Writable (Type _value, ConsumeMode _cmode) | |
Writable (Type _value, WriteMode _rwmode, std::string id) | |
Writable (Type _value, ConsumeMode _cmode, WriteMode _rwmode, std::string id) | |
bool | setValue (Type _value) |
Attempts to set the value, returns false if fails. | |
Type | getValue () const |
Accessor function for the actual values. | |
bool | setRWMode (WriteMode _mode) |
WriteMode | getRWMode () const |
Accessor functions for the write mode. | |
bool | setCMode (ConsumeMode _mode) |
ConsumeMode | getCMode () const |
Accessor functions for the consumer mode. | |
bool | setStatus (StatusMode stat) |
Set the status of this info-- automatically set to STAT_REQUEST for consumers when setValue is called. | |
StatusMode | getStatus () const |
bool | setLock () |
Locks the variable, if possible. | |
bool | setValueAndLock (Type _value) |
Sets the value and locks, if possible. | |
bool | unlock () |
Returns true if the variable was successfully unlocked (ie, if this process held the lock). | |
bool | locked () const |
Returns true of the variable is locked. | |
std::string | getLockOwner () const |
Returns the name of the lock owner, if it is locked. | |
void | COM_ADAPTOR_setValue (Type _value) |
Sets the value, overriding the lock state. | |
void | COM_ADAPTOR_setRWMode (WriteMode _mode) |
Sets the write mode, overriding the lock state. | |
void | COM_ADAPTOR_setStatus (StatusMode stat) |
Sets the status, overriding the lock state. | |
void | COM_ADAPTOR_setLockOwner (std::string owner) |
Sets the lock owner, overriding the lock state. | |
Writable & | operator= (const Writable &r) |
Protected Attributes | |
Type | m_value |
WriteMode | m_rwMode |
ConsumeMode | m_cMode |
StatusMode | m_sMode |
std::string | m_id |
std::string | m_lockOwner |
Writable | ( | ) |
Definition at line 242 of file WritableType.H.
References WURDE::C_CONSUMER, Writable::m_cMode, Writable::m_id, Writable::m_lockOwner, Writable::m_rwMode, and WURDE::W_ALL.
Referenced by Writable::Writable().
Writable | ( | Type | _value | ) | [explicit] |
Definition at line 236 of file WritableType.H.
References WURDE::C_CONSUMER, WURDE::W_ALL, and Writable::Writable().
Writable | ( | Type | _value, | |
ConsumeMode | _cmode | |||
) |
Definition at line 231 of file WritableType.H.
References WURDE::C_CONSUMER, and Writable::Writable().
Writable | ( | Type | _value, | |
ConsumeMode | _cmode, | |||
WriteMode | _rwmode, | |||
std::string | id | |||
) |
Definition at line 212 of file WritableType.H.
References Writable::m_cMode, Writable::m_id, Writable::m_lockOwner, Writable::m_rwMode, Writable::m_value, and WURDE::W_LOCKED.
bool setValue | ( | Type | _value | ) |
Attempts to set the value, returns false if fails.
For consumers, this also automatically sets the status to be STAT_REQUEST. For suppliers, it gets set to STAT_OKAY, and so should be set manually if this is not correct.
Definition at line 250 of file WritableType.H.
References WURDE::C_CONSUMER, WURDE::C_SUPPLIER, Writable::m_cMode, Writable::m_id, Writable::m_lockOwner, Writable::m_rwMode, Writable::m_sMode, Writable::m_value, WURDE::STAT_NULL, WURDE::STAT_OKAY, WURDE::STAT_REQUEST, WURDE::W_ALL, WURDE::W_CONSUMER_ONLY, WURDE::W_LOCKED, WURDE::W_NULL, and WURDE::W_SUPPLIER_ONLY.
Referenced by handleRequest(), initializeLaser(), main(), VectorMover::moveToPoint(), ObstacleAvoider::moveToPoint(), VectorMover::moveToPose(), ObstacleAvoider::moveToPose(), VectorMover::moveToRelativePoint(), ObstacleAvoider::moveToRelativePoint(), VectorMover::moveToRelativePose(), ObstacleAvoider::moveToRelativePose(), ImageSource::publishImage(), ObstacleAvoider::rotateFixedAngle(), VectorMover::rotateToAngle(), ObstacleAvoider::rotateToAngle(), VectorMover::rotateToRelativeAngle(), ObstacleAvoider::rotateToRelativeAngle(), ObstacleAvoider::setAvoidanceRadius(), Writable< std::vector< WURDE::VisionOperatorSpec > >::setValueAndLock(), VectorMover::stop(), ObstacleAvoider::stop(), VectorMover::translateFixedDistance(), ObstacleAvoider::translateFixedDistance(), and updateModules().
Type getValue | ( | ) | const |
Accessor function for the actual values.
Definition at line 300 of file WritableType.H.
References Writable::m_value.
Referenced by closeLaser(), ImageSource::getImage(), CommsManager::handleMCPReply(), handleRequest(), main(), ImageSource::publishImage(), DataCollector::runOperator(), CommsManager::runUpdate(), and updateWaypoint().
bool setRWMode | ( | WriteMode | _mode | ) |
Definition at line 305 of file WritableType.H.
References WURDE::C_CONSUMER, WURDE::C_SUPPLIER, Writable::m_cMode, Writable::m_rwMode, WURDE::W_ALL, WURDE::W_CONSUMER_ONLY, WURDE::W_LOCKED, WURDE::W_NULL, and WURDE::W_SUPPLIER_ONLY.
WriteMode getRWMode | ( | ) | const |
Accessor functions for the write mode.
Definition at line 342 of file WritableType.H.
References Writable::m_rwMode.
bool setCMode | ( | ConsumeMode | _mode | ) |
Definition at line 347 of file WritableType.H.
References Writable::m_cMode.
Referenced by WallBuilder::activateConsumer(), VisionControl::activateConsumer(), VectorMoverTransport::activateConsumer(), SoundController::activateConsumer(), RobotDrive::activateConsumer(), RangeFinder::activateConsumer(), PTUnit::activateConsumer(), PlaybackControl::activateConsumer(), ObstacleAvoiderTransport::activateConsumer(), McpRequest::activateConsumer(), ImageTransport::activateConsumer(), ImageDisplay::activateConsumer(), Heartbeat::activateConsumer(), Foo::activateConsumer(), Bumper::activateConsumer(), BlobFinder::activateConsumer(), WallBuilder::activateSupplier(), VisionControl::activateSupplier(), VectorMoverTransport::activateSupplier(), SoundController::activateSupplier(), RobotDrive::activateSupplier(), RangeFinder::activateSupplier(), PTUnit::activateSupplier(), PlaybackControl::activateSupplier(), ObstacleAvoiderTransport::activateSupplier(), McpRequest::activateSupplier(), ImageTransport::activateSupplier(), ImageDisplay::activateSupplier(), Heartbeat::activateSupplier(), Foo::activateSupplier(), Bumper::activateSupplier(), BlobFinder::activateSupplier(), WallBuilder::getNextInfo(), VisionControl::getNextInfo(), VectorMoverTransport::getNextInfo(), SoundController::getNextInfo(), RobotDrive::getNextInfo(), RangeFinder::getNextInfo(), PTUnit::getNextInfo(), PlaybackControl::getNextInfo(), ObstacleAvoiderTransport::getNextInfo(), McpRequest::getNextInfo(), ImageTransport::getNextInfo(), ImageDisplay::getNextInfo(), Heartbeat::getNextInfo(), Foo::getNextInfo(), Bumper::getNextInfo(), BlobFinder::getNextInfo(), WallBuilder::publishInfo(), VisionControl::publishInfo(), VectorMoverTransport::publishInfo(), SoundController::publishInfo(), RobotDrive::publishInfo(), RangeFinder::publishInfo(), PTUnit::publishInfo(), PlaybackControl::publishInfo(), ObstacleAvoiderTransport::publishInfo(), McpRequest::publishInfo(), ImageTransport::publishInfo(), ImageDisplay::publishInfo(), Heartbeat::publishInfo(), Foo::publishInfo(), Bumper::publishInfo(), and BlobFinder::publishInfo().
ConsumeMode getCMode | ( | ) | const |
Accessor functions for the consumer mode.
Definition at line 353 of file WritableType.H.
References Writable::m_cMode.
bool setStatus | ( | StatusMode | stat | ) |
Set the status of this info-- automatically set to STAT_REQUEST for consumers when setValue is called.
Suppliers should set manually, though defaults to STAT_OKAY.
Definition at line 358 of file WritableType.H.
References WURDE::C_SUPPLIER, Writable::m_cMode, and Writable::m_sMode.
Referenced by main().
StatusMode getStatus | ( | ) | const |
bool setLock | ( | ) |
Locks the variable, if possible.
Definition at line 374 of file WritableType.H.
References WURDE::C_CONSUMER, WURDE::C_SUPPLIER, Writable::m_cMode, Writable::m_id, Writable::m_lockOwner, Writable::m_rwMode, WURDE::W_ALL, WURDE::W_CONSUMER_ONLY, WURDE::W_LOCKED, WURDE::W_NULL, and WURDE::W_SUPPLIER_ONLY.
Referenced by initializeLaser(), and Writable< std::vector< WURDE::VisionOperatorSpec > >::setValueAndLock().
bool setValueAndLock | ( | Type | _value | ) | [inline] |
Sets the value and locks, if possible.
Definition at line 108 of file WritableType.H.
Referenced by initializeLaser(), ImagePublisher::initOperator(), main(), and CommsManager::updateObjects().
bool unlock | ( | ) |
Returns true if the variable was successfully unlocked (ie, if this process held the lock).
Definition at line 408 of file WritableType.H.
References Writable::m_id, Writable::m_lockOwner, Writable::m_rwMode, WURDE::W_ALL, and WURDE::W_LOCKED.
bool locked | ( | ) | const |
Returns true of the variable is locked.
Definition at line 426 of file WritableType.H.
References Writable::m_rwMode, and WURDE::W_LOCKED.
std::string getLockOwner | ( | ) | const |
Returns the name of the lock owner, if it is locked.
Definition at line 435 of file WritableType.H.
References Writable::m_lockOwner.
void COM_ADAPTOR_setValue | ( | Type | _value | ) |
Sets the value, overriding the lock state.
This function is ONLY to be used when building communication adaptors. SERIOUS BUGS will result if you EVER use these otherwise. Also, your first-born will be stricken with a Pox Of Unusual Size, your couch will catch fire (as will your hot water heater), and you will be PERSONALLY RESPONSIBLE for California breaking off in an enormous earthquake, floating across the ocean, and causing nuclear war with North Korea. You've been warned.
On a side note, the other way to do this is to make this inherit from something that the adaptors also inherit from(so we can make these protected), but my feeling is that that is even more of a bad hack.
Definition at line 441 of file WritableType.H.
References Writable::m_value.
void COM_ADAPTOR_setRWMode | ( | WriteMode | _mode | ) |
Sets the write mode, overriding the lock state.
This function is ONLY to be used when building communication adaptors. SERIOUS BUGS will result if you EVER use these otherwise. Also, your first-born will be stricken with a Pox Of Unusual Size, your couch will catch fire (as will your hot water heater), and you will be PERSONALLY RESPONSIBLE for California breaking off in an enormous earthquake, floating across the ocean, and causing nuclear war with North Korea. You've been warned.
On a side note, the other way to do this is to make this inherit from something that the adaptors also inherit from(so we can make these protected), but my feeling is that that is even more of a bad hack.
Definition at line 446 of file WritableType.H.
References Writable::m_rwMode.
void COM_ADAPTOR_setStatus | ( | StatusMode | stat | ) |
Sets the status, overriding the lock state.
This function is ONLY to be used when building communication adaptors. SERIOUS BUGS will result if you EVER use these otherwise. Also, your first-born will be stricken with a Pox Of Unusual Size, your couch will catch fire (as will your hot water heater), and you will be PERSONALLY RESPONSIBLE for California breaking off in an enormous earthquake, floating across the ocean, and causing nuclear war with North Korea. You've been warned.
On a side note, the other way to do this is to make this inherit from something that the adaptors also inherit from(so we can make these protected), but my feeling is that that is even more of a bad hack.
Definition at line 451 of file WritableType.H.
References Writable::m_sMode.
void COM_ADAPTOR_setLockOwner | ( | std::string | owner | ) |
Sets the lock owner, overriding the lock state.
This function is ONLY to be used when building communication adaptors. SERIOUS BUGS will result if you EVER use these otherwise. Also, your first-born will be stricken with a Pox Of Unusual Size, your couch will catch fire (as will your hot water heater), and you will be PERSONALLY RESPONSIBLE for California breaking off in an enormous earthquake, floating across the ocean, and causing nuclear war with North Korea. You've been warned.
On a side note, the other way to do this is to make this inherit from something that the adaptors also inherit from(so we can make these protected), but my feeling is that that is even more of a bad hack.
Definition at line 456 of file WritableType.H.
References Writable::m_lockOwner.
Definition at line 191 of file WritableType.H.
Type m_value [protected] |
Definition at line 202 of file WritableType.H.
Referenced by Writable::COM_ADAPTOR_setValue(), Writable::getValue(), Writable< std::vector< WURDE::VisionOperatorSpec > >::operator=(), Writable::setValue(), and Writable::Writable().
Definition at line 203 of file WritableType.H.
Referenced by Writable::COM_ADAPTOR_setRWMode(), Writable::getRWMode(), Writable::locked(), Writable< std::vector< WURDE::VisionOperatorSpec > >::operator=(), Writable::setLock(), Writable::setRWMode(), Writable::setValue(), Writable::unlock(), and Writable::Writable().
ConsumeMode m_cMode [protected] |
Definition at line 204 of file WritableType.H.
Referenced by Writable::getCMode(), Writable< std::vector< WURDE::VisionOperatorSpec > >::operator=(), Writable::setCMode(), Writable::setLock(), Writable::setRWMode(), Writable::setStatus(), Writable::setValue(), and Writable::Writable().
StatusMode m_sMode [protected] |
Definition at line 205 of file WritableType.H.
Referenced by Writable::COM_ADAPTOR_setStatus(), Writable::getStatus(), Writable< std::vector< WURDE::VisionOperatorSpec > >::operator=(), Writable::setStatus(), and Writable::setValue().
std::string m_id [protected] |
Definition at line 206 of file WritableType.H.
Referenced by Writable< std::vector< WURDE::VisionOperatorSpec > >::operator=(), Writable::setLock(), Writable::setValue(), Writable::unlock(), and Writable::Writable().
std::string m_lockOwner [protected] |
Definition at line 207 of file WritableType.H.
Referenced by Writable::COM_ADAPTOR_setLockOwner(), Writable::getLockOwner(), Writable< std::vector< WURDE::VisionOperatorSpec > >::operator=(), Writable::setLock(), Writable::setValue(), Writable::unlock(), and Writable::Writable().