![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Version FC
Dependencies: DmTftLibrary eeprom SX1280Lib filesystem mbed
Fork of MSNV2-Terminal_V1-5 by
Payload.cpp
- Committer:
- patrick_duc
- Date:
- 2018-08-30
- Revision:
- 19:4b147d8f9164
- Parent:
- 18:d5e7e56b0a0d
- Child:
- 20:b0281e8a375a
File content as of revision 19:4b147d8f9164:
//#include <strstream> #include "Component.hpp" #include "Payload.hpp" Payload::Payload(Payload::PAYLOAD_ID id, std::vector<Component*> components) : _id(id), _components(components) { for (std::vector<Component*>::iterator it = this->_components.begin(); it != this->_components.end(); it++) { Component* component = *it; for(std::vector<Service*>::iterator it = component->getServices().begin(); it != component->getServices().end(); it++) { this->_channels.push_back(*it); } } /* for (Component component : this->_components) { for (Service* channel : component.getServices()) { this->_channels.push_back(channel); } */ } Service* Payload::getServiceByRank(short channelRank) { /* if (channelRank < 1 || channelRank > 6) { throw ServiceException(); } */ if (channelRank < 1 || channelRank > 6) { return (Service*) NULL; } return this->_channels[channelRank - 1]; } std::ostream& operator<<(std::ostream& out, const Payload& payload) { out << "Payload id : " << payload._id << std::endl; out << "It contains " << payload._components.size() << " components" << std::endl; out << "List of components :\n------------------" << std::endl; //std::vector<const Component>::iterator it; std::vector< Component*>::iterator it; //for (it = payload._components.begin(); it != payload._components.end(); it++) { // std::cout << **it << std::endl; //} std::vector<Service*> channels = payload._channels; out << "There are " << channels.size() << " channels." << std::endl; out << "List of channels :\n------------------" << std::endl; for(std::vector<Service*>::iterator it = channels.begin(); it != channels.end(); it++) { Service* channel = *it; std::cout << *channel << std::endl; } /* for (Component* component : payload._components) { out << " (component : " << *component << ")"; } for (Service* channel : payload._channels) { out << " (channel : " << *channel << ")"; } */ return out; }