source: ThirdParty/mpqc_open/src/lib/util/state/state.cc@ 00f983

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 00f983 was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 4.2 KB
Line 
1//
2// state.cc
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifdef __GNUC__
29#pragma implementation
30#endif
31
32#include <stdlib.h>
33#include <sys/time.h>
34#include <unistd.h>
35
36#include <util/misc/formio.h>
37#include <util/class/class.h>
38#include <util/state/state.h>
39#include <util/state/stateio.h>
40
41using namespace std;
42using namespace sc;
43
44#define DEBUG 0
45
46/////////////////////////////////////////////////////////////////
47
48static ClassDesc SavableState_cd(
49 typeid(SavableState),"SavableState",1,"public DescribedClass");
50
51SavableState::SavableState()
52{
53}
54
55SavableState::SavableState(const SavableState&)
56{
57}
58
59SavableState& SavableState::operator=(const SavableState&)
60{
61 return *this;
62}
63
64SavableState::SavableState(StateIn&si)
65{
66 // In case si is looking for the next pointer, let it know i
67 // have one.
68 reference();
69 Ref<SavableState> th(this);
70 si.haveobject(th);
71 th = 0;
72 dereference();
73
74 // The following gets the version of this class and all of the
75 // parent classes. This is only needed for restoring objects
76 // that were saved with save_object_state and don't necessarily
77 // have all of their version information already restored.
78 if (si.need_classdesc()) {
79 const ClassDesc* tcd;
80 si.get(&tcd);
81 }
82}
83
84SavableState::~SavableState()
85{
86}
87
88void
89SavableState::save_state(StateOut&so)
90{
91 save_state(this,so);
92}
93
94void
95SavableState::save_state(SavableState*th,StateOut&so)
96{
97 so.putobject(th);
98}
99
100SavableState*
101SavableState::restore_state(StateIn& si)
102{
103 return dir_restore_state(si,0,0);
104}
105
106SavableState*
107SavableState::key_restore_state(StateIn& si,
108 const char *keyword)
109{
110 return dir_restore_state(si,0,keyword);
111}
112
113SavableState*
114SavableState::dir_restore_state(StateIn&si, const char *objectname,
115 const char *keyword)
116{
117 Ref<KeyVal> old_override;
118 Ref<SavableState> overriding_value;
119 int p = si.push_key(keyword);
120 const int can_override_objects = 0;
121 if (can_override_objects && keyword && si.override().nonnull()) {
122 overriding_value << si.override()->describedclassvalue(si.key());
123 old_override = si.override();
124 if (overriding_value.nonnull()) {
125 si.set_override(0);
126 }
127 }
128 // restore the pointer
129 Ref<SavableState> ss;
130 if (objectname) si.dir_getobject(ss, objectname);
131 else si.getobject(ss);
132 if (overriding_value.nonnull()) {
133 ExEnv::out0() << indent
134 << "overriding \"" << si.key() << "\": object of type ";
135 if (ss.null()) ExEnv::out0() << "(null)";
136 else ExEnv::out0() << ss->class_name();
137 ExEnv::out0() << " -> object of type "
138 << overriding_value->class_name()
139 << endl;
140 ss = overriding_value;
141 }
142 SavableState *ret = ss.pointer();
143 if (ret) {
144 ret->reference();
145 ss = 0;
146 ret->dereference();
147 }
148 if (old_override.nonnull()) {
149 si.set_override(old_override);
150 }
151 si.pop_key(p);
152 return ret;
153}
154
155void
156SavableState::save_object_state(StateOut&so)
157{
158 save_vbase_state(so);
159 save_data_state(so);
160}
161
162void
163SavableState::save_vbase_state(StateOut&so)
164{
165 SavableState::save_data_state(so);
166}
167void
168SavableState::save_data_state(StateOut& so)
169{
170 if (so.need_classdesc()) so.put(class_desc());
171}
172
173/////////////////////////////////////////////////////////////////////////////
174
175// Local Variables:
176// mode: c++
177// c-file-style: "CLJ"
178// End:
Note: See TracBrowser for help on using the repository browser.