textureCollection.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file textureCollection.h
  10. * @author drose
  11. * @date 2002-03-16
  12. */
  13. #ifndef TEXTURECOLLECTION_H
  14. #define TEXTURECOLLECTION_H
  15. #include "pandabase.h"
  16. #include "pointerToArray.h"
  17. #include "texture.h"
  18. /**
  19. * Manages a list of Texture objects, as returned by
  20. * TexturePool::find_all_textures().
  21. */
  22. class EXPCL_PANDA_GOBJ TextureCollection {
  23. PUBLISHED:
  24. TextureCollection();
  25. TextureCollection(const TextureCollection &copy);
  26. void operator = (const TextureCollection &copy);
  27. INLINE ~TextureCollection();
  28. PY_EXTENSION(TextureCollection(PyObject *self, PyObject *sequence));
  29. PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
  30. void add_texture(Texture *texture);
  31. bool remove_texture(Texture *texture);
  32. void add_textures_from(const TextureCollection &other);
  33. void remove_textures_from(const TextureCollection &other);
  34. void remove_duplicate_textures();
  35. bool has_texture(Texture *texture) const;
  36. void clear();
  37. void reserve(size_t num);
  38. Texture *find_texture(const std::string &name) const;
  39. int get_num_textures() const;
  40. Texture *get_texture(int index) const;
  41. MAKE_SEQ(get_textures, get_num_textures, get_texture);
  42. Texture *operator [] (int index) const;
  43. int size() const;
  44. INLINE void operator += (const TextureCollection &other);
  45. INLINE TextureCollection operator + (const TextureCollection &other) const;
  46. // Method names to satisfy Python's conventions.
  47. INLINE void append(Texture *texture);
  48. INLINE void extend(const TextureCollection &other);
  49. void output(std::ostream &out) const;
  50. void write(std::ostream &out, int indent_level = 0) const;
  51. private:
  52. typedef PTA(PT(Texture)) Textures;
  53. Textures _textures;
  54. };
  55. INLINE std::ostream &operator << (std::ostream &out, const TextureCollection &col) {
  56. col.output(out);
  57. return out;
  58. }
  59. #include "textureCollection.I"
  60. #endif