You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCETICE project - Copyright 2009 by Lucio Asnaghi.
  4. JUCETICE is based around the JUCE library - "Jules' Utility Class Extensions"
  5. Copyright 2007 by Julian Storer.
  6. ------------------------------------------------------------------------------
  7. JUCE and JUCETICE can be redistributed and/or modified under the terms of
  8. the GNU General Public License, as published by the Free Software Foundation;
  9. either version 2 of the License, or (at your option) any later version.
  10. JUCE and JUCETICE are distributed in the hope that they will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with JUCE and JUCETICE; if not, visit www.gnu.org/licenses or write to
  16. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  17. Boston, MA 02111-1307 USA
  18. ==============================================================================
  19. */
  20. BEGIN_JUCE_NAMESPACE
  21. //==============================================================================
  22. void SerializeFactoryXml::addSerializable (XmlSerializable* object)
  23. {
  24. objects.addIfNotAlreadyThere (object);
  25. }
  26. void SerializeFactoryXml::removeSerializable (XmlSerializable* object)
  27. {
  28. for (int i = 0; i < objects.size(); ++i)
  29. {
  30. if (objects.getUnchecked(i) == object)
  31. {
  32. objects.remove (i);
  33. break;
  34. }
  35. }
  36. }
  37. //==============================================================================
  38. XmlElement* SerializeFactoryXml::serializeObjects (const String& rootName)
  39. {
  40. XmlElement* root = new XmlElement (rootName);
  41. for (int i = 0; i < objects.size(); ++i)
  42. {
  43. root->addChildElement (objects.getUnchecked(i)->serialize ());
  44. }
  45. return root;
  46. }
  47. void SerializeFactoryXml::restoreObjects (XmlElement* root)
  48. {
  49. for (int i = 0; i < objects.size(); ++i)
  50. {
  51. objects.getUnchecked(i)->restore (root);
  52. }
  53. }
  54. //==============================================================================
  55. juce_ImplementSingleton (SerializeFactoryXml)
  56. END_JUCE_NAMESPACE