/[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 1424 - (hide annotations) (download)
Sun Oct 14 22:00:17 2007 UTC (16 years, 7 months ago) by schoenebeck
File size: 4560 byte(s)
* code cleanup:
- global.h now only covers global definitions that are needed for the C++
  API header files, all implementation internal global definitions are now
  in global_private.h
- atomic.h is not exposed to the C++ API anymore (replaced the references
  in SynchronizedConfig.h for this with local definitions)
- no need to include config.h anymore for using LS's API header files
- DB instruments classes are not exposed to the C++ API
- POSIX callback functions of Thread.h are hidden
- the (optional) gig Engine benchmark compiles again
- updated Doxyfile.in
- fixed warnings in API doc generation
* preparations for release 0.5.0

1 senkov 170 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 1424 * Copyright (C) 2005 - 2007 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 schoenebeck 1424 #include "../common/global_private.h"
36    
37 senkov 170 std::map<LSCPEvent::event_t, String> LSCPEvent::EventNames = std::map<LSCPEvent::event_t, String>();
38    
39 schoenebeck 880 LSCPEvent::LSCPEvent(String eventName) throw (Exception) {
40 senkov 170 for (std::map<event_t, String>::iterator iter = EventNames.begin(); iter != EventNames.end(); iter++) {
41     if (iter->second == eventName) {
42     this->type = iter->first;
43     return;
44     }
45     }
46 schoenebeck 880 throw Exception("Event does not exist");
47 senkov 170 }
48    
49     LSCPEvent::LSCPEvent(event_t eventType, int uiData) {
50     this->type = eventType;
51     this->storage = ToString(uiData);
52     }
53    
54     LSCPEvent::LSCPEvent(event_t eventType, String sData) {
55     this->type = eventType;
56     this->storage = sData;
57     }
58    
59     LSCPEvent::LSCPEvent(event_t eventType, int uiData1, int uiData2) {
60     this->type = eventType;
61     this->storage = ToString(uiData1) + " " + ToString(uiData2);
62     }
63    
64     LSCPEvent::LSCPEvent(event_t eventType, String sData, int uiData) {
65     this->type = eventType;
66     this->storage = sData + " " + ToString(uiData);
67     }
68    
69 iliev 1108 LSCPEvent::LSCPEvent(event_t eventType, String sData, double dData) {
70     this->type = eventType;
71     this->storage = sData + " " + ToString(dData);
72     }
73    
74 senkov 170 LSCPEvent::LSCPEvent(event_t eventType, int uiData, String sData) {
75     this->type = eventType;
76     this->storage = ToString(uiData) + " " + sData;
77     }
78    
79 iliev 981 LSCPEvent::LSCPEvent(event_t eventType, int uiData1, int uiData2, int uiData3) {
80     this->type = eventType;
81     this->storage = ToString(uiData1) + " " + ToString(uiData2) + " " + ToString(uiData3);
82     }
83    
84 iliev 1161 LSCPEvent::LSCPEvent(event_t eventType, String sData1, String sData2, String sData3) {
85     this->type = eventType;
86     this->storage = sData1 + " " + sData2 + " " + sData3;
87     }
88    
89 senkov 170 //Produce event string
90     String LSCPEvent::Produce(void) {
91     String result = "NOTIFY:";
92     result += EventNames[type];
93     result += ":";
94     result += storage;
95 schoenebeck 552 result += "\r\n";
96 senkov 170 return result;
97     }
98    
99     //This can later return handle and then we can get rid of event_t enum
100     //and make events fully dynamic
101     void LSCPEvent::RegisterEvent(event_t eventType, String EventName) {
102     EventNames[eventType] = EventName;
103     }
104    
105     void LSCPEvent::UnregisterEvent(event_t eventType) {
106     EventNames.erase(eventType);
107     }
108    
109     //The following static method is used to get names from types
110     String LSCPEvent::Name(event_t eventType) {
111     if (EventNames.count(eventType))
112     return EventNames[eventType];
113     return "UNKNOWN";
114     }
115    
116     std::list<LSCPEvent::event_t> LSCPEvent::List( void ) {
117     std::list<event_t> result;
118     for (std::map<event_t, String>::iterator iter = EventNames.begin(); iter != EventNames.end(); iter++)
119     result.push_back(iter->first);
120     return result;
121     }
122    

  ViewVC Help
Powered by ViewVC