| 1 | // Aseprite UI Library |
|---|---|
| 2 | // Copyright (C) 2001-2015 David Capello |
| 3 | // |
| 4 | // This file is released under the terms of the MIT license. |
| 5 | // Read LICENSE.txt for more information. |
| 6 | |
| 7 | #ifdef HAVE_CONFIG_H |
| 8 | #include "config.h" |
| 9 | #endif |
| 10 | |
| 11 | #include "ui/component.h" |
| 12 | #include "ui/property.h" |
| 13 | |
| 14 | namespace ui { |
| 15 | |
| 16 | Component::Component() |
| 17 | { |
| 18 | } |
| 19 | |
| 20 | Component::~Component() |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | PropertyPtr Component::getProperty(const std::string& name) const |
| 25 | { |
| 26 | auto it = m_properties.find(name); |
| 27 | if (it != m_properties.end()) |
| 28 | return it->second; |
| 29 | else |
| 30 | return PropertyPtr(); |
| 31 | } |
| 32 | |
| 33 | void Component::setProperty(PropertyPtr property) |
| 34 | { |
| 35 | m_properties[property->getName()] = property; |
| 36 | } |
| 37 | |
| 38 | bool Component::hasProperty(const std::string& name) const |
| 39 | { |
| 40 | return (m_properties.find(name) != m_properties.end()); |
| 41 | } |
| 42 | |
| 43 | void Component::removeProperty(const std::string& name) |
| 44 | { |
| 45 | Properties::iterator it = m_properties.find(name); |
| 46 | if (it != m_properties.end()) |
| 47 | m_properties.erase(it); |
| 48 | } |
| 49 | |
| 50 | const Component::Properties& Component::getProperties() const |
| 51 | { |
| 52 | return m_properties; |
| 53 | } |
| 54 | |
| 55 | } // namespace ui |
| 56 |