Clipboard.cpp 1.22 KB
Newer Older
1
#include "Clipboard.hpp"
2
#include "objects/Object.hpp"
3
4
5

using namespace corryvreckan;

6
void Clipboard::put(std::string name, Objects* objects) {
7
8
9
10
    m_dataID.push_back(name);
    m_data[name] = objects;
}

11
void Clipboard::put(std::string name, std::string type, Objects* objects) {
12
13
14
15
16
17
18
19
    m_dataID.push_back(name + type);
    m_data[name + type] = objects;
}

void Clipboard::put_persistent(std::string name, double value) {
    m_persistent_data[name] = value;
}

20
Objects* Clipboard::get(std::string name) {
21
22
23
24
25
    if(m_data.count(name) == 0)
        return NULL;
    return m_data[name];
}

26
Objects* Clipboard::get(std::string name, std::string type) {
27
28
29
30
31
32
33
34
35
36
37
    if(m_data.count(name + type) == 0)
        return NULL;
    return m_data[name + type];
}

double Clipboard::get_persistent(std::string name) {
    return m_persistent_data[name];
}

void Clipboard::clear() {
    for(auto& id : m_dataID) {
38
39
        Objects* collection = m_data[id];
        for(Objects::iterator it = collection->begin(); it != collection->end(); it++)
40
41
42
43
44
45
46
47
48
49
50
            delete(*it);
        delete m_data[id];
        m_data.erase(id);
    }
    m_dataID.clear();
}

void Clipboard::checkCollections() {
    for(auto& name : m_dataID)
        LOG(DEBUG) << "Data held: " << name;
}