BlinkenArea - GitList
Repositories
Blog
Wiki
libetherpix
Code
Commits
Branches
Tags
Search
Tree:
8e0a57f
Branches
Tags
master
libetherpix
simulator
distri.h
complete implementation of config file parsing
Stefan Schuermans
commited
8e0a57f
at 2017-06-10 21:21:50
distri.h
Blame
History
Raw
/* * EtherPix simulator * * Copyright 2017 Stefan Schuermans <stefan schuermans info> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DISTRI_H #define DISTRI_H #include <arpa/inet.h> #include <map> #include <vector> #include "mapping.h" #include "pixel.h" /// distributor class Distri { public: /// constructor Distri(); /** * @brief initialize * @param[in] distno distributor number * @param[in] outputs number of outputs * @param[in] pixels number of pixels per output */ void init(unsigned long distno, unsigned long outputs, unsigned long pixels); /// get distributor number unsigned long getNo() const { return m_distno; } /// get number of outputs unsigned long getOutputs() const { return m_outputs; } /// get number of pixels at each output unsigned long getPixels() const { return m_pixels; } /** * @brief set network address * @param[in] addr IPv4/port network address (UDP) */ void setAddr(struct sockaddr_in const &addr); /** * @brief get mapping * @param[in] chan color channel * @return mapping mapping object of color channel * @throws std::exception in case of error */ Mapping const& getMapping(Mapping::Channel chan) const; /** * @brief set mapping * @param[in] chan color channel * @param[in] mapping new mapping object for color channel * @throws std::exception in case of error */ void setMapping(Mapping::Channel chan, Mapping const &mapping); /** * @brief add output to distributor * @param[in] outno number of output * @throws std::exception in case of error */ void addOutput(unsigned long outno); /** * @brief add pixel to output of distributor * @param[in] outno number of output * @param[in] pixel pixel object to add * @throws std::exception in case of error */ void addPixel(unsigned long outno, Pixel const &pixel); protected: /// output data struct Output { std::vector<Pixel> m_pixels; ///< pixels at this output }; /// map out outputs: output number -> output data typedef std::map<unsigned long, Output> OutputMap; protected: /// distributor number unsigned long m_distno; /// number of outputs unsigned long m_outputs; /// number of pixels per output unsigned long m_pixels; /// network address struct sockaddr_in m_addr; /// mappings of color channels Mapping m_mappings[Mapping::ChannelCount]; /// outputs OutputMap m_outputMap; }; #endif // #ifndef DISTRI_H