Switch to unified view

a/src/ohservice.hxx b/src/ohservice.hxx
...
...
20
#include <string>         
20
#include <string>         
21
#include <unordered_map>  
21
#include <unordered_map>  
22
#include <vector>         
22
#include <vector>         
23
23
24
#include "libupnpp/device/device.hxx"
24
#include "libupnpp/device/device.hxx"
25
#include "upmpdutils.hxx"
25
#include "upmpd.hxx"
26
#include "upmpd.hxx"
26
27
27
using namespace UPnPP;
28
using namespace UPnPP;
28
29
29
// A parent class for all openhome service, to share a bit of state
30
// A parent class for all openhome service, to share a bit of state
...
...
33
    OHService(const std::string& servtp, const std::string &servid, UpMpd *dev)
34
    OHService(const std::string& servtp, const std::string &servid, UpMpd *dev)
34
        : UpnpService(servtp, servid, dev), m_dev(dev) {
35
        : UpnpService(servtp, servid, dev), m_dev(dev) {
35
    }
36
    }
36
    virtual ~OHService() { }
37
    virtual ~OHService() { }
37
38
38
    // Implementation in upmpd.cxx
39
    virtual bool getEventData(bool all, std::vector<std::string>& names, 
39
    virtual bool getEventData(bool all, std::vector<std::string>& names, 
40
                              std::vector<std::string>& values);
40
                              std::vector<std::string>& values) {
41
        //LOGDEB("OHService::getEventData" << std::endl);
41
42
43
        std::unordered_map<std::string, std::string> state, changed;
44
        makestate(state);
45
        if (all) {
46
            changed = state;
47
        } else {
48
            changed = diffmaps(m_state, state);
49
        }
50
        m_state = state;
51
52
        for (auto& it : changed) {
53
            //LOGDEB("OHService: state change: " << it.first << " -> "
54
            // << it.second << endl);
55
            names.push_back(it.first);
56
            values.push_back(it.second);
57
        }
58
59
        return true;
60
    }
61
    
42
protected:
62
protected:
43
    virtual bool makestate(std::unordered_map<std::string, std::string> &) = 0;
63
    virtual bool makestate(std::unordered_map<std::string, std::string> &) = 0;
44
    // State variable storage
64
    // State variable storage
45
    std::unordered_map<std::string, std::string> m_state;
65
    std::unordered_map<std::string, std::string> m_state;
46
    UpMpd *m_dev;
66
    UpMpd *m_dev;