set parent when creating the Block
This commit is contained in:
parent
5d042f72e7
commit
56a0bf0f25
|
@ -153,14 +153,16 @@ using Block = std::shared_ptr<std::vector<std::shared_ptr<T>>>;
|
|||
@return std::shared_ptr<std::vector<std::shared_ptr<T>>> A block of PDU
|
||||
*/
|
||||
template<typename T>
|
||||
shared_ptr<vector<shared_ptr<T>>> readBlock(stream_ptr buffer) {
|
||||
auto block = shared_ptr<vector<shared_ptr<T>>>(new vector<shared_ptr<T>>);
|
||||
Block<T> readBlock(stream_ptr buffer, shared_ptr<PDU::Pdu> parent = 0) {
|
||||
auto block = Block<T>(new vector<shared_ptr<T>>);
|
||||
while(buffer->good()) {
|
||||
std::shared_ptr<T> pdu(new T(buffer));
|
||||
shared_ptr<T> pdu(new T(buffer));
|
||||
if (buffer->fail()) // stream failed during pdu constructor
|
||||
break;
|
||||
if (pdu->buffer()->fail()) // pdu buffer errors
|
||||
continue;
|
||||
if (parent != 0) // set parent
|
||||
pdu->setParent(parent);
|
||||
if (!block->empty()) // set inheritee
|
||||
pdu->setInherit(block->back());
|
||||
block->push_back(pdu); // add to block
|
||||
|
|
|
@ -102,11 +102,10 @@ Receive VECTOR_ROOT_E131_DATA vector'd packets.
|
|||
@param pdu is a shared pointer to the PDU
|
||||
*/
|
||||
void Receiver::rootDataHandler(RLP::pdu_ptr root) {
|
||||
auto block = PDU::readBlock<DATA::Pdu>(root->buffer());
|
||||
auto block = PDU::readBlock<DATA::Pdu>(root->buffer(), root);
|
||||
if (root->buffer()->fail())
|
||||
return;
|
||||
for(auto frame : *block) {
|
||||
frame->setParent(root);
|
||||
// 6.2.1 E1.31 Data Packet: Vector
|
||||
// Sources sending an E1.31 Data Packet shall set the E1.31 Layer's Vector
|
||||
// to VECTOR_E131_DATA_PACKET. This value indicates that the E1.31 framing
|
||||
|
@ -197,11 +196,10 @@ void Receiver::dataPacketHandler(DATA::pdu_ptr frame) {
|
|||
// TODO: do something with merging and arbitration
|
||||
|
||||
// PDU data will be a block of DMP
|
||||
auto block = PDU::readBlock<DMP::Pdu>(frame->buffer());
|
||||
auto block = PDU::readBlock<DMP::Pdu>(frame->buffer(), frame);
|
||||
if (frame->buffer()->fail())
|
||||
return;
|
||||
for (auto dmp : *block) {
|
||||
dmp->setParent(frame);
|
||||
// 7.2 DMP Layer: Vector
|
||||
// The DMP Layer's Vector shall be set to VECTOR_DMP_SET_PROPERTY, which
|
||||
// indicates a DMP Set Property message by sources. Receivers shall discard
|
||||
|
|
Loading…
Reference in New Issue