Version FC

Dependencies:   DmTftLibrary eeprom SX1280Lib filesystem mbed

Fork of MSNV2-Terminal_V1-5 by Francis CHATAIN

Component.hpp

Committer:
patrick_duc
Date:
2018-10-19
Branch:
Integration
Revision:
38:9b43b2415093
Parent:
37:b565750d9978
Child:
39:13e66d087ae9

File content as of revision 38:9b43b2415093:

#ifndef __COMPONENT_HPP__
#define __COMPONENT_HPP__

#include "Context.h"


#include <vector>

#ifdef TEST_ENVIRONMENT
#include <sstream>
#endif

#include "Service.hpp"


namespace misnet {
    class Component;
}

class misnet::Component {
public:

    enum COMPONENT_ID {
        HTS221 = 1,
        LPS22HB = 2,
        LSM303A = 3,
        LSM6DSL = 4,
        BME280 = 5,
        DS18B20 = 6
    };

    Component(COMPONENT_ID id, std::vector<misnet::Service*>& services) {
        this->id = id;
        this->services = services;
    }

    std::vector<misnet::Service*>& getServices() {
        return this->services;
    }

    COMPONENT_ID getId() {
        return this->id;
    }

    // Loop on all component services to read their value
    void readValues(std::vector<misnet::Service *> servicesWithAsynchronousRead) {
        for (std::vector<misnet::Service*>::iterator
            srvIt = this->services.begin();
                srvIt != this->services.end();
                srvIt++) {
            (*srvIt)->readValue(servicesWithAsynchronousRead);
        }
    }

#ifdef TEST_ENVIRONMENT
    std::string toString() {
        std::ostringstream stringStream;
        stringStream << "Component id : " << this->id << std::endl;

        for (std::vector<misnet::Service*>::iterator it = services.begin(); it != services.end(); it++) {
            misnet::Service * service = *it;
            stringStream << service->toString() << std::endl;
        }

        return stringStream.str();
    }
#endif


private:
    COMPONENT_ID id;
    std::vector<misnet::Service*> services;
};

#endif // __COMPONENT_HPP__