⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 state.dox

📁 大型并行量子化学软件;支持密度泛函(DFT)。可以进行各种量子化学计算。支持CHARMM并行计算。非常具有应用价值。
💻 DOX
字号:
/** \page state The State LibraryThe state library provides means for objects to save and restore theirstate.  Features include:<ul><li>  Pointers to base types can be saved and restored.  The exact types of the saved and restored objects will match.<li>  If the pointer to an object is saved twice, only one copy of the  object is saved.  When these two pointers are restored they will  point to the same object.<li>  Virtual base classes are dealt with in a manner consistent with  the way C++ treats virtual base classes.<li>  The library is portable.  Information about object layout for  particular compiler implementations is not needed.</ul>For objects of a class to be savable with this library the class mustinherit SavableState which in turn inheritsDescribedClass.  SavableState must be inherited with the virtual qualifier.Also, a constructor taking aStateIn& argument and asave_data_state(StateOut&) member must be provided.  Ifthe class has virtual base classes other than SavableState, then asave_vbase_state(StateOut&) member must also beprovided.<ul> <li> \ref stateex <li> \ref stateexin <li> \ref stateexvin <li> \ref stateexvpoint <li> \ref stateexvsmart <li> \ref stateexdata</ul>\section stateex Simple ExampleHere is a simple example of the specification of a client, C,of SavableState:<pre>class C: virtual public SavableState {  private:    int i;  public:    C(StateIn&);    void save_data_state(StateOut&);};</pre>Here is the implementation for the above:<pre>static ClassDesc C_cd(typeid(C),"C",1,"virtual public SavableState",                      0, 0, create<C>);void C::save_data_state(StateOut&so) {  so.put(i);}C::C(StateIn&si): SavableState(si) {  si.get(i);}</pre>\section stateexin Example with InheritanceHere is an example of the specification of C,where C nonvirtually inherits from anotherSavableState derivative:<pre>class C: public B {  private:    int i;  public:    C(StateIn&);    void save_data_state(StateOut&);};</pre>Here is the implementation for the above:<pre>static ClassDesc C_cd(typeid(C),"C",1,"public B",                      0, 0, create<C>);void C::save_data_state(StateOut&so) {  B::save_data_state(so);  so.put(i);}C::C(StateIn&si): SavableState(si), B(si)  {  si.get(i);}</pre>Note that B (or one of its parents) virtually inherits fromSavableState, so the StateIn constructor for SavableState iscalled explicitly from the class C constructor.\section stateexvin Example with Virtual and Nonvirtual InheritanceHere is an example of the specification of C,where C nonvirtually inherits from another client ofSavableState as well as virtually inherits from a clientof SavableState:<pre>class C: public B,         virtual public E {  private:    int i;  public:    C(StateIn&);    void save_vbase_state(StateOut&);    void save_data_state(StateOut&);  };</pre>In this case a save_vbase_state member is required since virtualbase classes besides SavableState exist.  This member functionmust save the virtual base classes in the same order that virtualbase classes are initialized in constructors.  Virtual baseclasses are initialized before all other base classes in a depthfirst, left to right transversal of the directed acyclic graph ofparent classes.  In this example, B and E inherit virtuallyfrom SavableState.  Here is the implementation:<pre>static ClassDesc C_cd(typeid(C),"C",1,"public B, virtual public E",                      0, 0, create<C>);void C::save_vbase_state(StateOut&sio) {  SavableState::save_data_state(so);  E::save_data_state(sio);}void C::save_data_state(StateOut&so) {  B::save_parent_state(so);  so.put(i);}C::C(StateIn&si): SavableState(si), B(si), E(si) {  si.get(i);}</pre>\section stateexpoint Example with Pointers to SavableStatesHere is an example where C has data members which arepointers to derivatives of SavableState:<pre>class C: virtual public SavableState {  private:    A* ap; // A is also a SavableState  public:    C(StateIn&);    void save_data_state(StateOut&);  };</pre>Here is the implementation for the above:<pre>static ClassDesc C_cd(typeid(C),"C",1,"virtual public SavableState",                      0, 0, create<C>);void C::save_data_state(StateOut&so) {  SavableState::save_state(ap,so);}C::C(StateIn&si): SavableState(si) {  ap = dynamic_cast<A>(SavableState::restore_state(si));}</pre>\section stateexsmart Example with Smart Pointers to SavableStatesHere is an example where C has data members which aresmart pointers to derivatives of SavableState:<pre>class C: virtual public SavableState {  private:    Ref<A> a; // A is also a SavableState  public:    C(StateIn&);    void save_data_state(StateOut&);};</pre>Here is the implementation for the above:<pre>static ClassDesc C_cd(typeid(C),"C",1,"virtual public SavableState",                      0, 0, create<C>);void C::save_data_state(StateOut&so) {  SavableState::save_state(a.pointer(),so);}C::C(StateIn&si): SavableState(si) {  a << SavableState::restore_state(so);}</pre>\section stateexdata Example with Pointers to DataHere is an example where C has data members which arepointers to data:<pre>class C: virtual public SavableState {  private:    int vecsize;    double *vec;    int n1;    int n2;    double **array;  public:    C(StateIn&);    void save_data_state(StateOut&);};</pre>Here is the implementation for the above:<pre>static ClassDesc C_cd(typeid(C),"C",1,"virtual public SavableState",                      0, 0, create<C>);void C::save_data_state(StateOut&so) {  so.put(vecsize);  so.put_array_double(vec,vecsize);  so.put(n1);  so.put(n2);  for (int i=0; i<n1; i++) {    so.put_array_double(array[i],n2);  }}C::C(StateIn&si): SavableState(si) {  si.get(vecsize);  vec = new double[vecsize];  si.get_array_double(vec,vecsize);  si.get(n1);  si.get(n2);  array = new double*[n1];  for (int i=0; i<n1; i++) {    array[i] = new double[n2];    si.get_array_double(array[i],n2);  }}</pre>*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -