8e0a57f13344b7a0f54fcd0f75369ba89f9fcec4
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

1) /*
2)  * EtherPix simulator
3)  *
4)  * Copyright 2017 Stefan Schuermans <stefan schuermans info>
5)  *
6)  * This program is free software: you can redistribute it and/or modify
7)  * it under the terms of the GNU General Public License as published by
8)  * the Free Software Foundation, version 3 of the License.
9)  *
10)  *
11)  * This program is distributed in the hope that it will be useful,
12)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)  * GNU General Public License for more details.
15)  *
16)  * You should have received a copy of the GNU Lesser General Public License
17)  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18)  */
19) 
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

20) #include <arpa/inet.h>
21) #include <map>
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

22) #include <sstream>
23) #include <stdexcept>
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

24) #include <vector>
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

25) 
26) #include "distri.h"
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

27) #include "mapping.h"
28) #include "pixel.h"
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

29) 
30) /// constructor
31) Distri::Distri():
32)   m_distno(0),
33)   m_outputs(0),
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

34)   m_pixels(0),
35)   m_mappings(),
36)   m_outputMap()
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

37) {
38) }
39) 
40) /**
41)  * @brief initialize
42)  * @param[in] distno distributor number
43)  * @param[in] outputs number of outputs
44)  * @param[in] pixels number of pixels per output
45)  */
46) void Distri::init(unsigned long distno, unsigned long outputs,
47)                   unsigned long pixels)
48) {
49)   m_distno = distno;
50)   m_outputs = outputs;
51)   m_pixels = pixels;
52) }
53) 
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

54) /**
55)  * @brief set network address
56)  * @param[in] addr IPv4/port network address (UDP)
57)  */
58) void Distri::setAddr(struct sockaddr_in const &addr)
59) {
60)   m_addr = addr;
61) }
62) 
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

63) /**
64)  * @brief get mapping
65)  * @param[in] chan color channel
66)  * @return mapping mapping object of color channel
67)  * @throws std::exception in case of error
68)  */
69) Mapping const& Distri::getMapping(Mapping::Channel chan) const
70) {
71)   if (chan >= Mapping::ChannelCount) {
72)     std::stringstream msg;
73)     msg << "invalid channel: " << chan;
74)     throw std::runtime_error(msg.str());
75)   }
76)   return m_mappings[chan];
77) }
78) 
79) /**
80)  * @brief set mapping
81)  * @param[in] chan color channel
82)  * @param[in] mapping new mapping object for color channel
83)  * @throws std::exception in case of error
84)  */
85) void Distri::setMapping(Mapping::Channel chan, Mapping const &mapping)
86) {
87)   if (chan >= Mapping::ChannelCount) {
88)     std::stringstream msg;
89)     msg << "invalid channel: " << chan;
90)     throw std::runtime_error(msg.str());
91)   }
92)   m_mappings[chan] = mapping;
93) }
94)