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

  1. #ifndef K3DSDK_IPROPERTY_H
  2. #define K3DSDK_IPROPERTY_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. /** \file
  24.     \author Tim Shead (tshead@k-3d.com)
  25. */
  26.  
  27. #include "ihint.h"
  28. #include "signal_system.h"
  29. #include "types.h"
  30.  
  31. #include <boost/any.hpp>
  32.  
  33. namespace k3d
  34. {
  35.  
  36. class inode;
  37.  
  38. /// Abstract interface for a name-value pair with fixed type (note - if you want to write to a property, query for iwritable_property and be prepared for it to fail for read-only properties)
  39. class iproperty :
  40.     public virtual iunknown
  41. {
  42. public:
  43.     virtual ~iproperty() {}
  44.  
  45.     /// Returns the property name, which will be used as a unique identifier for programmatic access to the property (i.e. through scripting)
  46.     virtual const string_t property_name() = 0;
  47.     /// Returns a human-readable lable for the property, which should be localized for display in UI code
  48.     virtual const string_t property_label() = 0;
  49.     /// Returns a human-readable "one-liner" description of the property, which should be localized for display in the UI (e.g. as a tooltip)
  50.     virtual const string_t property_description() = 0;
  51.     /// Returns the property type
  52.     virtual const std::type_info& property_type() = 0;
  53.     /// Returns the value stored internally by the property.  Note that most code that uses properties should retrieve the pipeline value instead.
  54.     virtual const boost::any property_internal_value() = 0;
  55.     /// Returns the property value, accounting for any connections in the pipeline.  The result may-or-may-not be the same as the internal value.
  56.     virtual const boost::any property_pipeline_value() = 0;
  57.     /// Returns a reference to the object that owns the property (if any)
  58.     virtual inode* property_node() = 0;
  59.     /// Defines a signal that will be emitted if the property value changes.  The signal includes a pointer to an optional "hint" object that may provide additional information about what changed.
  60.     typedef sigc::signal<void, ihint*> changed_signal_t;
  61.     virtual changed_signal_t& property_changed_signal() = 0;
  62.     /// Defines a signal that will be emitted when the property is destroyed
  63.     typedef sigc::signal<void> deleted_signal_t;
  64.     virtual deleted_signal_t& property_deleted_signal() = 0;
  65.  
  66.     /// Returns this property's pipeline dependency, if any.  Note: there may be dependency cycles, don't use this to perform lookups directly, use k3d::property_lookup() instead
  67.     virtual iproperty* property_dependency() = 0;
  68.     /// Sets this property's pipeline dependency.  Note: never call this directly, use a k3d::pipeline object to manage pipeline dependencies
  69.     virtual void property_set_dependency(iproperty*) = 0;
  70.  
  71. protected:
  72.     iproperty() {}
  73.     iproperty(const iproperty&) {}
  74.     iproperty& operator = (const iproperty&) { return *this; }
  75. };
  76.  
  77. } // namespace k3d
  78.  
  79. #endif // !K3DSDK_IPROPERTY_H
  80.  
  81.