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:
- 18:d5e7e56b0a0d
- Parent:
- 16:a15cd98debe7
- Child:
- 19:4b147d8f9164
File content as of revision 18:d5e7e56b0a0d:
//#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<Channel*>::iterator it = component->getChannels().begin(); it != component->getChannels().end(); it++) { this->_channels.push_back(*it); } } /* for (Component component : this->_components) { for (Channel* channel : component.getChannels()) { this->_channels.push_back(channel); } */ } Channel* Payload::getChannelByRank(short channelRank) { /* if (channelRank < 1 || channelRank > 6) { throw ChannelException(); } */ if (channelRank < 1 || channelRank > 6) { return (Channel*) 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<Channel*> channels = payload._channels; out << "There are " << channels.size() << " channels." << std::endl; out << "List of channels :\n------------------" << std::endl; for(std::vector<Channel*>::iterator it = channels.begin(); it != channels.end(); it++) { Channel* channel = *it; std::cout << *channel << std::endl; } /* for (Component* component : payload._components) { out << " (component : " << *component << ")"; } for (Channel* channel : payload._channels) { out << " (channel : " << *channel << ")"; } */ return out; }