~christophe-andral/wm2midi/trunk

« back to all changes in this revision

Viewing changes to src/emitter.cc

  • Committer: Christophe Andral
  • Date: 2010-03-17 06:45:17 UTC
  • Revision ID: christophe@andral.fr-20100317064517-fzejb2w81nw0olyt
InitialĀ sourceĀ import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 
2
/*
 
3
 * wm2midi
 
4
 * Copyright (C) Christophe Andral 2010 <christophe@andral.fr>
 
5
 * 
 
6
 * wm2midi is free software: you can redistribute it and/or modify it
 
7
 * under the terms of the GNU General Public License as published by the
 
8
 * Free Software Foundation, either version 3 of the License, or
 
9
 * (at your option) any later version.
 
10
 * 
 
11
 * wm2midi is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
14
 * See the GNU General Public License for more details.
 
15
 * 
 
16
 * You should have received a copy of the GNU General Public License along
 
17
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include "emitter.h"
 
21
 
 
22
#include "log.h"
 
23
#include "bloc.h"
 
24
#include "receiver.h"
 
25
 
 
26
namespace WM2Midi {
 
27
 
 
28
Emitter::Emitter(Bloc* bloc_parent, std::string emitter_name) :
 
29
        Port( bloc_parent, Port::OUTPUT, emitter_name ),
 
30
        parent( bloc_parent )
 
31
{
 
32
}
 
33
 
 
34
Emitter::~Emitter()
 
35
{
 
36
}
 
37
 
 
38
void
 
39
Emitter::connect(Receiver* receiver)
 
40
{
 
41
        receivers.insert( receiver );
 
42
}
 
43
 
 
44
void
 
45
Emitter::emit(double value)
 
46
{
 
47
        if (receivers.empty()) return;
 
48
        Log::TRACE("Emit %s value:%f", name.c_str(), value);
 
49
        std::set<Receiver*>::const_iterator cur(receivers.begin()), end(receivers.end());
 
50
        for(;cur!=end;++cur)
 
51
        {
 
52
                (*cur)->on_receive( this, value );
 
53
        }
 
54
}
 
55
 
 
56
} //namespace
 
 
b'\\ No newline at end of file'