<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>MPQC: class.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.9 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> <h1>class.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span> <a name="l00002"></a>00002 <span class="comment">// class.h</span> <a name="l00003"></a>00003 <span class="comment">//</span> <a name="l00004"></a>00004 <span class="comment">// Copyright (C) 1996 Limit Point Systems, Inc.</span> <a name="l00005"></a>00005 <span class="comment">//</span> <a name="l00006"></a>00006 <span class="comment">// Author: Curtis Janssen <cljanss@limitpt.com></span> <a name="l00007"></a>00007 <span class="comment">// Maintainer: LPS</span> <a name="l00008"></a>00008 <span class="comment">//</span> <a name="l00009"></a>00009 <span class="comment">// This file is part of the SC Toolkit.</span> <a name="l00010"></a>00010 <span class="comment">//</span> <a name="l00011"></a>00011 <span class="comment">// The SC Toolkit is free software; you can redistribute it and/or modify</span> <a name="l00012"></a>00012 <span class="comment">// it under the terms of the GNU Library General Public License as published by</span> <a name="l00013"></a>00013 <span class="comment">// the Free Software Foundation; either version 2, or (at your option)</span> <a name="l00014"></a>00014 <span class="comment">// any later version.</span> <a name="l00015"></a>00015 <span class="comment">//</span> <a name="l00016"></a>00016 <span class="comment">// The SC Toolkit is distributed in the hope that it will be useful,</span> <a name="l00017"></a>00017 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00018"></a>00018 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00019"></a>00019 <span class="comment">// GNU Library General Public License for more details.</span> <a name="l00020"></a>00020 <span class="comment">//</span> <a name="l00021"></a>00021 <span class="comment">// You should have received a copy of the GNU Library General Public License</span> <a name="l00022"></a>00022 <span class="comment">// along with the SC Toolkit; see the file COPYING.LIB. If not, write to</span> <a name="l00023"></a>00023 <span class="comment">// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00024"></a>00024 <span class="comment">//</span> <a name="l00025"></a>00025 <span class="comment">// The U.S. Government is granted a limited license as per AL 91-7.</span> <a name="l00026"></a>00026 <span class="comment">//</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="preprocessor">#ifdef __GNUG__</span> <a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#pragma interface</span> <a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00031"></a>00031 <span class="preprocessor"></span> <a name="l00032"></a>00032 <span class="preprocessor">#ifndef _util_class_class_h</span> <a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define _util_class_class_h</span> <a name="l00034"></a>00034 <span class="preprocessor"></span> <a name="l00035"></a>00035 <span class="preprocessor">#include <map></span> <a name="l00036"></a>00036 <span class="preprocessor">#include <set></span> <a name="l00037"></a>00037 <span class="preprocessor">#include <string></span> <a name="l00038"></a>00038 <a name="l00039"></a>00039 <span class="preprocessor">#include <stdio.h></span> <a name="l00040"></a>00040 <span class="preprocessor">#include <string.h></span> <a name="l00041"></a>00041 <span class="preprocessor">#include <stdarg.h></span> <a name="l00042"></a>00042 <span class="preprocessor">#include <iostream></span> <a name="l00043"></a>00043 <span class="preprocessor">#include <iomanip></span> <a name="l00044"></a>00044 <span class="preprocessor">#include <typeinfo></span> <a name="l00045"></a>00045 <span class="preprocessor">#include <util/ref/ref.h></span> <a name="l00046"></a>00046 <span class="preprocessor">#include <util/misc/exenv.h></span> <a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="keyword">namespace </span>sc { <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keyword">template</span> <<span class="keyword">class</span> T, <span class="keyword">class</span> C> <a name="l00051"></a>00051 <span class="keyword">class </span>DescribedMemberDatum { <a name="l00052"></a>00052 <span class="keyword">private</span>: <a name="l00053"></a>00053 T C::*member_; <a name="l00054"></a>00054 <span class="keyword">public</span>: <a name="l00055"></a>00055 DescribedMemberDatum(T C::*member): member_(member) {} <a name="l00056"></a>00056 <span class="comment">//T &member(C *c) { return c->*member_; }</span> <a name="l00057"></a>00057 }; <a name="l00058"></a>00058 <a name="l00059"></a>00059 <span class="keyword">class </span>DescribedClass; <a name="l00060"></a>00060 <span class="keyword">class </span>ClassDesc; <a name="l00061"></a>00061 <span class="keyword">typedef</span> ClassDesc* ClassDescP; <a name="l00062"></a>00062 <span class="keyword">typedef</span> <span class="keyword">const</span> ClassDesc* CClassDescP; <a name="l00063"></a>00063 <a name="l00064"></a>00064 <span class="keyword">class </span>ClassDesc; <a name="l00065"></a>00065 <a name="l00067"></a><a class="code" href="classsc_1_1ParentClass.html">00067</a> <span class="keyword">class </span><a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a> <a name="l00068"></a>00068 { <a name="l00069"></a>00069 <span class="keyword">public</span>: <a name="l00070"></a>00070 <span class="keyword">enum</span> Access { Private, Protected, Public }; <a name="l00071"></a>00071 <span class="keyword">private</span>: <a name="l00072"></a>00072 Access _access; <a name="l00073"></a>00073 <span class="keywordtype">int</span> _is_virtual; <a name="l00074"></a>00074 <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>* _classdesc; <a name="l00075"></a>00075 <span class="keyword">public</span>: <a name="l00076"></a>00076 <a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>(<a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>*,Access access = Private,<span class="keywordtype">int</span> is_virtual = 0); <a name="l00077"></a>00077 <a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>&); <a name="l00078"></a>00078 ~<a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>(); <a name="l00079"></a>00079 <span class="keywordtype">int</span> is_virtual() <span class="keyword">const</span>; <a name="l00080"></a>00080 Access access()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _access; } <a name="l00081"></a>00081 <span class="keyword">const</span> <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>* classdesc() <span class="keyword">const</span>; <a name="l00082"></a>00082 <span class="keywordtype">void</span> change_classdesc(<a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>*n); <a name="l00083"></a>00083 }; <a name="l00084"></a>00084 <a name="l00086"></a><a class="code" href="classsc_1_1ParentClasses.html">00086</a> <span class="keyword">class </span><a class="code" href="classsc_1_1ParentClasses.html" title="Gives a list of parent classes of a class.">ParentClasses</a> <a name="l00087"></a>00087 { <a name="l00088"></a>00088 <span class="keyword">private</span>: <a name="l00089"></a>00089 <span class="keywordtype">int</span> _n; <a name="l00090"></a>00090 <a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>** _classes; <a name="l00091"></a>00091 <span class="keywordtype">void</span> add(<a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>*); <a name="l00092"></a>00092 <span class="comment">// do not allow copy constructor or assignment</span> <a name="l00093"></a>00093 <a class="code" href="classsc_1_1ParentClasses.html" title="Gives a list of parent classes of a class.">ParentClasses</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1ParentClasses.html" title="Gives a list of parent classes of a class.">ParentClasses</a>&); <a name="l00094"></a>00094 <span class="keywordtype">void</span> operator=(<span class="keyword">const</span> <a class="code" href="classsc_1_1ParentClasses.html" title="Gives a list of parent classes of a class.">ParentClasses</a>&); <a name="l00095"></a>00095 <span class="keyword">public</span>: <a name="l00096"></a>00096 <a class="code" href="classsc_1_1ParentClasses.html" title="Gives a list of parent classes of a class.">ParentClasses</a>(); <a name="l00097"></a>00097 <span class="keywordtype">void</span> init(<span class="keyword">const</span> <span class="keywordtype">char</span>*); <a name="l00098"></a>00098 ~<a class="code" href="classsc_1_1ParentClasses.html" title="Gives a list of parent classes of a class.">ParentClasses</a>(); <a name="l00099"></a>00099 <a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>& parent(<span class="keywordtype">int</span> i) { <span class="keywordflow">return</span> *_classes[i]; } <a name="l00100"></a>00100 <span class="keyword">const</span> <a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>& parent(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *_classes[i]; } <a name="l00101"></a>00101 <a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>& operator[](<span class="keywordtype">int</span> i) { <span class="keywordflow">return</span> *_classes[i]; } <a name="l00102"></a>00102 <span class="keyword">const</span> <a class="code" href="classsc_1_1ParentClass.html" title="Gives one parent class of a class.">ParentClass</a>& operator[](<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *_classes[i]; } <a name="l00103"></a>00103 <span class="keywordtype">int</span> n()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _n; } <a name="l00104"></a>00104 <span class="keywordtype">void</span> change_parent(<a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>*oldcd,<a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>*newcd); <a name="l00105"></a>00105 }; <a name="l00106"></a>00106 <a name="l00107"></a>00107 <a name="l00108"></a>00108 <span class="keyword">class </span><a class="code" href="classsc_1_1KeyVal.html" title="The KeyVal class is designed to simplify the process of allowing a user to specify...">KeyVal</a>; <a name="l00109"></a>00109 <span class="keyword">class </span><a class="code" href="classsc_1_1StateIn.html" title="Restores objects that derive from SavableState.">StateIn</a>; <a name="l00110"></a>00110 <a name="l00113"></a>00113 <span class="keyword">template</span> <<span class="keyword">class</span> T> <a name="l00114"></a>00114 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* create() <a name="l00115"></a>00115 { <a name="l00116"></a>00116 <span class="keywordflow">return</span> <span class="keyword">new</span> T; <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <a name="l00121"></a>00121 <span class="keyword">template</span> <<span class="keyword">class</span> T> <a name="l00122"></a>00122 DescribedClass* create(<span class="keyword">const</span> Ref<KeyVal>& keyval) <a name="l00123"></a>00123 { <a name="l00124"></a>00124 <span class="keywordflow">return</span> <span class="keyword">new</span> T(keyval); <a name="l00125"></a>00125 } <a name="l00126"></a>00126 <a name="l00129"></a>00129 <span class="keyword">template</span> <<span class="keyword">class</span> T> <a name="l00130"></a>00130 DescribedClass* create(StateIn& statein) <a name="l00131"></a>00131 { <a name="l00132"></a>00132 <span class="keywordflow">return</span> <span class="keyword">new</span> T(statein); <a name="l00133"></a>00133 } <a name="l00134"></a>00134 <a name="l00135"></a>00135 <span class="keyword">class </span>type_info_key { <a name="l00136"></a>00136 <span class="keyword">private</span>: <a name="l00137"></a>00137 <span class="keyword">const</span> std::type_info *ti_; <a name="l00138"></a>00138 <span class="keyword">public</span>: <a name="l00139"></a>00139 type_info_key(): ti_(0) {} <a name="l00140"></a>00140 type_info_key(<span class="keyword">const</span> std::type_info *ti): ti_(ti) {} <a name="l00141"></a>00141 type_info_key& operator=(<span class="keyword">const</span> type_info_key&); <a name="l00142"></a>00142 <span class="keywordtype">int</span> operator==(<span class="keyword">const</span> type_info_key&) <span class="keyword">const</span>; <a name="l00143"></a>00143 <span class="keywordtype">int</span> operator<(<span class="keyword">const</span> type_info_key&) <span class="keyword">const</span>; <a name="l00144"></a>00144 <span class="keywordtype">int</span> cmp(<span class="keyword">const</span> type_info_key&) <span class="keyword">const</span>; <a name="l00145"></a>00145 }; <a name="l00146"></a>00146 <a name="l00158"></a><a class="code" href="classsc_1_1ClassDesc.html">00158</a> <span class="keyword">class </span><a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>: <span class="keyword">public</span> <a class="code" href="classsc_1_1Identity.html" title="Identity gives objects a unique identity and ordering relationship relative to all...">Identity</a> { <a name="l00159"></a>00159 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classsc_1_1ParentClasses.html" title="Gives a list of parent classes of a class.">ParentClasses</a>; <a name="l00160"></a>00160 <span class="keyword">private</span>: <a name="l00161"></a>00161 <span class="keyword">static</span> std::map<std::string,ClassDescP> *all_; <a name="l00162"></a>00162 <span class="keyword">static</span> std::map<type_info_key,ClassDescP> *type_info_all_; <a name="l00163"></a>00163 <span class="keyword">static</span> <span class="keywordtype">char</span> * classlib_search_path_; <a name="l00164"></a>00164 <span class="keyword">static</span> std::set<std::string> *unresolved_parents_; <a name="l00165"></a>00165 <a name="l00166"></a>00166 <span class="keywordtype">char</span>* classname_; <a name="l00167"></a>00167 <span class="keywordtype">int</span> version_; <a name="l00168"></a>00168 <a class="code" href="classsc_1_1ParentClasses.html" title="Gives a list of parent classes of a class.">ParentClasses</a> parents_; <a name="l00169"></a>00169 std::set<std::string> *children_; <a name="l00170"></a>00170 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* (*ctor_)(); <a name="l00171"></a>00171 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* (*keyvalctor_)(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref<KeyVal></a>&); <a name="l00172"></a>00172 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* (*stateinctor_)(<a class="code" href="classsc_1_1StateIn.html" title="Restores objects that derive from SavableState.">StateIn</a>&); <a name="l00173"></a>00173 <span class="keyword">const</span> std::type_info *ti_; <a name="l00174"></a>00174 <a name="l00175"></a>00175 <span class="keywordtype">void</span> change_parent(<a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>*oldcd,<a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>*newcd); <a name="l00176"></a>00176 <a name="l00177"></a>00177 <span class="comment">// do not allow copy constructor or assignment</span> <a name="l00178"></a>00178 <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>&); <a name="l00179"></a>00179 <span class="keywordtype">void</span> operator=(<span class="keyword">const</span> <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>&); <a name="l00180"></a>00180 <a name="l00181"></a>00181 <span class="comment">// this is used for temporary parent class descriptors</span> <a name="l00182"></a>00182 <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>*); <a name="l00183"></a>00183 <span class="keywordtype">void</span> init(<span class="keyword">const</span> <span class="keywordtype">char</span>*,<span class="keywordtype">int</span>=1,<span class="keyword">const</span> <span class="keywordtype">char</span>* p=0, <a name="l00184"></a>00184 <span class="keyword">const</span> std::type_info *ti=0, <a name="l00185"></a>00185 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* (*ctor)()=0, <a name="l00186"></a>00186 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* (*keyvalctor)(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref<KeyVal></a>&)=0, <a name="l00187"></a>00187 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* (*stateinctor)(<a class="code" href="classsc_1_1StateIn.html" title="Restores objects that derive from SavableState.">StateIn</a>&)=0); <a name="l00188"></a>00188 <span class="keyword">public</span>: <a name="l00189"></a>00189 <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>(<span class="keyword">const</span> std::type_info&, <span class="keyword">const</span> <span class="keywordtype">char</span>*,<span class="keywordtype">int</span>=1,<span class="keyword">const</span> <span class="keywordtype">char</span>* p=0, <a name="l00190"></a>00190 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* (*ctor)()=0, <a name="l00191"></a>00191 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* (*keyvalctor)(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref<KeyVal></a>&)=0, <a name="l00192"></a>00192 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* (*stateinctor)(<a class="code" href="classsc_1_1StateIn.html" title="Restores objects that derive from SavableState.">StateIn</a>&)=0); <a name="l00193"></a>00193 ~<a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>(); <a name="l00194"></a>00194 <a name="l00195"></a>00195 <span class="keyword">static</span> std::map<std::string,ClassDescP>& all(); <a name="l00196"></a>00196 <span class="keyword">const</span> <a class="code" href="classsc_1_1ParentClasses.html" title="Gives a list of parent classes of a class.">ParentClasses</a>& parents()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> parents_; } <a name="l00197"></a>00197 <a name="l00199"></a>00199 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1ClassDesc.html#acbc5cd6e23d391fe249f75ec1417f4b" title="Writes a list of all of the classes to ExEnv::out0().">list_all_classes</a>(); <a name="l00202"></a>00202 <span class="keyword">static</span> <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>* <a class="code" href="classsc_1_1ClassDesc.html#a5e74efb179390f71205cd91c42b2c83" title="Given the name of the class, return a pointer to the class descriptor.">name_to_class_desc</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>*); <a name="l00204"></a>00204 <span class="keyword">static</span> <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a> *<a class="code" href="classsc_1_1ClassDesc.html#444e53a2c1199439108464994e73590d" title="Given a type_info object return a pointer to the ClassDesc.">class_desc</a>(<span class="keyword">const</span> std::type_info &); <a name="l00206"></a><a class="code" href="classsc_1_1ClassDesc.html#edb67a508a4cd82fead4ff10651ee1b8">00206</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classsc_1_1ClassDesc.html#edb67a508a4cd82fead4ff10651ee1b8" title="Returns the name of the class.">name</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> classname_; } <a name="l00208"></a><a class="code" href="classsc_1_1ClassDesc.html#ba9518960cb1ff115a1660b63d5e72ac">00208</a> <span class="keywordtype">int</span> <a class="code" href="classsc_1_1ClassDesc.html#ba9518960cb1ff115a1660b63d5e72ac" title="Returns the version number of the class.">version</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> version_; } <a name="l00210"></a>00210 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* <a class="code" href="classsc_1_1ClassDesc.html#10968217f7494235df5ea2ee363798a5" title="This member has been replaced by create().">create_described_class</a>() <span class="keyword">const</span>; <a name="l00218"></a>00218 <span class="keyword">virtual</span> <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* <a class="code" href="classsc_1_1ClassDesc.html#a8e1c3ca9c99ba328d91005e902a25d5" title="Create an instance of DescribedClass with exact type equal to the class to which...">create</a>() <span class="keyword">const</span>; <a name="l00224"></a>00224 <span class="keyword">virtual</span> <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* <a class="code" href="classsc_1_1ClassDesc.html#a8e1c3ca9c99ba328d91005e902a25d5" title="Create an instance of DescribedClass with exact type equal to the class to which...">create</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref<KeyVal></a>&) <span class="keyword">const</span>; <a name="l00230"></a>00230 <span class="keyword">virtual</span> <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>* <a class="code" href="classsc_1_1ClassDesc.html#a8e1c3ca9c99ba328d91005e902a25d5" title="Create an instance of DescribedClass with exact type equal to the class to which...">create</a>(<a class="code" href="classsc_1_1StateIn.html" title="Restores objects that derive from SavableState.">StateIn</a>&) <span class="keyword">const</span>; <a name="l00231"></a>00231 <a name="l00234"></a>00234 <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classsc_1_1ClassDesc.html#27ba4aa6d6c1745021528e0f1a9430a6" title="Attempt to dynamically load the shared object file for classname.">load_class</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* classname); <a name="l00235"></a>00235 }; <a name="l00236"></a>00236 <a name="l00244"></a><a class="code" href="classsc_1_1DescribedClass.html">00244</a> <span class="keyword">class </span><a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a> : <span class="keyword">public</span> <a class="code" href="classsc_1_1RefCount.html" title="The base class for all reference counted objects.">RefCount</a> { <a name="l00245"></a>00245 <span class="keyword">public</span>: <a name="l00246"></a>00246 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>(); <a name="l00247"></a>00247 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>&); <a name="l00248"></a>00248 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>& operator=(<span class="keyword">const</span> <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>&); <a name="l00249"></a>00249 <span class="keyword">virtual</span> ~<a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a>(); <a name="l00252"></a>00252 <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a>* <a class="code" href="classsc_1_1DescribedClass.html#543db7ca087135f8bd28776c2801f930" title="This returns the unique pointer to the ClassDesc corresponding to the given type_info...">class_desc</a>() <span class="keyword">const</span> <span class="keywordflow">throw</span>(); <a name="l00254"></a>00254 <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classsc_1_1DescribedClass.html#4c3305b01115fbfd560a4dc397d4842c" title="Return the name of the object&#39;s exact type.">class_name</a>() <span class="keyword">const</span>; <a name="l00256"></a>00256 <span class="keywordtype">int</span> <a class="code" href="classsc_1_1DescribedClass.html#05088e3cd127293ac1c5f61e507c34f9" title="Return the version of the class.">class_version</a>() <span class="keyword">const</span>; <a name="l00258"></a>00258 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1DescribedClass.html#0d2e580b61452fb906f27ed972ea3800" title="Print the object.">print</a>(std::ostream& = <a class="code" href="classsc_1_1ExEnv.html#360216acd1f990e999c0ed46cb350b1f" title="Return an ostream that writes from node 0.">ExEnv::out0</a>()) <span class="keyword">const</span>; <a name="l00259"></a>00259 }; <a name="l00260"></a>00260 <a name="l00262"></a>00262 <span class="keyword">template</span> <<span class="keyword">class</span> T> <a name="l00263"></a>00263 <span class="keyword">inline</span> <a class="code" href="classsc_1_1ClassDesc.html" title="This class is used to contain information about classes.">ClassDesc</a> * <a name="l00264"></a>00264 class_desc() <a name="l00265"></a>00265 { <a name="l00266"></a>00266 <span class="keywordflow">return</span> <a class="code" href="classsc_1_1ClassDesc.html#444e53a2c1199439108464994e73590d" title="Given a type_info object return a pointer to the ClassDesc.">ClassDesc::class_desc</a>(<span class="keyword">typeid</span>(T)); <a name="l00267"></a>00267 } <a name="l00268"></a>00268 <a name="l00271"></a>00271 <span class="keyword">inline</span> ClassDesc * <a name="l00272"></a>00272 class_desc(DescribedClass *d) <a name="l00273"></a>00273 { <a name="l00274"></a>00274 <span class="keywordflow">return</span> <a class="code" href="classsc_1_1ClassDesc.html#444e53a2c1199439108464994e73590d" title="Given a type_info object return a pointer to the ClassDesc.">ClassDesc::class_desc</a>(<span class="keyword">typeid</span>(*d)); <a name="l00275"></a>00275 } <a name="l00276"></a>00276 <a name="l00279"></a>00279 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00280"></a>00280 <span class="keyword">inline</span> T <a name="l00281"></a>00281 require_dynamic_cast(DescribedClass*p,<span class="keyword">const</span> <span class="keywordtype">char</span> * errmsg,...) <a name="l00282"></a>00282 { <a name="l00283"></a>00283 T t = <span class="keyword">dynamic_cast<</span>T<span class="keyword">></span>(p); <a name="l00284"></a>00284 <span class="keywordflow">if</span> (p && !t) { <a name="l00285"></a>00285 va_list args; <a name="l00286"></a>00286 va_start(args,errmsg); <a name="l00287"></a>00287 fprintf(stderr,<span class="stringliteral">"A required dynamic_cast failed in: "</span>); <a name="l00288"></a>00288 vfprintf(stderr,errmsg,args); <a name="l00289"></a>00289 fprintf(stderr,<span class="stringliteral">"\nwanted type \"%s\" but got \"%s\"\n"</span>, <a name="l00290"></a>00290 <span class="keyword">typeid</span>(T).name(),p->class_desc()->name()); <a name="l00291"></a>00291 fflush(stderr); <a name="l00292"></a>00292 va_end(args); <a name="l00293"></a>00293 abort(); <a name="l00294"></a>00294 } <a name="l00295"></a>00295 <span class="keywordflow">return</span> t; <a name="l00296"></a>00296 } <a name="l00297"></a>00297 <a name="l00300"></a>00300 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00301"></a>00301 <span class="keyword">inline</span> T <a name="l00302"></a>00302 require_dynamic_cast(<span class="keyword">const</span> DescribedClass*p,<span class="keyword">const</span> <span class="keywordtype">char</span> * errmsg,...) <a name="l00303"></a>00303 { <a name="l00304"></a>00304 T t = <span class="keyword">dynamic_cast<</span>T<span class="keyword">></span>(p); <a name="l00305"></a>00305 <span class="keywordflow">if</span> (p && !t) { <a name="l00306"></a>00306 va_list args; <a name="l00307"></a>00307 va_start(args,errmsg); <a name="l00308"></a>00308 fprintf(stderr,<span class="stringliteral">"A required dynamic_cast failed in: "</span>); <a name="l00309"></a>00309 vfprintf(stderr,errmsg,args); <a name="l00310"></a>00310 fprintf(stderr,<span class="stringliteral">"\nwanted type \"%s\" but got \"%s\"\n"</span>, <a name="l00311"></a>00311 <span class="keyword">typeid</span>(T).name(),p->class_desc()->name()); <a name="l00312"></a>00312 fflush(stderr); <a name="l00313"></a>00313 va_end(args); <a name="l00314"></a>00314 abort(); <a name="l00315"></a>00315 } <a name="l00316"></a>00316 <span class="keywordflow">return</span> t; <a name="l00317"></a>00317 } <a name="l00318"></a>00318 <a name="l00321"></a>00321 <span class="keyword">template</span> <<span class="keyword">class</span> A> <a name="l00322"></a><a class="code" href="classsc_1_1ForceLinkBase.html">00322</a> <span class="keyword">class </span><a class="code" href="classsc_1_1ForceLinkBase.html" title="This, together with ForceLink, is used to force code for particular classes to be...">ForceLinkBase</a> { <a name="l00323"></a>00323 <span class="keyword">public</span>: <a name="l00324"></a>00324 <a class="code" href="classsc_1_1ForceLinkBase.html" title="This, together with ForceLink, is used to force code for particular classes to be...">ForceLinkBase</a>() {}; <a name="l00325"></a>00325 <span class="keyword">virtual</span> ~<a class="code" href="classsc_1_1ForceLinkBase.html" title="This, together with ForceLink, is used to force code for particular classes to be...">ForceLinkBase</a>() {}; <a name="l00326"></a>00326 <span class="keyword">virtual</span> <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a> *create(A) = 0; <a name="l00327"></a>00327 }; <a name="l00328"></a>00328 <a name="l00338"></a>00338 <span class="keyword">template</span> <<span class="keyword">class</span> T, <span class="keyword">class</span> A = const Ref<KeyVal> &> <a name="l00339"></a><a class="code" href="classsc_1_1ForceLink.html">00339</a> <span class="keyword">class </span><a class="code" href="classsc_1_1ForceLink.html" title="This, together with ForceLinkBase, is used to force code for particular classes to...">ForceLink</a>: <span class="keyword">public</span> <a class="code" href="classsc_1_1ForceLinkBase.html" title="This, together with ForceLink, is used to force code for particular classes to be...">ForceLinkBase</a><A> { <a name="l00340"></a>00340 <span class="keyword">public</span>: <a name="l00341"></a>00341 <a class="code" href="classsc_1_1ForceLink.html" title="This, together with ForceLinkBase, is used to force code for particular classes to...">ForceLink</a>() {}; <a name="l00342"></a>00342 <span class="keyword">virtual</span> ~<a class="code" href="classsc_1_1ForceLink.html" title="This, together with ForceLinkBase, is used to force code for particular classes to...">ForceLink</a>() {}; <a name="l00343"></a>00343 <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a> *create(A a) { <span class="keywordflow">return</span> <span class="keyword">new</span> T(a); } <a name="l00344"></a>00344 }; <a name="l00345"></a>00345 <a name="l00346"></a>00346 } <a name="l00347"></a>00347 <a name="l00348"></a>00348 <span class="preprocessor">#endif</span> <a name="l00349"></a>00349 <span class="preprocessor"></span> <a name="l00350"></a>00350 <span class="comment">// Local Variables:</span> <a name="l00351"></a>00351 <span class="comment">// mode: c++</span> <a name="l00352"></a>00352 <span class="comment">// c-file-style: "CLJ"</span> <a name="l00353"></a>00353 <span class="comment">// End:</span> </pre></div></div> <hr> <address> <small> Generated at Wed Oct 14 14:12:09 2009 for <a href="http://www.mpqc.org">MPQC</a> 2.3.1 using the documentation package <a href="http://www.doxygen.org">Doxygen</a> 1.5.9. </small> </address> </body> </html>