Action_Tracing.hpp

Go to the documentation of this file.
00001 // 
00002 // Copyright (C) 2007 Free Software Foundation, Inc.
00003 //
00004 // This file is part of GNU Cygnal.
00005 // 
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 
00022 
00023 #pragma once
00024 #ifndef __Action_Tracing_hpp__
00025 #define __Action_Tracing_hpp__
00026 
00027 #include <string>
00028 
00029 namespace ACT {
00030 
00031         //-------------------------
00035         class execution_trace
00036         {
00038                 std::string tracking_string ;
00039 
00040         public:
00041                 execution_trace()
00042                         : tracking_string( "" ) {}
00043 
00044                 void add( std::string x )
00045                 {
00046                         tracking_string += x ;
00047                 }
00048 
00049                 std::string result() const
00050                 {
00051                         return tracking_string ;
00052                 }
00053         } ;
00054 
00055         //-------------------------
00059         class tracking_function
00060         {
00061         public:
00066                 virtual void operator()( const std::string ) =0 ;
00067         } ;
00068 
00069         //-------------------------
00073         class simple_tracker
00074                 : public tracking_function
00075         {
00077                 execution_trace & trace ;
00078 
00080                 const std::string prefix ;
00081 
00082         public:
00084                 simple_tracker( execution_trace & trace, const std::string prefix )
00085                         : trace( trace ), prefix( prefix )
00086                 {}
00087 
00089                 virtual ~simple_tracker() {}
00090                 
00092                 void operator()( const std::string x )
00093                 {
00094                         std::string tracking_string( prefix ) ;
00095                         if ( ! x.empty() ) {
00096                                 tracking_string += "(" ;
00097                                 tracking_string += x ;
00098                                 tracking_string += ")" ;
00099                         }
00100                         trace.add( tracking_string ) ;
00101                 }
00102         } ;
00103 
00104         //-------------------------
00105 } // end namespace ACT
00106 
00107 #endif

Generated on Thu Mar 6 18:25:06 2008 for Gnash by  doxygen 1.5.4