LV2 Toolkit
1.1.1
Main Page
Related Pages
Modules
Classes
Examples
All
Classes
Namespaces
Functions
Typedefs
Enumerations
Enumerator
Groups
Pages
lvtk
ext
log.hpp
1
/****************************************************************************
2
3
log.hpp - Support file for writing LV2 plugins in C++
4
5
Copyright (C) 2012 Michael Fisher <mfisher31@gmail.com>
6
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 3 of the License, or
10
(at your option) any later version.
11
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA
20
21
****************************************************************************/
22
23
#ifndef LVTK_LV2_LOG_HPP
24
#define LVTK_LV2_LOG_HPP
25
26
#include <stdio.h>
27
#include <lv2/lv2plug.in/ns/ext/log/log.h>
28
29
namespace
lvtk
30
{
31
38
template
<
bool
Required = true>
39
struct
Log
40
{
41
template
<
class
Derived>
42
struct
I
: Extension<Required>
43
{
45
I
() : p_log(NULL) { }
46
48
static
void
49
map_feature_handlers
(
FeatureHandlerMap
& hmap)
50
{
51
hmap[LV2_LOG__log] = &
I<Derived>::handle_feature
;
52
}
53
55
static
void
56
handle_feature
(
void
* instance,
FeatureData
data)
57
{
58
Derived* d =
reinterpret_cast<
Derived*
>
(instance);
59
I<Derived>
* mixin =
static_cast<
I<Derived>
*
>
(d);
60
61
mixin->p_log =
reinterpret_cast<
LV2_Log_Log*
>
(data);
62
mixin->m_ok =
true
;
63
}
64
66
bool
67
check_ok
()
68
{
69
if
(LVTK_DEBUG)
70
{
71
std::clog <<
" [Log] Validation "
72
<< (this->m_ok ?
"succeeded"
:
"failed"
)
73
<<
"."
<< std::endl;
74
}
75
return
this->m_ok;
76
}
77
78
protected
:
79
87
int
88
vprintf
(LV2_URID type,
const
char
* fmt, va_list ap)
89
{
90
if
(p_log != NULL)
91
return
p_log->vprintf(p_log->handle, type, fmt, ap);
92
return ::vprintf (fmt, ap);
93
}
94
102
int
103
printf
(LV2_URID type,
const
char
* fmt, ...)
104
{
105
va_list argptr;
106
va_start(argptr, fmt);
107
108
int
res (this->
vprintf
(type, fmt, argptr));
109
va_end(argptr);
110
111
return
res;
112
}
113
114
LV2_Log_Log * p_log;
115
116
};
117
};
118
}
119
120
#endif
/* LVTK_LV2_LOG_HPP */
Generated on Thu May 9 2013 17:39:00 for LV2 Toolkit by
1.8.3.1