Make loggables more uniform.
This commit is contained in:
parent
9246742be2
commit
0e6352c54a
|
@ -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" );
|
||||
}
|
20
Loggable.H
20
Loggable.H
|
@ -19,14 +19,34 @@
|
|||
|
||||
/* Master class for journaling. */
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
class Loggable
|
||||
{
|
||||
|
||||
static int _log_id;
|
||||
|
||||
private:
|
||||
int _id;
|
||||
|
||||
public:
|
||||
|
||||
Loggable ( )
|
||||
{
|
||||
_id = ++_log_id;
|
||||
}
|
||||
|
||||
/* log messages for journal */
|
||||
virtual void log_create ( void ) = 0;
|
||||
virtual void log_destroy ( void ) = 0;
|
||||
virtual void log_move ( 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
|
||||
|
|
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ CXXFLAGS=-ggdb -Wall -O0
|
|||
LIBS=-lsndfile `fltk-config --ldflags`
|
||||
# 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)
|
||||
|
||||
|
|
13
Region.H
13
Region.H
|
@ -35,6 +35,9 @@ using namespace std;
|
|||
|
||||
#include "Track_Widget.H"
|
||||
|
||||
/* got I hate C++ */
|
||||
#define __CLASS__ "Region"
|
||||
|
||||
class Region : public Track_Widget
|
||||
{
|
||||
|
||||
|
@ -56,22 +59,22 @@ protected:
|
|||
/* general */
|
||||
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 )
|
||||
{
|
||||
printf( "region destroy %p\n", this );
|
||||
log( "destroy", NULL );
|
||||
}
|
||||
|
||||
void log_move ( void )
|
||||
{
|
||||
printf( "region move %p %lu\n", this, _offset );
|
||||
log( "move", "%lu", _offset );
|
||||
}
|
||||
|
||||
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:
|
||||
|
@ -92,3 +95,5 @@ public:
|
|||
void dump ( void );
|
||||
|
||||
};
|
||||
|
||||
#undef __CLASS__
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "Track_Point.H"
|
||||
|
||||
#define __CLASS__ "Tempo_Point"
|
||||
|
||||
class Tempo_Point : public Track_Point
|
||||
{
|
||||
float _tempo;
|
||||
|
@ -36,9 +38,9 @@ class Tempo_Point : public Track_Point
|
|||
|
||||
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:
|
||||
|
||||
|
@ -73,3 +75,4 @@ public:
|
|||
}
|
||||
|
||||
};
|
||||
#undef __CLASS__
|
||||
|
|
12
Time_Point.H
12
Time_Point.H
|
@ -20,6 +20,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Track_Point.H"
|
||||
#include "Loggable.H"
|
||||
|
||||
struct time_sig
|
||||
{
|
||||
|
@ -33,6 +34,9 @@ struct time_sig
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
#define __CLASS__ "Time_Point"
|
||||
|
||||
class Time_Point : public Track_Point
|
||||
{
|
||||
time_sig _time;
|
||||
|
@ -48,9 +52,9 @@ class Time_Point : public Track_Point
|
|||
|
||||
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:
|
||||
|
||||
|
@ -85,3 +89,5 @@ public:
|
|||
}
|
||||
|
||||
};
|
||||
|
||||
#undef __CLASS__
|
||||
|
|
Loading…
Reference in New Issue