@@ -59,143 +59,143 @@ |
||
59 | 59 | */ |
60 | 60 | class Story_Checkpoint implements IteratorAggregate |
61 | 61 | { |
62 | - /** |
|
63 | - * the StoryTeller object |
|
64 | - * |
|
65 | - * @var \DataSift\Storyplayer\PlayerLib\StoryTeller |
|
66 | - */ |
|
67 | - private $st; |
|
68 | - |
|
69 | - /** |
|
70 | - * keep track of whether the checkpoint is readonly (true) or |
|
71 | - * read-write(false) |
|
72 | - * |
|
73 | - * @var boolean |
|
74 | - */ |
|
75 | - private $readOnly = false; |
|
76 | - |
|
77 | - /** |
|
78 | - * the data stored inside the checkpoint |
|
79 | - * |
|
80 | - * @var array |
|
81 | - */ |
|
82 | - private $data = array(); |
|
83 | - |
|
84 | - /** |
|
85 | - * our constructor |
|
86 | - * |
|
87 | - * @param StoryTeller $st |
|
88 | - * The StoryTeller object (which we will cache) |
|
89 | - */ |
|
90 | - public function __construct(StoryTeller $st) |
|
91 | - { |
|
92 | - // remember the StoryTeller object for future use |
|
93 | - $this->st = $st; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * is the checkpoint currently readonly? |
|
98 | - * |
|
99 | - * @return boolean |
|
100 | - * TRUE if the checkpoint is currently readonly |
|
101 | - * FALSE if you can change the data in the checkpoint |
|
102 | - */ |
|
103 | - public function getReadOnly() |
|
104 | - { |
|
105 | - return $this->readOnly; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * put the checkpoint into readonly mode |
|
110 | - */ |
|
111 | - public function setReadOnly() |
|
112 | - { |
|
113 | - $this->readOnly = true; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * put the checkpoint into read-write mode |
|
118 | - */ |
|
119 | - public function setReadWrite() |
|
120 | - { |
|
121 | - $this->readOnly = false; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * magic method to retrieve data from the checkpoint |
|
126 | - * |
|
127 | - * throws the E5xx_NoSuchDataInCheckpoint exception if you attempt |
|
128 | - * to get data that does not exist |
|
129 | - * |
|
130 | - * @param string $key |
|
131 | - * the name of the data to store |
|
132 | - * @return mixed |
|
133 | - * the data stored in the checkpoint |
|
134 | - */ |
|
135 | - public function &__get($key) |
|
136 | - { |
|
137 | - // what are we doing? |
|
138 | - $log = Log::usingLog()->startAction("retrieve '{$key}' from the checkpoint"); |
|
139 | - |
|
140 | - // do we have the data to return? |
|
141 | - if (!isset($this->data[$key])) { |
|
142 | - // no, we do not |
|
143 | - $log->endAction("'{$key}' is not in the checkpoint"); |
|
144 | - throw new E5xx_NoSuchDataInCheckpoint($key); |
|
145 | - } |
|
146 | - |
|
147 | - // yes, we do |
|
62 | + /** |
|
63 | + * the StoryTeller object |
|
64 | + * |
|
65 | + * @var \DataSift\Storyplayer\PlayerLib\StoryTeller |
|
66 | + */ |
|
67 | + private $st; |
|
68 | + |
|
69 | + /** |
|
70 | + * keep track of whether the checkpoint is readonly (true) or |
|
71 | + * read-write(false) |
|
72 | + * |
|
73 | + * @var boolean |
|
74 | + */ |
|
75 | + private $readOnly = false; |
|
76 | + |
|
77 | + /** |
|
78 | + * the data stored inside the checkpoint |
|
79 | + * |
|
80 | + * @var array |
|
81 | + */ |
|
82 | + private $data = array(); |
|
83 | + |
|
84 | + /** |
|
85 | + * our constructor |
|
86 | + * |
|
87 | + * @param StoryTeller $st |
|
88 | + * The StoryTeller object (which we will cache) |
|
89 | + */ |
|
90 | + public function __construct(StoryTeller $st) |
|
91 | + { |
|
92 | + // remember the StoryTeller object for future use |
|
93 | + $this->st = $st; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * is the checkpoint currently readonly? |
|
98 | + * |
|
99 | + * @return boolean |
|
100 | + * TRUE if the checkpoint is currently readonly |
|
101 | + * FALSE if you can change the data in the checkpoint |
|
102 | + */ |
|
103 | + public function getReadOnly() |
|
104 | + { |
|
105 | + return $this->readOnly; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * put the checkpoint into readonly mode |
|
110 | + */ |
|
111 | + public function setReadOnly() |
|
112 | + { |
|
113 | + $this->readOnly = true; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * put the checkpoint into read-write mode |
|
118 | + */ |
|
119 | + public function setReadWrite() |
|
120 | + { |
|
121 | + $this->readOnly = false; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * magic method to retrieve data from the checkpoint |
|
126 | + * |
|
127 | + * throws the E5xx_NoSuchDataInCheckpoint exception if you attempt |
|
128 | + * to get data that does not exist |
|
129 | + * |
|
130 | + * @param string $key |
|
131 | + * the name of the data to store |
|
132 | + * @return mixed |
|
133 | + * the data stored in the checkpoint |
|
134 | + */ |
|
135 | + public function &__get($key) |
|
136 | + { |
|
137 | + // what are we doing? |
|
138 | + $log = Log::usingLog()->startAction("retrieve '{$key}' from the checkpoint"); |
|
139 | + |
|
140 | + // do we have the data to return? |
|
141 | + if (!isset($this->data[$key])) { |
|
142 | + // no, we do not |
|
143 | + $log->endAction("'{$key}' is not in the checkpoint"); |
|
144 | + throw new E5xx_NoSuchDataInCheckpoint($key); |
|
145 | + } |
|
146 | + |
|
147 | + // yes, we do |
|
148 | 148 | $log->endAction($this->data[$key]); |
149 | 149 | |
150 | - // all done |
|
151 | - return $this->data[$key]; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * magic method to tell if the data is stored in the checkpoint or not |
|
156 | - * |
|
157 | - * @param string $key |
|
158 | - * the name of the data to test for |
|
159 | - * @return boolean |
|
160 | - * TRUE if the data exists in the checkpoint |
|
161 | - * FALSE if the data does not exist in the checkpoint |
|
162 | - */ |
|
163 | - public function __isset($key) |
|
164 | - { |
|
165 | - return (isset($this->data[$key])); |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * magic method to store data in the checkpoint |
|
170 | - * |
|
171 | - * throws the E5xx_CheckpointIsReadOnly exception if you attempt |
|
172 | - * to store data when the checkpoint is in readonly mode |
|
173 | - * |
|
174 | - * @param string $key |
|
175 | - * the name of the data to store |
|
176 | - * @param mixed $value |
|
177 | - * the value to store in the checkpoint |
|
178 | - * @return void |
|
179 | - */ |
|
180 | - public function __set($key, $value) |
|
181 | - { |
|
182 | - // what are we doing? |
|
183 | - $log = Log::usingLog()->startAction("store '{$key}' in the checkpoint"); |
|
184 | - |
|
185 | - // are we allowed to change the data at this time? |
|
186 | - if ($this->readOnly) |
|
187 | - { |
|
188 | - // no, we are not |
|
189 | - $log->endAction("checkpoint is readonly; did not store '{$key}'"); |
|
190 | - throw new E5xx_CheckpointIsReadOnly(); |
|
191 | - } |
|
192 | - |
|
193 | - // if we get here, we're allowed to change the checkpoint |
|
194 | - $this->data[$key] = $value; |
|
195 | - |
|
196 | - // all done |
|
197 | - $log->endAction($value); |
|
198 | - } |
|
150 | + // all done |
|
151 | + return $this->data[$key]; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * magic method to tell if the data is stored in the checkpoint or not |
|
156 | + * |
|
157 | + * @param string $key |
|
158 | + * the name of the data to test for |
|
159 | + * @return boolean |
|
160 | + * TRUE if the data exists in the checkpoint |
|
161 | + * FALSE if the data does not exist in the checkpoint |
|
162 | + */ |
|
163 | + public function __isset($key) |
|
164 | + { |
|
165 | + return (isset($this->data[$key])); |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * magic method to store data in the checkpoint |
|
170 | + * |
|
171 | + * throws the E5xx_CheckpointIsReadOnly exception if you attempt |
|
172 | + * to store data when the checkpoint is in readonly mode |
|
173 | + * |
|
174 | + * @param string $key |
|
175 | + * the name of the data to store |
|
176 | + * @param mixed $value |
|
177 | + * the value to store in the checkpoint |
|
178 | + * @return void |
|
179 | + */ |
|
180 | + public function __set($key, $value) |
|
181 | + { |
|
182 | + // what are we doing? |
|
183 | + $log = Log::usingLog()->startAction("store '{$key}' in the checkpoint"); |
|
184 | + |
|
185 | + // are we allowed to change the data at this time? |
|
186 | + if ($this->readOnly) |
|
187 | + { |
|
188 | + // no, we are not |
|
189 | + $log->endAction("checkpoint is readonly; did not store '{$key}'"); |
|
190 | + throw new E5xx_CheckpointIsReadOnly(); |
|
191 | + } |
|
192 | + |
|
193 | + // if we get here, we're allowed to change the checkpoint |
|
194 | + $this->data[$key] = $value; |
|
195 | + |
|
196 | + // all done |
|
197 | + $log->endAction($value); |
|
198 | + } |
|
199 | 199 | |
200 | 200 | // ==================================================================== |
201 | 201 | // |