Attribute.h 940 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 Jérémie Dumas <jeremie.dumas@ens-lyon.org>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_ATTRIBUTE_H
  9. #define IGL_ATTRIBUTE_H
  10. #include <typeindex>
  11. namespace igl
  12. {
  13. struct AttributeBase
  14. {
  15. private:
  16. std::type_index derived_type_;
  17. public:
  18. AttributeBase(std::type_index t) : derived_type_(t) { }
  19. virtual ~AttributeBase() = default;
  20. std::type_index type() const { return derived_type_; }
  21. };
  22. // -----------------------------------------------------------------------------
  23. template<typename T>
  24. struct Attribute : public AttributeBase
  25. {
  26. // Constructor
  27. Attribute() : AttributeBase(typeid(T)) { }
  28. // Data
  29. T content_;
  30. };
  31. } // namespace igl
  32. #endif // IGL_ATTRIBUTE_H