CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Operations.cc
Go to the documentation of this file.
1 // $Id: Operations.cc,v 1.10.6.1 2011/03/07 11:33:05 mommsen Exp $
3 
6 
7 #include <iostream>
8 
9 #include <boost/statechart/event_base.hpp>
10 
11 #include "xcept/tools.h"
12 
13 using namespace std;
14 using namespace stor;
15 using namespace boost::statechart;
16 
17 Operations::Operations()
18 {
19  //TransitionRecord tr( stateName(), true );
20  //outermost_context().updateHistory( tr );
21 }
22 
23 Operations::~Operations()
24 {
25  //TransitionRecord tr( stateName(), false );
26  //outermost_context().updateHistory( tr );
27 }
28 
29 void Operations::processI2OFragment( I2OChain& frag ) const
30 {
31  do_processI2OFragment( frag );
32 }
33 
34 void Operations::noFragmentToProcess() const
35 {
36  do_noFragmentToProcess();
37 }
38 
39 std::string Operations::stateName() const
40 {
41  return do_stateName();
42 }
43 
44 void Operations::moveToFailedState( xcept::Exception& exception ) const
45 {
46  do_moveToFailedState( exception );
47 }
48 
49 
51 // Default implementation for (some) virtual functions.
53 
54 void
55 Operations::do_processI2OFragment( I2OChain& frag ) const
56 {
57  //std::cout << stateName() << "::processI2OFragment()" << std::endl;
58 
59  // 20-Mar-2009, KAB: if we get a fragment when we are not supposed to get
60  // one, should we still send a discard message to the resource broker?
61  // If we don't, couldn't that cause problems upstream? If we do, though,
62  // we could end up sending duplicate discard messages (one per fragment).
63  // At a minimum, we should make sure that we don't try to use the discard
64  // manager before it is available.
65  // Of course, if we want to do this, we need to implement a way to get
66  // a handle to the discard manager since outermost_context() doesn't
67  // actually work here.
68  //
69  //if ( outermost_context().getSharedResources().get() != 0 &&
70  // outermost_context().getSharedResources()->discardManager_.get() != 0)
71  // {
72  // outermost_context().getSharedResources()->discardManager_->sendDiscardMessage(frag);
73  // }
74 }
75 
76 
77 void Operations::safeEntryAction()
78 {
79  const std::string unknown = "unknown exception";
80  std::string msg = "Error going into " + stateName() + " state: ";
81  try
82  {
83  do_entryActionWork();
84  }
85  catch( xcept::Exception& e )
86  {
87  XCEPT_DECLARE_NESTED( stor::exception::StateTransition,
88  sentinelException, msg, e );
89  moveToFailedState( sentinelException );
90  }
91  catch( std::exception& e )
92  {
93  msg += e.what();
94  XCEPT_DECLARE( stor::exception::StateTransition,
95  sentinelException, msg );
96  moveToFailedState( sentinelException );
97  }
98  catch(...)
99  {
100  msg += "unknown exception";
101  XCEPT_DECLARE( stor::exception::StateTransition,
102  sentinelException, msg );
103  moveToFailedState( sentinelException );
104  }
105 }
106 
107 
108 void Operations::safeExitAction()
109 {
110  const std::string unknown = "unknown exception";
111  std::string msg = "Error leaving " + stateName() + " state: ";
112  try
113  {
114  do_exitActionWork();
115  }
116  catch( xcept::Exception& e )
117  {
118  XCEPT_DECLARE_NESTED( stor::exception::StateTransition,
119  sentinelException, msg, e );
120  moveToFailedState( sentinelException );
121  }
122  catch( std::exception& e )
123  {
124  msg += e.what();
125  XCEPT_DECLARE( stor::exception::StateTransition,
126  sentinelException, msg );
127  moveToFailedState( sentinelException );
128  }
129  catch(...)
130  {
131  msg += "unknown exception";
132  XCEPT_DECLARE( stor::exception::StateTransition,
133  sentinelException, msg );
134  moveToFailedState( sentinelException );
135  }
136 }
137 
138 
139 void
140 Operations::do_noFragmentToProcess() const
141 {
142  //std::cout << stateName() << "::noFragmentToProcess()" << std::endl;
143 }
144 
145 
146 
153