blob: 3972a32a424877630b96e35e1417bc6cdbcf0c99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
//
// libavg - Media Playback Engine.
// Copyright (C) 2003-2014 Ulrich von Zadow
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Current versions can be found at www.libavg.de
//
#include "PublisherDefinitionRegistry.h"
#include "PublisherDefinition.h"
#include "../base/Exception.h"
using namespace std;
namespace avg {
PublisherDefinitionRegistry* PublisherDefinitionRegistry::s_pInstance = 0;
PublisherDefinitionRegistry::PublisherDefinitionRegistry()
: m_LastMessageID(-1)
{
s_pInstance = this;
// The following should really happen in the player constructor, but the entries
// need to exist for the player to be constructed.
PublisherDefinitionPtr pPlayerDef = PublisherDefinition::create("Player");
pPlayerDef->addMessage("KEY_DOWN");
pPlayerDef->addMessage("KEY_UP");
pPlayerDef->addMessage("PLAYBACK_START");
pPlayerDef->addMessage("PLAYBACK_END");
pPlayerDef->addMessage("ON_FRAME");
}
PublisherDefinitionRegistry::~PublisherDefinitionRegistry()
{
}
PublisherDefinitionRegistry* PublisherDefinitionRegistry::get()
{
if (!s_pInstance) {
new PublisherDefinitionRegistry();
}
return s_pInstance;
}
void PublisherDefinitionRegistry::registerDefinition(PublisherDefinitionPtr def)
{
m_Definitions.push_back(def);
}
PublisherDefinitionPtr PublisherDefinitionRegistry::getDefinition(const string& sName)
const
{
for (unsigned i=0; i<m_Definitions.size(); ++i) {
if (m_Definitions[i]->getName() == sName) {
return m_Definitions[i];
}
}
AVG_ASSERT_MSG(false, (string("Can't find PublisherDefinition ")+sName).c_str());
return PublisherDefinitionPtr();
}
void PublisherDefinitionRegistry::dump() const
{
for (unsigned i=0; i<m_Definitions.size(); ++i) {
m_Definitions[i]->dump();
}
}
MessageID PublisherDefinitionRegistry::genMessageID(const string& sName)
{
return MessageID(sName, ++m_LastMessageID);
}
}
|