blob: 8b16b642981603f49d35b00ead27e60f06f6d9bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/*
* Copyright (C) 2017 Thales Lima Oliveira <thales@ufu.br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "ElementDataObject.h"
ElementDataObject::ElementDataObject() : wxDataObjectSimple(wxDataFormat(wxT("PSPCopy")))
{
m_elementsLists = new ElementsLists();
}
ElementDataObject::ElementDataObject(std::vector<Element*> elementList) : wxDataObjectSimple(wxDataFormat(wxT("PSPCopy")))
{
m_elementsLists = new ElementsLists();
if(elementList.size() > 0) {
// Separate buses (parents) from the rest of the elements (childs).
for(auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
Element* copy = (*it)->GetCopy();
if(copy) {
if(Bus* bus = dynamic_cast<Bus*>(copy))
m_elementsLists->parentList.push_back(bus);
else
m_elementsLists->elementList.push_back(copy);
}
}
}
}
ElementDataObject::~ElementDataObject() {}
size_t ElementDataObject::GetDataSize() const
{
return sizeof(void*);
//return sizeof(*this);
}
bool ElementDataObject::GetDataHere(void* buf) const
{
*(ElementsLists**)buf = m_elementsLists;
//buf = m_elementsLists;
return true;
}
bool ElementDataObject::SetData(size_t len, const void* buf)
{
m_elementsLists = *(ElementsLists**)buf;
//m_elementsLists = const_cast<ElementsLists*>(static_cast<const ElementsLists*>(buf));
return true;
}
|