|
DUDS
|
Distributed Update of Data from Something
|
Represents a two-way conversation with a device. More...
#include <Conversation.hpp>
Public Types | |
| typedef std::vector< std::unique_ptr< ConversationPart > > | PartVector |
| The storage type for the ConversationPart objects. More... | |
Public Member Functions | |
| Conversation ()=default | |
| template<class CP > | |
| void | add (std::unique_ptr< CP > &cp) |
| Adds an already constructed conversation part to the end of the conversation. More... | |
| template<class CP > | |
| CP & | add (const CP &cp) |
| Adds a copy of an existing conversation part to the end of the conversation. More... | |
| ConversationExternal & | addInputBuffer (char *a, std::size_t len) |
| Adds a conversation part that will write input into the given buffer. More... | |
| template<typename T , std::size_t N> | |
| ConversationExternal & | addInputBuffer (T(&a)[N]) |
| Adds a conversation part that will write input into the given array. More... | |
| ConversationVector & | addInputVector (std::size_t len) |
| Creates a new ConversationVector for fixed length input and initializes it with the given length. More... | |
| template<class LengthType > | |
| ConversationVector & | addInputVector (std::size_t len, LengthType lt) |
| Creates a new ConversationVector for fixed or variable length input and initializes it with the given length. More... | |
| ConversationExternal & | addOutputBuffer (const char *a, std::size_t len) |
| Adds a conversation part that will use the given buffer for output. More... | |
| template<typename T , std::size_t N> | |
| ConversationExternal & | addOutputBuffer (const T(&a)[N]) |
| Adds a conversation part that will use the given array for output. More... | |
| ConversationVector & | addOutputVector () |
| Creates a new ConversationVector for output and returns it for modification. More... | |
| PartVector::iterator | begin () |
| An iterator to the first ConversationPart that allows modification. More... | |
| PartVector::const_iterator | cbegin () const |
| An iterator to the first ConversationPart that does not allow modification. More... | |
| PartVector::const_iterator | cend () const |
| An iterator to the end of ConversationPart vector. More... | |
| void | clear () |
| Makes the conversation empty. More... | |
| bool | empty () const |
| Returns true if the conversation has no parts. More... | |
| PartVector::iterator | end () |
| An iterator to the end of ConversationPart vector. More... | |
| ConversationExtractor | extract () const |
| Returns an extraction object that can be used to read all the conversation data marked extractible. More... | |
| std::size_t | size () const |
| Returns the number of parts within this conversation. More... | |
Protected Attributes | |
| PartVector | parts |
| The container of the parts that make up the full conversation. More... | |
Represents a two-way conversation with a device.
Output data is written prior to transmission, and input space is pre-allocated. The data is held in ConversationPart objects; there is no hard limit on the number of parts that can be added.
A Conversation can be used multiple times. Each time, input data will be overwritten. Output data can be reused rather than rewritten.
After using a Conversation for a transmission, the input is read using a ConversationExtractor object. It references the data held in the Conversation object rather than copy it, so the source Conversation must not be modified while the ConversationExtractor object is in use. The ConversationExtractor can outlive the Conversation, but it must not be used to read data from a destructed Conversation.
Definition at line 52 of file Conversation.hpp.
| typedef std::vector< std::unique_ptr<ConversationPart> > duds::hardware::interface::Conversation::PartVector |
The storage type for the ConversationPart objects.
Definition at line 57 of file Conversation.hpp.
|
default |
|
inline |
Adds an already constructed conversation part to the end of the conversation.
| CP | The class of the conversation part. |
| cp | The conversation part to add. The Conversation object will assume responsibility for the part. |
Definition at line 139 of file Conversation.hpp.
|
inline |
Adds a copy of an existing conversation part to the end of the conversation.
| CP | The class of the conversation part. It must be derived from ConversationPart. |
| cp | The conversation part to copy. |
Definition at line 151 of file Conversation.hpp.
| ConversationExternal & duds::hardware::interface::Conversation::addInputBuffer | ( | char * | a, |
| std::size_t | len | ||
| ) |
Adds a conversation part that will write input into the given buffer.
| a | The start of the buffer. |
| len | The length of the buffer in bytes. The current implementation requires this length to be fixed rather than the maximum amount of a variable length input. |
Definition at line 53 of file Conversation.cpp.
Referenced by addOutputBuffer().
|
inline |
Adds a conversation part that will write input into the given array.
| T | The element type of the array. |
| N | The length of the buffer in elements of T. The current implementation requires this length to be fixed rather than the maximum amount of a variable length input. |
| a | The array. |
Definition at line 216 of file Conversation.hpp.
| ConversationVector & duds::hardware::interface::Conversation::addInputVector | ( | std::size_t | len | ) |
Creates a new ConversationVector for fixed length input and initializes it with the given length.
| len | The length of the input in bytes. |
Definition at line 37 of file Conversation.cpp.
Referenced by add(), duds::hardware::devices::instruments::AM2320::AM2320(), duds::hardware::devices::instruments::AMG88xx::AMG88xx(), duds::hardware::devices::instruments::LSM9DS1AccelGyro::configure(), duds::hardware::devices::instruments::FXOS8700CQ::configure(), duds::hardware::devices::instruments::LSM9DS1Mag::configure(), duds::hardware::devices::instruments::FXOS8700CQ::FXOS8700CQ(), duds::hardware::devices::instruments::ISL29125::ISL29125(), duds::hardware::devices::instruments::LSM9DS1AccelGyro::LSM9DS1AccelGyro(), duds::hardware::devices::instruments::LSM9DS1Mag::LSM9DS1Mag(), duds::hardware::devices::instruments::AMG88xx::start(), duds::hardware::devices::instruments::FXOS8700CQ::suspend(), and duds::hardware::devices::instruments::TSL2591::TSL2591().
|
inline |
Creates a new ConversationVector for fixed or variable length input and initializes it with the given length.
| LengthType | Either ConversationVector::FixedLength or ConversationVector::VaribleLength. |
| len | The length of the input in bytes. |
| lt | The length type object. |
Definition at line 176 of file Conversation.hpp.
| ConversationExternal & duds::hardware::interface::Conversation::addOutputBuffer | ( | const char * | a, |
| std::size_t | len | ||
| ) |
Adds a conversation part that will use the given buffer for output.
| a | The start of the buffer. |
| len | The length of the buffer in bytes. |
Definition at line 44 of file Conversation.cpp.
Referenced by addInputVector().
|
inline |
Adds a conversation part that will use the given array for output.
| T | The element type of the array. |
| N | The length of the array in elements of T. |
| a | The array. |
Definition at line 194 of file Conversation.hpp.
| ConversationVector & duds::hardware::interface::Conversation::addOutputVector | ( | ) |
Creates a new ConversationVector for output and returns it for modification.
Definition at line 30 of file Conversation.cpp.
Referenced by add(), duds::hardware::devices::instruments::AM2320::AM2320(), duds::hardware::devices::instruments::AMG88xx::AMG88xx(), duds::hardware::devices::instruments::AMG88xx::configure(), duds::hardware::devices::instruments::LSM9DS1AccelGyro::configure(), duds::hardware::devices::instruments::FXOS8700CQ::configure(), duds::hardware::devices::instruments::LSM9DS1Mag::configure(), duds::hardware::devices::instruments::FXOS8700CQ::FXOS8700CQ(), duds::hardware::devices::instruments::ISL29125::init(), duds::hardware::devices::instruments::TSL2591::init(), duds::hardware::devices::instruments::ISL29125::ISL29125(), duds::hardware::devices::instruments::LSM9DS1AccelGyro::LSM9DS1AccelGyro(), duds::hardware::devices::instruments::LSM9DS1Mag::LSM9DS1Mag(), duds::hardware::devices::instruments::AMG88xx::start(), duds::hardware::devices::instruments::FXOS8700CQ::start(), duds::hardware::devices::instruments::ISL29125::suspend(), duds::hardware::devices::instruments::TSL2591::suspend(), duds::hardware::devices::instruments::AMG88xx::suspend(), duds::hardware::devices::instruments::LSM9DS1AccelGyro::suspend(), duds::hardware::devices::instruments::FXOS8700CQ::suspend(), duds::hardware::devices::instruments::LSM9DS1Mag::suspend(), and duds::hardware::devices::instruments::TSL2591::TSL2591().
|
inline |
An iterator to the first ConversationPart that allows modification.
Definition at line 90 of file Conversation.hpp.
Referenced by duds::hardware::interface::linux::DevI2c::converse(), and duds::hardware::interface::MasterSyncSerial::converseAlreadyOpen().
|
inline |
An iterator to the first ConversationPart that does not allow modification.
Definition at line 103 of file Conversation.hpp.
Referenced by duds::hardware::interface::ConversationExtractor::set().
|
inline |
An iterator to the end of ConversationPart vector.
Definition at line 109 of file Conversation.hpp.
Referenced by duds::hardware::interface::ConversationExtractor::advance(), duds::hardware::interface::ConversationExtractor::nextPart(), and duds::hardware::interface::ConversationExtractor::set().
|
inline |
Makes the conversation empty.
Definition at line 127 of file Conversation.hpp.
Referenced by duds::hardware::devices::instruments::AMG88xx::AMG88xx(), duds::hardware::devices::instruments::LSM9DS1AccelGyro::configure(), duds::hardware::devices::instruments::FXOS8700CQ::configure(), duds::hardware::devices::instruments::LSM9DS1Mag::configure(), duds::hardware::devices::instruments::FXOS8700CQ::FXOS8700CQ(), duds::hardware::devices::instruments::ISL29125::init(), duds::hardware::devices::instruments::TSL2591::init(), duds::hardware::devices::instruments::LSM9DS1AccelGyro::LSM9DS1AccelGyro(), duds::hardware::devices::instruments::LSM9DS1Mag::LSM9DS1Mag(), duds::hardware::devices::instruments::AMG88xx::start(), duds::hardware::devices::instruments::FXOS8700CQ::suspend(), and duds::hardware::devices::instruments::TSL2591::TSL2591().
|
inline |
Returns true if the conversation has no parts.
Definition at line 121 of file Conversation.hpp.
Referenced by duds::hardware::interface::linux::DevI2c::converse(), duds::hardware::devices::instruments::ISL29125::resume(), and duds::hardware::devices::instruments::TSL2591::resume().
|
inline |
An iterator to the end of ConversationPart vector.
Definition at line 96 of file Conversation.hpp.
Referenced by duds::hardware::interface::linux::DevI2c::converse(), and duds::hardware::interface::MasterSyncSerial::converseAlreadyOpen().
| ConversationExtractor duds::hardware::interface::Conversation::extract | ( | ) | const |
Returns an extraction object that can be used to read all the conversation data marked extractible.
Definition at line 59 of file Conversation.cpp.
Referenced by addInputBuffer().
|
inline |
Returns the number of parts within this conversation.
Definition at line 115 of file Conversation.hpp.
Referenced by duds::hardware::interface::linux::DevI2c::converse().
|
protected |
The container of the parts that make up the full conversation.
Definition at line 62 of file Conversation.hpp.
Referenced by addInputBuffer(), addInputVector(), addOutputBuffer(), and addOutputVector().