Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpTaggedObject.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2006 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpTaggedObject.hpp 2613 2015-11-04 14:42:02Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9 #ifndef __IPTAGGEDOBJECT_HPP__
10 #define __IPTAGGEDOBJECT_HPP__
11
12 #include "IpUtils.hpp"
13 #include "IpDebug.hpp"
14 #include "IpReferenced.hpp"
15 #include "IpObserver.hpp"
16 #include <limits>
17
18 /* keyword to declare a thread-local variable according to http://en.wikipedia.org/wiki/Thread-local_storage
19 * GCC < 4.5 on MacOS X does not support TLS
20 * With Intel compiler on MacOS X, problems with TLS were reported.
21 */
22 #ifndef IPOPT_THREAD_LOCAL
23
24 #if defined(_MSC_VER)
25 #define IPOPT_THREAD_LOCAL __declspec(thread)
26 #elif defined(__APPLE__) && ((defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 405)) || defined(__INTEL_COMPILER))
27 #define IPOPT_THREAD_LOCAL
28 #else
29 #define IPOPT_THREAD_LOCAL __thread
30 #endif
31
32 #endif
33
34 namespace Ipopt
35 {
36
76 class TaggedObject : public ReferencedObject, public Subject
77 {
78 public:
80 typedef unsigned int Tag;
81
83 TaggedObject()
84 :
85 Subject()
86 {
87 ObjectChanged();
88 }
89
91 virtual ~TaggedObject()
92 {}
93
98 Tag GetTag() const
99 {
100 return tag_;
101 }
102
108 bool HasChanged(const Tag comparison_tag) const
109 {
110 return (comparison_tag == tag_) ? false : true;
111 }
112 protected:
117 void ObjectChanged()
118 {
119 DBG_START_METH("TaggedObject::ObjectChanged()", 0);
120 tag_ = unique_tag_;
121 unique_tag_++;
122 DBG_ASSERT(unique_tag_ < std::numeric_limits<Tag>::max());
123 // The Notify method from the Subject base class notifies all
124 // registered Observers that this subject has changed.
125 Notify(Observer::NT_Changed);
126 }
127 private:
135 TaggedObject(const TaggedObject&);
136
138 void operator=(const TaggedObject&);
140
145 static IPOPT_THREAD_LOCAL Tag unique_tag_;
146
152 Tag tag_;
153
159 Index cache_priority_;
160 };
161 } // namespace Ipopt
162 #endif
IpUtils.hpp
Ipopt::Subject::Notify
void Notify(Observer::NotifyType notify_type) const
Definition: IpObserver.hpp:351
DBG_START_METH
#define DBG_START_METH(__func_name, __verbose_level)
Definition: IpDebug.hpp:49
Ipopt::Observer::NT_Changed
Definition: IpObserver.hpp:63
Ipopt::TaggedObject::operator=
void operator=(const TaggedObject &)
Overloaded Equals Operator.
Ipopt::TaggedObject::ObjectChanged
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
Definition: IpTaggedObject.hpp:117
Ipopt::TaggedObject::TaggedObject
TaggedObject()
Constructor.
Definition: IpTaggedObject.hpp:83
Ipopt::TaggedObject::cache_priority_
Index cache_priority_
The index indicating the cache priority for this TaggedObject.
Definition: IpTaggedObject.hpp:159
Ipopt::Subject
Slight Variation of the Observer Design Pattern (Subject part).
Definition: IpObserver.hpp:129
IpObserver.hpp
Ipopt::TaggedObject
TaggedObject class.
Definition: IpTaggedObject.hpp:76
Ipopt::ReferencedObject
ReferencedObject class.
Definition: IpReferenced.hpp:174
IpDebug.hpp
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
IpReferenced.hpp
DBG_ASSERT
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
Ipopt::TaggedObject::unique_tag_
static IPOPT_THREAD_LOCAL Tag unique_tag_
static data member that is incremented every time ANY TaggedObject changes.
Definition: IpTaggedObject.hpp:145
Ipopt::TaggedObject::Tag
unsigned int Tag
Type for the Tag values.
Definition: IpTaggedObject.hpp:80
Ipopt::TaggedObject::tag_
Tag tag_
The tag indicating the current state of the object.
Definition: IpTaggedObject.hpp:152
Ipopt::TaggedObject::HasChanged
bool HasChanged(const Tag comparison_tag) const
Users of TaggedObjects call this to check if the object HasChanged since they last updated their own ...
Definition: IpTaggedObject.hpp:108
Ipopt::TaggedObject::GetTag
Tag GetTag() const
Users of TaggedObjects call this to update their own internal tags every time they perform the expens...
Definition: IpTaggedObject.hpp:98
IPOPT_THREAD_LOCAL
#define IPOPT_THREAD_LOCAL
Definition: IpTaggedObject.hpp:29
Ipopt::TaggedObject::~TaggedObject
virtual ~TaggedObject()
Destructor.
Definition: IpTaggedObject.hpp:91