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

  1. #ifndef K3DSDK_INODE_H
  2. #define K3DSDK_INODE_H
  3.  
  4. // K-3D
  5. // Copyright (c) 1995-2005, 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.         \brief Declares inode, an abstract interface which MUST be implemented by ALL document nodes
  25.         \author Tim Shead (tshead@k-3d.com)
  26. */
  27.  
  28. #include "almost_equal.h"
  29. #include "iunknown.h"
  30. #include "signal_system.h"
  31.  
  32. #include <string>
  33.  
  34. namespace k3d
  35. {
  36.  
  37. class idocument;
  38. class iplugin_factory;
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // inode
  42.  
  43. /// Abstract interface which MUST be implemented by ALL document nodes
  44. class inode :
  45.     public virtual iunknown
  46. {
  47. public:
  48.     virtual ~inode() {}
  49.  
  50.     /// Sets the node name (could fail or be overridden)
  51.     virtual void set_name(const std::string Name) = 0;
  52.     /// Returns the node name
  53.     virtual const std::string name() = 0;
  54.  
  55.     /// Returns a reference to the factory that created this node
  56.     virtual iplugin_factory& factory() = 0;
  57.     /// Returns a reference to the document that owns this node
  58.     virtual idocument& document() = 0;
  59.  
  60.     /// Defines a signal that will be emitted iff the node is deleted
  61.     typedef sigc::signal<void> deleted_signal_t;
  62.     virtual deleted_signal_t& deleted_signal() = 0;
  63.  
  64.     /// Defines a signal that will be emitted if the node name changes (including via undo / redo)
  65.     typedef sigc::signal<void> name_changed_signal_t;
  66.     virtual name_changed_signal_t& name_changed_signal() = 0;
  67.  
  68. protected:
  69.     inode() {}
  70.     inode(const inode&) {}
  71.     inode& operator=(const inode&) { return *this; }
  72. };
  73.  
  74. /// Specialization of almost_equal that tests inode pointers for equality
  75. template<>
  76. class almost_equal<inode*>
  77. {
  78. public:
  79.     almost_equal(const boost::uint64_t) { } 
  80.     inline const bool operator()(inode* const A, inode* const B) const { return A == B; }
  81. };
  82.  
  83. } // namespace k3d
  84.  
  85. #endif // !K3DSDK_INODE_H
  86.  
  87.