Ipopt
3.11.4
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
src
Common
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 2276 2013-05-05 12:33:44Z 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
#include <utility>
// for std::pair
18
19
namespace
Ipopt
20
{
21
61
class
TaggedObject
:
public
ReferencedObject
,
public
Subject
62
{
63
public
:
70
typedef
std::pair<const TaggedObject*, unsigned int>
Tag
;
71
73
TaggedObject
()
74
:
75
Subject
(),
76
/* We can initialize the tag counter to 0, because this objects Tag
77
* will differ from a Tag() object in its first member. */
78
tagcount_
(0)
79
{
80
ObjectChanged
();
81
}
82
84
virtual
~TaggedObject
()
85
{}
86
91
Tag
GetTag
()
const
92
{
93
return
Tag
(
this
,
tagcount_
);
94
}
95
101
bool
HasChanged
(
const
Tag
comparison_tag)
const
102
{
103
return
(comparison_tag.first !=
this
) || (comparison_tag.second !=
tagcount_
);
104
}
105
protected
:
110
void
ObjectChanged
()
111
{
112
DBG_START_METH
(
"TaggedObject::ObjectChanged()"
, 0);
113
tagcount_
++;
114
DBG_ASSERT
(
tagcount_
< std::numeric_limits<Tag::second_type>::max());
115
// The Notify method from the Subject base class notifies all
116
// registered Observers that this subject has changed.
117
Notify
(
Observer::NT_Changed
);
118
}
119
private
:
127
TaggedObject
(
const
TaggedObject
&);
128
130
void
operator=
(
const
TaggedObject
&);
132
138
Tag::second_type
tagcount_
;
139
145
Index
cache_priority_
;
146
};
147
152
inline
153
TaggedObject::Tag
operator+
(
const
TaggedObject::Tag
& tag1,
const
TaggedObject::Tag
& tag2)
154
{
155
return
TaggedObject::Tag
(tag1.first, tag1.second + tag2.second);
156
}
157
158
}
// namespace Ipopt
159
#endif
Generated on Mon Oct 21 2013 19:08:15 for Ipopt by
1.8.4