2 Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (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 License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "exceptions.h"
25 #include <boost/shared_ptr.hpp>
38 Ref (boost::shared_ptr<T> object)
43 void set_id (std::string id)
48 void resolve (std::list<boost::shared_ptr<Object> > objects)
50 typename std::list<boost::shared_ptr<Object> >::iterator i = objects.begin();
51 while (i != objects.end() && (*i)->id() != _id) {
55 if (i != objects.end ()) {
56 _object = boost::dynamic_pointer_cast<T> (*i);
60 std::string id () const {
64 boost::shared_ptr<T> object () const {
66 throw UnresolvedRefError (_id);
72 T * operator->() const {
74 throw UnresolvedRefError (_id);
77 return _object.get ();
80 bool resolved () const {
86 boost::shared_ptr<T> _object;