Polaris: Relinkable.h Source File

Relinkable.h

Go to the documentation of this file.
00001 ///
00002 ///
00003 #ifndef _RELINKABLE_H
00004 #define _RELINKABLE_H
00005 ///
00006 #ifdef POLARIS_GNU_PRAGMAS
00007 #pragma interface
00008 #endif
00009 ///
00010 #include "ClassNames.h"
00011 #include "Listable.h"
00012 #include "Collection/List.h"
00013 ///
00014 class ProgramUnit;
00015 
00016 class Relinkable : public Listable {
00017  public:
00018   inline   Relinkable();
00019   virtual ~Relinkable();
00020 
00021   virtual void relink_lptrs( ProgramUnit &p) = 0;
00022 };
00023 
00024 template <class T>
00025 inline
00026 void
00027 relink_all_lptrs(List<T> &list, ProgramUnit &p);
00028 ///< Make sure that all pointers encountered in the elements of a 
00029 ///< Dictionary are pointing into the given ProgramUnit.
00030 ///< T here must be derived from Relinkable.
00031 
00032 
00033 ///< implementation
00034 
00035 inline 
00036 Relinkable::Relinkable()
00037 {
00038     #ifdef CLASS_INSTANCE_REGISTRY
00039     register_instance(RELINKABLE, sizeof(Relinkable), this);
00040     #endif
00041 }
00042 
00043 template <class T>
00044 inline
00045 void 
00046 relink_all_lptrs(List<T> &list, ProgramUnit &p)
00047 {
00048   Iterator<T> iter = list;
00049  
00050   while (!iter.end()) {
00051     iter.current().relink_lptrs(p);
00052     ++iter;
00053   }
00054 }
00055 
00056 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:06:06 2005