IpTaggedObject.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2004, 2006 International Business Machines and others.
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: IpTaggedObject.hpp 759 2006-07-07 03:07:08Z andreasw $
00006 //
00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
00008 
00009 #ifndef __IPTAGGEDOBJECT_HPP__
00010 #define __IPTAGGEDOBJECT_HPP__
00011 
00012 #include "IpUtils.hpp"
00013 #include "IpDebug.hpp"
00014 #include "IpReferenced.hpp"
00015 #include "IpObserver.hpp"
00016 #include <limits>
00017 
00018 namespace Ipopt
00019 {
00020 
00063   class TaggedObject : public ReferencedObject, public Subject
00064   {
00065   public:
00067     typedef unsigned int Tag;
00068 
00070     TaggedObject()
00071         :
00072         Subject()
00073     {
00074       ObjectChanged();
00075     }
00076 
00078     virtual ~TaggedObject()
00079     {}
00080 
00085     Tag GetTag() const
00086     {
00087       return tag_;
00088     }
00089 
00095     bool HasChanged(const Tag comparison_tag) const
00096     {
00097       return (comparison_tag == tag_) ? false : true;
00098     }
00099   protected:
00104     void ObjectChanged()
00105     {
00106       DBG_START_METH("TaggedObject::ObjectChanged()", 0);
00107       tag_ = unique_tag_;
00108       unique_tag_++;
00109       DBG_ASSERT(unique_tag_ < std::numeric_limits<Tag>::max());
00110       // The Notify method from the Subject base class notifies all
00111       // registed Observers that this subject has changed.
00112       Notify(Observer::NT_Changed);
00113     }
00114   private:
00122     TaggedObject(const TaggedObject&);
00123 
00125     void operator=(const TaggedObject&);
00127 
00132     static Tag unique_tag_;
00133 
00139     Tag tag_;
00140 
00146     Index cache_priority_;
00147   };
00148 } // namespace Ipopt
00149 #endif

Generated on Fri Sep 26 07:44:13 2008 for SimTKcore by  doxygen 1.5.6