~ubuntu-branches/ubuntu/vivid/mygui/vivid

« back to all changes in this revision

Viewing changes to Tools/EditorFramework/DataTypeManager.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Howard, Bret Curtis, Scott Howard
  • Date: 2014-09-18 17:57:48 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140918175748-dd8va78mvpw1jbes
Tags: 3.2.1-1
[ Bret Curtis ]
* Updated license for majority of files from LGPL to Expat (MIT)

[ Scott Howard ]
* New upstream release
* Updated patch to add build option for system GLEW libraries
* All patches accepted upstream except shared_libraries.patch
* Bumped SONAME due to dropped symbols, updated *.symbols and package
  names
* Updated license of debian/* to Expat with permission of all authors
* Don't install Doxygen autogenerated md5 and map files (thanks
  lintian)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!
 
2
        @file
 
3
        @author         Albert Semenov
 
4
        @date           07/2012
 
5
*/
 
6
 
 
7
#include "Precompiled.h"
 
8
#include "DataTypeManager.h"
 
9
#include "pugixml.hpp"
 
10
#include "MyGUI_DataManager.h"
 
11
 
 
12
namespace tools
 
13
{
 
14
 
 
15
        DataTypeManager* DataTypeManager::mInstance = nullptr;
 
16
 
 
17
        DataTypeManager::DataTypeManager()
 
18
        {
 
19
                mInstance = this;
 
20
        }
 
21
 
 
22
        DataTypeManager::~DataTypeManager()
 
23
        {
 
24
                mInstance = nullptr;
 
25
        }
 
26
 
 
27
        DataTypeManager& DataTypeManager::getInstance()
 
28
        {
 
29
                return *mInstance;
 
30
        }
 
31
 
 
32
        DataTypeManager* DataTypeManager::getInstancePtr()
 
33
        {
 
34
                return mInstance;
 
35
        }
 
36
 
 
37
        void DataTypeManager::initialise()
 
38
        {
 
39
        }
 
40
 
 
41
        void DataTypeManager::shutdown()
 
42
        {
 
43
                clear();
 
44
        }
 
45
 
 
46
        void DataTypeManager::load(const std::string& _fileName)
 
47
        {
 
48
                std::string fileName = MyGUI::DataManager::getInstance().getDataPath(_fileName);
 
49
                pugi::xml_document doc;
 
50
                pugi::xml_parse_result result = doc.load_file(fileName.c_str());
 
51
                if (result)
 
52
                {
 
53
                        pugi::xpath_node_set nodes = doc.select_nodes("Document/DataTypes/DataType");
 
54
                        for (pugi::xpath_node_set::const_iterator node = nodes.begin(); node != nodes.end(); node ++)
 
55
                        {
 
56
                                DataTypePtr data = DataTypePtr(new DataType());
 
57
                                data->deserialization((*node).node());
 
58
                                mDataInfos.push_back(data);
 
59
                        }
 
60
                }
 
61
        }
 
62
 
 
63
        void DataTypeManager::clear()
 
64
        {
 
65
                mDataInfos.clear();
 
66
        }
 
67
 
 
68
        DataTypePtr DataTypeManager::getType(const std::string& _type)
 
69
        {
 
70
                for (VectorDataInfo::const_iterator data = mDataInfos.begin(); data != mDataInfos.end(); data ++)
 
71
                {
 
72
                        if ((*data)->getName() == _type)
 
73
                                return *data;
 
74
                }
 
75
 
 
76
                return nullptr;
 
77
        }
 
78
 
 
79
        DataTypePtr DataTypeManager::getParentType(const std::string& _type)
 
80
        {
 
81
                for (VectorDataInfo::const_iterator data = mDataInfos.begin(); data != mDataInfos.end(); data ++)
 
82
                {
 
83
                        if ((*data)->isChild(_type))
 
84
                                return *data;
 
85
                }
 
86
 
 
87
                return nullptr;
 
88
        }
 
89
 
 
90
}