| @@ -0,0 +1,46 @@ | |||||
| /*******************************************************************************/ | |||||
| /* Copyright (C) 2008 Jonathan Moore Liles */ | |||||
| /* */ | |||||
| /* This program is free software; you can redistribute it and/or modify it */ | |||||
| /* under the terms of the GNU General Public License as published by the */ | |||||
| /* Free Software Foundation; either version 2 of the License, or (at your */ | |||||
| /* option) any later version. */ | |||||
| /* */ | |||||
| /* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||||
| /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||||
| /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||||
| /* more details. */ | |||||
| /* */ | |||||
| /* You should have received a copy of the GNU General Public License along */ | |||||
| /* with This program; see the file COPYING. If not,write to the Free Software */ | |||||
| /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
| /*******************************************************************************/ | |||||
| #define _LOGGABLE_C | |||||
| #include "Loggable.H" | |||||
| #undef _LOGABLE_C | |||||
| #include <stdio.h> | |||||
| #include <stdarg.h> | |||||
| int Loggable::_log_id = 0; | |||||
| void | |||||
| Loggable::log ( const char *module, const char *action, const char *fmt, ... ) | |||||
| { | |||||
| va_list args; | |||||
| /* FIXME: log all this stuff to someplace meaningful */ | |||||
| printf( "%s %s %p ", module, action, _id ); | |||||
| if ( fmt ) | |||||
| { | |||||
| va_start( args, fmt ); | |||||
| vfprintf( stdout, fmt, args ); | |||||
| va_end( args ); | |||||
| } | |||||
| printf( "\n" ); | |||||
| } | |||||
| @@ -19,14 +19,34 @@ | |||||
| /* Master class for journaling. */ | /* Master class for journaling. */ | ||||
| #pragma once | |||||
| class Loggable | class Loggable | ||||
| { | { | ||||
| static int _log_id; | |||||
| private: | |||||
| int _id; | |||||
| public: | public: | ||||
| Loggable ( ) | |||||
| { | |||||
| _id = ++_log_id; | |||||
| } | |||||
| /* log messages for journal */ | /* log messages for journal */ | ||||
| virtual void log_create ( void ) = 0; | virtual void log_create ( void ) = 0; | ||||
| virtual void log_destroy ( void ) = 0; | virtual void log_destroy ( void ) = 0; | ||||
| virtual void log_move ( void ) = 0; | virtual void log_move ( void ) = 0; | ||||
| virtual void log_change ( void ) = 0; | virtual void log_change ( void ) = 0; | ||||
| void log ( const char *module, const char *action, const char *fmt, ... ); | |||||
| }; | }; | ||||
| #ifndef _LOGGABLE_C | |||||
| #define log( act, fmt, args... ) log( __CLASS__, act, fmt, ## args ) | |||||
| #endif | |||||
| @@ -5,7 +5,7 @@ CXXFLAGS=-ggdb -Wall -O0 | |||||
| LIBS=-lsndfile `fltk-config --ldflags` | LIBS=-lsndfile `fltk-config --ldflags` | ||||
| # CXXFLAGS=`fltk-config -cxxflags` | # CXXFLAGS=`fltk-config -cxxflags` | ||||
| SRCS= Waveform.C Region.C Peaks.C main.C Track.C Timeline.C Audio_File.C Audio_File_SF.C | |||||
| SRCS= Waveform.C Region.C Peaks.C main.C Track.C Timeline.C Audio_File.C Audio_File_SF.C Loggable.C | |||||
| OBJS=$(SRCS:.C=.o) | OBJS=$(SRCS:.C=.o) | ||||
| @@ -35,6 +35,9 @@ using namespace std; | |||||
| #include "Track_Widget.H" | #include "Track_Widget.H" | ||||
| /* got I hate C++ */ | |||||
| #define __CLASS__ "Region" | |||||
| class Region : public Track_Widget | class Region : public Track_Widget | ||||
| { | { | ||||
| @@ -56,22 +59,22 @@ protected: | |||||
| /* general */ | /* general */ | ||||
| void log_create ( void ) | void log_create ( void ) | ||||
| { | { | ||||
| printf( "region create %p %lu \"%s\" %d %f %lu %lu\n", this, _offset, _clip->name(), _selected, _scale, _start, _end ); | |||||
| log( "create", "%lu \"%s\" %d %f %lu %lu", _offset, _clip->name(), _selected, _scale, _start, _end ); | |||||
| } | } | ||||
| void log_destroy ( void ) | void log_destroy ( void ) | ||||
| { | { | ||||
| printf( "region destroy %p\n", this ); | |||||
| log( "destroy", NULL ); | |||||
| } | } | ||||
| void log_move ( void ) | void log_move ( void ) | ||||
| { | { | ||||
| printf( "region move %p %lu\n", this, _offset ); | |||||
| log( "move", "%lu", _offset ); | |||||
| } | } | ||||
| void log_change ( void ) | void log_change ( void ) | ||||
| { | { | ||||
| printf( "region change %p %d %f %lu %lu\n", this, _selected, _scale, _start, _end ); | |||||
| log( "change", "%d %f %lu %lu", _selected, _scale, _start, _end ); | |||||
| } | } | ||||
| public: | public: | ||||
| @@ -92,3 +95,5 @@ public: | |||||
| void dump ( void ); | void dump ( void ); | ||||
| }; | }; | ||||
| #undef __CLASS__ | |||||
| @@ -21,6 +21,8 @@ | |||||
| #include "Track_Point.H" | #include "Track_Point.H" | ||||
| #define __CLASS__ "Tempo_Point" | |||||
| class Tempo_Point : public Track_Point | class Tempo_Point : public Track_Point | ||||
| { | { | ||||
| float _tempo; | float _tempo; | ||||
| @@ -36,9 +38,9 @@ class Tempo_Point : public Track_Point | |||||
| protected: | protected: | ||||
| void log_create ( void ) { printf( "tempo-point create %p %lu %f\n", this, _offset, _tempo ); } | |||||
| void log_destroy ( void ) { printf( "tempo-point destroy %p\n", this ); } | |||||
| void log_move ( void ) { printf( "tempo-point move %p %lu\n", this, _offset ); } | |||||
| void log_create ( void ) { log( "create", "%lu %f", _offset, _tempo ); } | |||||
| void log_destroy ( void ) { log( "destroy", NULL ); } | |||||
| void log_move ( void ) { log( "move", "%lu", _offset ); } | |||||
| public: | public: | ||||
| @@ -73,3 +75,4 @@ public: | |||||
| } | } | ||||
| }; | }; | ||||
| #undef __CLASS__ | |||||
| @@ -20,6 +20,7 @@ | |||||
| #pragma once | #pragma once | ||||
| #include "Track_Point.H" | #include "Track_Point.H" | ||||
| #include "Loggable.H" | |||||
| struct time_sig | struct time_sig | ||||
| { | { | ||||
| @@ -33,6 +34,9 @@ struct time_sig | |||||
| } | } | ||||
| }; | }; | ||||
| #define __CLASS__ "Time_Point" | |||||
| class Time_Point : public Track_Point | class Time_Point : public Track_Point | ||||
| { | { | ||||
| time_sig _time; | time_sig _time; | ||||
| @@ -48,9 +52,9 @@ class Time_Point : public Track_Point | |||||
| protected: | protected: | ||||
| void log_create ( void ) { printf( "time-point create %p %lu %d %d\n", this, _offset, _time.beats_per_bar, _time.note_type ); } | |||||
| void log_destroy ( void ) { printf( "time-point destroy %p\n", this ); } | |||||
| void log_move ( void ) { printf( "time-point move %p %lu\n", this, _offset ); } | |||||
| void log_create ( void ) { log( "create", "%lu %d %d", _offset, _time.beats_per_bar, _time.note_type ); } | |||||
| void log_destroy ( void ) { log( "destroy", NULL ); } | |||||
| void log_move ( void ) { log( "move", "%lu", _offset ); } | |||||
| public: | public: | ||||
| @@ -85,3 +89,5 @@ public: | |||||
| } | } | ||||
| }; | }; | ||||
| #undef __CLASS__ | |||||