diff --git a/dmx/universe.cpp b/dmx/universe.cpp index 0d05888..e4d4684 100644 --- a/dmx/universe.cpp +++ b/dmx/universe.cpp @@ -25,7 +25,6 @@ #include "universe.h" namespace DMX { -using std::copy; /** */ @@ -33,6 +32,19 @@ Universe::Universe() { null_start_data_.fill(0); } +/** + Get value of a slot. + + @param uint16_t address of the requested slot. + @return const uint8_t value of the slot. +*/ +const uint8_t Universe::slot (uint16_t address) const +{ + if (address > 512) return 0; + return null_start_data_[address]; +} + + /** accept new data from receiver @@ -42,7 +54,7 @@ void Universe::set(vector vect) { switch (vect.front()) { // start code case E111_NULL_START: vect.resize(null_start_data_.size(), 0); // pad shorter, truncate larger - copy(vect.begin(), vect.end(), null_start_data_.begin()); + std::copy(vect.begin(), vect.end(), null_start_data_.begin()); for (const auto &cb : callbacks_) cb(this); break; diff --git a/dmx/universe.h b/dmx/universe.h index fccad62..1b89777 100644 --- a/dmx/universe.h +++ b/dmx/universe.h @@ -59,10 +59,11 @@ class Universe { public: Universe (); - DimmerData * data() { return &null_start_data_; } - void onData (const DataHandler callback); - void set (vector); - uint8_t slot (uint16_t address) { return null_start_data_[address]; } + const DimmerData * data() const { return &null_start_data_; } + const uint8_t slot (uint16_t address) const; + + void set (vector); + void onData (const DataHandler); private: DimmerData null_start_data_;