1
// This file is part of the AspectC++ compiler 'ac++'.
2
// Copyright (C) 1999-2003 The 'ac++' developers (see aspectc.org)
4
// This program is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU General Public License as
6
// published by the Free Software Foundation; either version 2 of
7
// the License, or (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public
15
// License along with this program; if not, write to the Free
16
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19
#ifndef __join_point_model_element_h__
20
#define __join_point_model_element_h__
29
using std::istringstream;
31
typedef vector<class JoinPointModelElement *> IdElementMap;
33
// The base class of all join point model elements
35
class JoinPointModelElement {
36
// needed for reconciling the translation unit model with the project model
38
mutable JoinPointModelElement *_partner;
40
/// a unique id for each joinpoint location
43
/// map needed to locate model elements based on their ID
46
/// assigned JPID for code generation
50
JoinPointModelElement () : _ref (false), _partner (0), _id (-1), _map (0),
52
JoinPointModelElement (const JoinPointModelElement ©) :
53
_ref (false), _partner (0), _id (-1), _map (0), _assigned_id (-1) {}
54
void assigned_id (int id) { _assigned_id = id; }
55
int assigned_id () const { return _assigned_id; }
56
bool is_ref () const { return _ref; }
57
void ref (bool r = true) const { _ref = r; }
58
JoinPointModelElement *partner () const { return _partner; }
59
void partner (JoinPointModelElement *p) const { _partner = p; }
60
int id () const { return _id; }
61
void id (int new_id) {
63
cout << "element without map" << endl;
71
while ((unsigned)new_id >= _map->size ())
73
(*_map)[new_id] = this;
77
IdElementMap *map () const { return _map; }
78
JoinPointModelElement *map (int id) const { return (*_map)[id]; }
79
void map (IdElementMap *map) { _map = map; }
82
// container for element IDs
84
class IdSet : public set<int> {
85
typedef set<int> _Base;
87
string to_string () const {
91
for (_Base::iterator i = _Base::begin (); i != _Base::end (); ++i) {
92
if (i != _Base::begin ())
98
bool from_string (const string &id_str) {
99
istringstream in (id_str, istringstream::in);
112
#endif // __join_point_model_element_h__