Cogs.Core
DataSet2DComponent.cpp
1#include <algorithm>
2#include "DataSet2DComponent.h"
3#include "Types.h"
4
5using namespace Cogs::Reflection;
6
7void Cogs::Core::DataSet2DComponent::registerType()
8{
9 Field fields[] = {
13 };
14
15 Method methods[] = {
16 Method(Name("update"), &DataSet2DComponent::update)
17 };
18
19 DynamicComponent::registerDerivedType<DataSet2DComponent>()
20 .setFields(fields)
21 .setMethods(methods);
22}
23
24void Cogs::Core::DataSet2DComponent::update()
25{
26 if (hasChanged()) {
27
28 hasData = (sizeI > 0) && (sizeJ > 0) &&
29 (static_cast<size_t>(sizeI)*static_cast<size_t>(sizeJ) == data.size());
30
31 if (hasData) {
32 auto mm = std::minmax_element(data.cbegin(), data.cend());
33 minValue = *mm.first;
34 maxValue = *mm.second;
35 }
36 else {
37 minValue = 0.f;
38 maxValue = 0.f;
39 }
40
41 }
42}
Field definition describing a single data member of a data structure.
Definition: Field.h:68
Simple method definition.
Definition: Method.h:72
Contains reflection support.
Definition: Component.h:11
std::vector< float > data
Values of the dataset, should be of size layout.x*layout.y.
int sizeI
2D layout of dataset.
int sizeJ
2D layout of dataset.
Represents an unique name.
Definition: Name.h:70