home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / include / k3d / k3dsdk / named_attribute_arrays.h < prev    next >
C/C++ Source or Header  |  2008-11-07  |  2KB  |  66 lines

  1. #ifndef K3DSDK_NAMED_ATTRIBUTE_ARRAYS_H
  2. #define K3DSDK_NAMED_ATTRIBUTE_ARRAYS_H
  3.  
  4. // K-3D
  5. // Copyright (c) 1995-2008, Timothy M. Shead
  6. //
  7. // Contact: tshead@k-3d.com
  8. //
  9. // This program is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. // General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public
  20. // License along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22.  
  23. #include "attribute_arrays.h"
  24.  
  25. namespace k3d
  26. {
  27.  
  28. /// Defines a collection of named attribute_arrays objects.  The length of the individual
  29. /// attribute_arrays objects may vary.
  30. class named_attribute_arrays :
  31.     public std::map<string_t, attribute_arrays>
  32. {
  33. public:
  34.     /// Return an attribute_array by name, or NULL
  35.     const attribute_arrays* lookup(const string_t& Name) const;
  36.     /// Return an attribute_array by name, or NULL
  37.     attribute_arrays* writable(const string_t& Name);
  38.     /// Returns true iff two collections are equivalent, using the imprecise semantics of almost_equal to compare values.
  39.     const bool_t almost_equal(const named_attribute_arrays& Other, const uint64_t Threshold) const;
  40. };
  41.  
  42. /// Specialization of almost_equal that tests named_attribute_arrays for equality
  43. template<>
  44. class almost_equal<named_attribute_arrays>
  45. {
  46.     typedef named_attribute_arrays T;
  47.  
  48. public:
  49.     almost_equal(const uint64_t Threshold) :
  50.         threshold(Threshold)
  51.     {
  52.     }
  53.  
  54.     inline const bool_t operator()(const T& A, const T& B) const
  55.     {
  56.         return A.almost_equal(B, threshold);
  57.     }
  58.  
  59.     const uint64_t threshold;
  60. };
  61.  
  62. } // namespace k3d
  63.  
  64. #endif // !K3DSDK_NAMED_ATTRIBUTE_ARRAYS_H
  65.  
  66.