Mixer: Hide panner widget until it's ready to be connected to something...
[nondaw.git] / nonlib / Log_Entry.H
blob66fb9d35267910dcb42cae864ae3043ff5e44b86
2 /*******************************************************************************/
3 /* Copyright (C) 2008 Jonathan Moore Liles                                     */
4 /*                                                                             */
5 /* This program is free software; you can redistribute it and/or modify it     */
6 /* under the terms of the GNU General Public License as published by the       */
7 /* Free Software Foundation; either version 2 of the License, or (at your      */
8 /* option) any later version.                                                  */
9 /*                                                                             */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       */
12 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   */
13 /* more details.                                                               */
14 /*                                                                             */
15 /* You should have received a copy of the GNU General Public License along     */
16 /* with This program; see the file COPYING.  If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18 /*******************************************************************************/
20 #pragma once
22 #include "Loggable.H"
24 #include "types.h"
26 class Log_Entry
28 //    vector <Pair> _sa;
29     char **_sa;
30     int _i;
32     /* not permitted */
33     Log_Entry ( const Log_Entry &rhs );
34     Log_Entry & operator= ( const Log_Entry &rhs );
36     static char ** parse_alist ( const char *s );
37     static bool log_diff (  char **sa1, char **sa2 );
39 public:
41     Log_Entry ( );
42     Log_Entry ( char **sa );
43     Log_Entry ( const char *s );
44     ~Log_Entry ( );
46 /****************/
47 /* Construction */
48 /****************/
50     void grow (  );
52 #define ADD( type, format, exp )                                        \
53     void add ( const char *name, type v )                               \
54         {                                                               \
55             grow();                                                     \
56             asprintf( &_sa[ _i ], "%s " format, name, (exp) );          \
57             strtok( _sa[ _i++ ], " " );                                 \
58         }                                                               \
60 /***************/
61 /* Examination */
62 /***************/
64     static bool diff ( Log_Entry *e1, Log_Entry *e2 );
66     int size ( void ) const;
68     void get ( int n, const char **name, const char **value ) const;
69     char **sa ( void );
71     char *print ( void ) const;
73 /* #define ADD ( type, format, exp )             \ */
74 /*     void add ( const char *name, type v ) \ */
75 /*         { \ */
76 /*             char pat[ 256 ]; \ */
77 /*             Pair p; \ */
78 /*             p.name = strdup( name ); \ */
79 /*             snprintf( pat, sizeof( pat ), format, exp ); \ */
80 /*             p.value = strdup( pat ); \ */
81 /*             _sa.push( p ); \ */
82 /*         } \ */
84     ADD( int, "%d", v );
85     ADD( nframes_t, "%lu", (unsigned long)v );
86     ADD( unsigned long, "%lu", v );
87     ADD( const char *, "\"%s\"", v ? Loggable::escape( v ) : "" );
88     ADD( Loggable * , "0x%X", v ? v->id() : 0 );
89     ADD( float, "%f", v );
90     ADD( double, "%f", v );
92 #undef ADD