|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00052 abstract class progressive_parser_processor { 00053 00054 protected $inittime; // Initial microtime 00055 protected $chunks; // Number of chunks processed 00056 00057 public function __construct() { 00058 $this->inittime= microtime(true); 00059 $this->chunks = 0; 00060 } 00061 00065 abstract public function process_chunk($data); 00066 00070 public function before_path($path) { } 00071 00075 public function after_path($path) { } 00076 00080 public function process_cdata($cdata) { 00081 return $cdata; 00082 } 00083 00084 public function debug_info() { 00085 return array('memory' => memory_get_peak_usage(true), 00086 'time' => microtime(true) - $this->inittime, 00087 'chunks' => $this->chunks); 00088 } 00089 00090 public function receive_chunk($data) { 00091 $this->chunks++; 00092 $this->process_chunk($data); 00093 } 00094 00095 }