drumstick  1.1.0
subscription.cpp
Go to the documentation of this file.
1 /*
2  MIDI Sequencer C++ library
3  Copyright (C) 2006-2016, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4 
5  This library is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 
20 #include "alsaclient.h"
21 
27 namespace drumstick {
28 
54 {
55  snd_seq_query_subscribe_malloc(&m_Info);
56 }
57 
63 {
64  snd_seq_query_subscribe_malloc(&m_Info);
65  snd_seq_query_subscribe_copy(m_Info, other.m_Info);
66 }
67 
72 Subscriber::Subscriber(snd_seq_query_subscribe_t* other)
73 {
74  snd_seq_query_subscribe_malloc(&m_Info);
75  snd_seq_query_subscribe_copy(m_Info, other);
76 }
77 
82 {
83  snd_seq_query_subscribe_free(m_Info);
84 }
85 
91 {
92  return new Subscriber(m_Info);
93 }
94 
101 {
102  snd_seq_query_subscribe_copy(m_Info, other.m_Info);
103  return *this;
104 }
105 
110 int
112 {
113  return snd_seq_query_subscribe_get_client(m_Info);
114 }
115 
120 int
122 {
123  return snd_seq_query_subscribe_get_port(m_Info);
124 }
125 
130 const snd_seq_addr_t*
132 {
133  return snd_seq_query_subscribe_get_root(m_Info);
134 }
135 
144 snd_seq_query_subs_type_t
146 {
147  return snd_seq_query_subscribe_get_type(m_Info);
148 }
149 
154 int
156 {
157  return snd_seq_query_subscribe_get_index(m_Info);
158 }
159 
164 int
166 {
167  return snd_seq_query_subscribe_get_num_subs(m_Info);
168 }
169 
174 const snd_seq_addr_t*
176 {
177  return snd_seq_query_subscribe_get_addr(m_Info);
178 }
179 
184 int
186 {
187  return snd_seq_query_subscribe_get_queue(m_Info);
188 }
189 
194 bool
196 {
197  return (snd_seq_query_subscribe_get_exclusive(m_Info) != 0);
198 }
199 
204 bool
206 {
207  return (snd_seq_query_subscribe_get_time_update(m_Info) != 0);
208 }
209 
214 bool
216 {
217  return (snd_seq_query_subscribe_get_time_real(m_Info) != 0);
218 }
219 
224 void
226 {
227  snd_seq_query_subscribe_set_client(m_Info, client);
228 }
229 
234 void
236 {
237  snd_seq_query_subscribe_set_port(m_Info, port);
238 }
239 
244 void
245 Subscriber::setRoot(snd_seq_addr_t* addr)
246 {
247  snd_seq_query_subscribe_set_root(m_Info, addr);
248 }
249 
258 void
259 Subscriber::setType(snd_seq_query_subs_type_t type)
260 {
261  snd_seq_query_subscribe_set_type(m_Info, type);
262 }
263 
268 void
270 {
271  snd_seq_query_subscribe_set_index(m_Info, index);
272 }
273 
278 int
280 {
281  return snd_seq_query_subscribe_sizeof();
282 }
283 
288 {
289  snd_seq_port_subscribe_malloc(&m_Info);
290 }
291 
297 {
298  snd_seq_port_subscribe_malloc(&m_Info);
299  snd_seq_port_subscribe_copy(m_Info, other.m_Info);
300 }
301 
306 Subscription::Subscription(snd_seq_port_subscribe_t* other)
307 {
308  snd_seq_port_subscribe_malloc(&m_Info);
309  snd_seq_port_subscribe_copy(m_Info, other);
310 }
311 
317 {
318  snd_seq_port_subscribe_malloc(&m_Info);
319  CHECK_WARNING(snd_seq_get_port_subscription(seq->getHandle(), m_Info));
320 }
321 
327 {
328  snd_seq_port_subscribe_free(m_Info);
329 }
330 
337 {
338  return new Subscription(m_Info);
339 }
340 
348 {
349  snd_seq_port_subscribe_copy(m_Info, other.m_Info);
350  return *this;
351 }
352 
357 const snd_seq_addr_t*
359 {
360  return snd_seq_port_subscribe_get_sender(m_Info);
361 }
362 
367 const snd_seq_addr_t*
369 {
370  return snd_seq_port_subscribe_get_dest(m_Info);
371 }
372 
377 int
379 {
380  return snd_seq_port_subscribe_get_queue(m_Info);
381 }
382 
387 bool
389 {
390  return (snd_seq_port_subscribe_get_exclusive(m_Info) != 0);
391 }
392 
397 bool
399 {
400  return (snd_seq_port_subscribe_get_time_update(m_Info) != 0);
401 }
402 
407 bool
409 {
410  return (snd_seq_port_subscribe_get_time_real(m_Info) != 0);
411 }
412 
417 void
418 Subscription::setSender(const snd_seq_addr_t* addr)
419 {
420  snd_seq_port_subscribe_set_sender(m_Info, addr);
421 }
422 
427 void
428 Subscription::setDest(const snd_seq_addr_t* addr)
429 {
430  snd_seq_port_subscribe_set_dest(m_Info, addr);
431 }
432 
437 void
439 {
440  snd_seq_port_subscribe_set_queue(m_Info, q);
441 }
442 
447 void
449 {
450  snd_seq_port_subscribe_set_exclusive(m_Info, val?1:0);
451 }
452 
457 void
459 {
460  snd_seq_port_subscribe_set_time_update(m_Info, val?1:0);
461 }
462 
467 void
469 {
470  snd_seq_port_subscribe_set_time_real(m_Info, val?1:0);
471 }
472 
478 void
479 Subscription::setSender(unsigned char client, unsigned char port)
480 {
481  snd_seq_addr_t addr;
482  addr.client = client;
483  addr.port = port;
484  setSender(&addr);
485 }
486 
492 void
493 Subscription::setDest(unsigned char client, unsigned char port)
494 {
495  snd_seq_addr_t addr;
496  addr.client = client;
497  addr.port = port;
498  setDest(&addr);
499 }
500 
507 void
509 {
510  if ((m_Info == NULL) || (seq == NULL) || !(seq->isOpened()))
511  {
512  return;
513  }
514  CHECK_WARNING(snd_seq_subscribe_port(seq->getHandle(), m_Info));
515 }
516 
523 void
525 {
526  if ((m_Info == NULL) || (seq == NULL) || !(seq->isOpened()))
527  {
528  return;
529  }
530  CHECK_WARNING(snd_seq_unsubscribe_port(seq->getHandle(), m_Info));
531 }
532 
537 int
539 {
540  return snd_seq_port_subscribe_sizeof();
541 }
542 
543 } /* namespace drumstick */
544