/[svn]/linuxsampler/trunk/src/network/lscpevent.cpp
ViewVC logotype

Annotation of /linuxsampler/trunk/src/network/lscpevent.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1161 - (hide annotations) (download)
Mon Apr 16 15:51:18 2007 UTC (17 years ago) by iliev
File size: 4521 byte(s)
* Implemented instruments database

1 senkov 170 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 880 * Copyright (C) 2005, 2006 Christian Schoenebeck *
7 senkov 170 * *
8     * This program is free software; you can redistribute it and/or modify *
9     * it under the terms of the GNU General Public License as published by *
10     * the Free Software Foundation; either version 2 of the License, or *
11     * (at your option) any later version. *
12     * *
13     * This program is distributed in the hope that it will be useful, *
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16     * GNU General Public License for more details. *
17     * *
18     * You should have received a copy of the GNU General Public License *
19     * along with this program; if not, write to the Free Software *
20     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21     * MA 02111-1307 USA *
22     ***************************************************************************/
23    
24     /*********************************************************
25     * This class helps to constuct valid events per
26     * LSCP protocol specification
27     *
28     * It also helps LSCPServer lookup the events when
29     * a client is trying to subscribe to an event
30     *
31     * ******************************************************/
32    
33     #include "lscpevent.h"
34    
35     std::map<LSCPEvent::event_t, String> LSCPEvent::EventNames = std::map<LSCPEvent::event_t, String>();
36    
37 schoenebeck 880 LSCPEvent::LSCPEvent(String eventName) throw (Exception) {
38 senkov 170 for (std::map<event_t, String>::iterator iter = EventNames.begin(); iter != EventNames.end(); iter++) {
39     if (iter->second == eventName) {
40     this->type = iter->first;
41     return;
42     }
43     }
44 schoenebeck 880 throw Exception("Event does not exist");
45 senkov 170 }
46    
47     LSCPEvent::LSCPEvent(event_t eventType, int uiData) {
48     this->type = eventType;
49     this->storage = ToString(uiData);
50     }
51    
52     LSCPEvent::LSCPEvent(event_t eventType, String sData) {
53     this->type = eventType;
54     this->storage = sData;
55     }
56    
57     LSCPEvent::LSCPEvent(event_t eventType, int uiData1, int uiData2) {
58     this->type = eventType;
59     this->storage = ToString(uiData1) + " " + ToString(uiData2);
60     }
61    
62     LSCPEvent::LSCPEvent(event_t eventType, String sData, int uiData) {
63     this->type = eventType;
64     this->storage = sData + " " + ToString(uiData);
65     }
66    
67 iliev 1108 LSCPEvent::LSCPEvent(event_t eventType, String sData, double dData) {
68     this->type = eventType;
69     this->storage = sData + " " + ToString(dData);
70     }
71    
72 senkov 170 LSCPEvent::LSCPEvent(event_t eventType, int uiData, String sData) {
73     this->type = eventType;
74     this->storage = ToString(uiData) + " " + sData;
75     }
76    
77 iliev 981 LSCPEvent::LSCPEvent(event_t eventType, int uiData1, int uiData2, int uiData3) {
78     this->type = eventType;
79     this->storage = ToString(uiData1) + " " + ToString(uiData2) + " " + ToString(uiData3);
80     }
81    
82 iliev 1161 LSCPEvent::LSCPEvent(event_t eventType, String sData1, String sData2, String sData3) {
83     this->type = eventType;
84     this->storage = sData1 + " " + sData2 + " " + sData3;
85     }
86    
87 senkov 170 //Produce event string
88     String LSCPEvent::Produce(void) {
89     String result = "NOTIFY:";
90     result += EventNames[type];
91     result += ":";
92     result += storage;
93 schoenebeck 552 result += "\r\n";
94 senkov 170 return result;
95     }
96    
97     //This can later return handle and then we can get rid of event_t enum
98     //and make events fully dynamic
99     void LSCPEvent::RegisterEvent(event_t eventType, String EventName) {
100     EventNames[eventType] = EventName;
101     }
102    
103     void LSCPEvent::UnregisterEvent(event_t eventType) {
104     EventNames.erase(eventType);
105     }
106    
107     //The following static method is used to get names from types
108     String LSCPEvent::Name(event_t eventType) {
109     if (EventNames.count(eventType))
110     return EventNames[eventType];
111     return "UNKNOWN";
112     }
113    
114     std::list<LSCPEvent::event_t> LSCPEvent::List( void ) {
115     std::list<event_t> result;
116     for (std::map<event_t, String>::iterator iter = EventNames.begin(); iter != EventNames.end(); iter++)
117     result.push_back(iter->first);
118     return result;
119     }
120    

  ViewVC Help
Powered by ViewVC