root/trunk/libffado/support/dbus/controlserver.cpp

Revision 1888, 25.9 kB (checked in by arnonym, 14 years ago)

Drop the libs in external/ and use the system-libs for that. Easier on administration, easier on compilation time, easier for packagers.

This is basically the patches provided by packagers in #290.

Line 
1 /*
2  * Copyright (C) 2005-2008 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "controlserver.h"
25 #include "libcontrol/Element.h"
26 #include "libcontrol/BasicElements.h"
27 #include "libcontrol/MatrixMixer.h"
28 #include "libcontrol/CrossbarRouter.h"
29 #include "libutil/Time.h"
30 #include "libutil/PosixMutex.h"
31
32 namespace DBusControl {
33
34 IMPL_DEBUG_MODULE( Element, Element, DEBUG_LEVEL_NORMAL );
35
36 // --- Element
37 Element::Element( DBus::Connection& connection, std::string p, Element* parent, Control::Element &slave)
38 : DBus::ObjectAdaptor(connection, p)
39 , m_Parent(parent)
40 , m_Slave(slave)
41 , m_UpdateLock( NULL )
42 {
43     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Element on '%s'\n",
44                  path().c_str() );
45     // allocate a lock
46     if(parent == NULL) {
47         m_UpdateLock = new Util::PosixMutex("CTLSVEL");
48     } else {
49         m_UpdateLock = NULL;
50     }
51     // set verbose level AFTER allocating the lock
52     setVerboseLevel(m_Slave.getVerboseLevel());
53 }
54
55 void Element::setVerboseLevel( const int32_t &i)
56 {
57     setDebugLevel(i);
58     m_Slave.setVerboseLevel(i);
59     if(m_UpdateLock) m_UpdateLock->setVerboseLevel(i);
60 }
61
62 int32_t Element::getVerboseLevel()
63 {
64     return getDebugLevel();
65 }
66
67 bool
68 Element::canChangeValue()
69 {
70     return m_Slave.canChangeValue();
71 }
72
73 void
74 Element::Lock()
75 {
76     if(m_Parent) {
77         m_Parent->Lock();
78     } else {
79         m_UpdateLock->Lock();
80     }
81 }
82
83 void
84 Element::Unlock()
85 {
86     if(m_Parent) {
87         m_Parent->Unlock();
88     } else {
89         m_UpdateLock->Unlock();
90     }
91 }
92
93 bool
94 Element::isLocked()
95 {
96     if(m_Parent) {
97         return m_Parent->isLocked();
98     } else {
99         return m_UpdateLock->isLocked();
100     }
101 }
102
103 Util::Mutex*
104 Element::getLock()
105 {
106     if(m_Parent) {
107         return m_Parent->getLock();
108     } else {
109         return m_UpdateLock;
110     }
111 }
112
113 uint64_t
114 Element::getId( )
115 {
116     return m_Slave.getId();
117 }
118
119 std::string
120 Element::getName( )
121 {
122     return std::string(m_Slave.getName());
123 }
124
125 std::string
126 Element::getLabel( )
127 {
128     return std::string(m_Slave.getLabel());
129 }
130
131 std::string
132 Element::getDescription( )
133 {
134     return std::string(m_Slave.getDescription());
135 }
136
137 // --- Container
138 Container::Container( DBus::Connection& connection, std::string p, Element* parent, Control::Container &slave)
139 : Element(connection, p, parent, slave)
140 , m_Slave(slave)
141 {
142     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Container on '%s'\n",
143                  path().c_str() );
144
145     setDebugLevel(slave.getVerboseLevel());
146
147     // register an update signal handler
148     m_updateFunctor = new MemberSignalFunctor1< Container*,
149                       void (Container::*)(int) >
150                       ( this, &Container::updated, (int)Control::Container::eS_Updated );
151     if(m_updateFunctor) {
152         if(!slave.addSignalHandler(m_updateFunctor)) {
153             debugWarning("Could not add update signal functor\n");
154         }
155     } else {
156         debugWarning("Could not create update signal functor\n");
157     }
158
159     // build the initial tree
160     m_Slave = slave;
161     updateTree();
162 }
163
164 Container::~Container() {
165     debugOutput( DEBUG_LEVEL_VERBOSE, "Deleting Container on '%s'\n",
166                  path().c_str() );
167
168     Destroyed(); //send dbus signal
169
170     if(m_updateFunctor) {
171         if(!m_Slave.remSignalHandler(m_updateFunctor)) {
172             debugWarning("Could not remove update signal functor\n");
173         }
174     }
175     delete m_updateFunctor;
176
177     for ( ElementVectorIterator it = m_Children.begin();
178       it != m_Children.end();
179       ++it )
180     {
181         delete (*it);
182     }
183 }
184
185 void
186 Container::setVerboseLevel( const int32_t & i)
187 {
188     Element::setVerboseLevel(i);
189     for ( ElementVectorIterator it = m_Children.begin();
190       it != m_Children.end();
191       ++it )
192     {
193         (*it)->setVerboseLevel(i);
194     }
195 }
196
197 int32_t
198 Container::getNbElements( ) {
199     return m_Slave.countElements();
200 }
201
202 std::string
203 Container::getElementName( const int32_t& i ) {
204     int nbElements=m_Slave.countElements();
205     if (i<nbElements) {
206         m_Slave.lockControl();
207         const Control::ElementVector elements = m_Slave.getElementVector();
208         Control::Element *e = elements.at(i);
209         std::string name;
210         if(e) name = e->getName();
211         m_Slave.unlockControl();
212         return name;
213     } else return "";
214 }
215 //     Util::MutexLockHelper lock(*m_access_lock);
216
217 // NOTE: call with tree locked
218 void
219 Container::updateTree()
220 {
221     bool something_changed = false;
222     debugOutput( DEBUG_LEVEL_VERBOSE, "Updating tree...\n");
223     // send a pre update signal
224     PreUpdate();
225     debugOutput( DEBUG_LEVEL_VERBOSE, "Add handlers for elements...\n");
226     // add handlers for the slaves that don't have one yet
227     const Control::ElementVector elements = m_Slave.getElementVector();
228     for ( Control::ConstElementVectorIterator it = elements.begin();
229       it != elements.end();
230       ++it )
231     {
232         Element *e = findElementForControl((*it));
233         if(e == NULL) { // element not in tree
234             e = createHandler(this, *(*it));
235             if (e) {
236                 e->setVerboseLevel(getDebugLevel());
237                 m_Children.push_back(e);
238                 debugOutput( DEBUG_LEVEL_VERBOSE, "Created handler %p for Control::Element %s...\n",
239                             e, (*it)->getName().c_str());
240                 something_changed = true;
241             } else {
242                 debugWarning("Failed to create handler for Control::Element %s\n",
243                     (*it)->getName().c_str());
244             }
245         } else {
246             // element already present
247             debugOutput( DEBUG_LEVEL_VERBOSE, "Already have handler (%p) for Control::Element %s...\n",
248                          e, (*it)->getName().c_str());
249         }
250     }
251
252     debugOutput( DEBUG_LEVEL_VERBOSE, "Remove handlers without element...\n");
253     std::vector<Element *> to_remove;
254     // remove handlers that don't have a slave anymore
255     for ( ElementVectorIterator it = m_Children.begin();
256       it != m_Children.end();
257       ++it )
258     {
259         Element *e = *it;
260         bool found = false;
261         for ( Control::ConstElementVectorIterator it2 = elements.begin();
262               it2 != elements.end();
263               ++it2 )
264         {
265             if(&(e)->m_Slave == *it2) {
266                 found = true;
267                 debugOutput( DEBUG_LEVEL_VERBOSE, "Slave for handler %p at %s is present: Control::Element %s...\n",
268                             e, e->path().c_str(), (*it)->getName().c_str());
269                 break;
270             }
271         }
272
273         if (!found) {
274             debugOutput(DEBUG_LEVEL_VERBOSE,
275                         "going to remove handler %p on path %s since slave is gone\n",
276                         e, e->path().c_str());
277             // can't remove while iterating
278             to_remove.push_back(e);
279             something_changed = true;
280         }
281     }
282     // do the actual remove
283     while(to_remove.size()) {
284         Element * e = *(to_remove.begin());
285         removeElement(e);
286         to_remove.erase(to_remove.begin());
287     }
288
289     if(something_changed) {
290         debugOutput(DEBUG_LEVEL_VERBOSE,
291                     "send dbus signal for path %s since something changed\n",
292                     path().c_str());
293         // send a dbus signal
294         Updated();
295     }
296     // send a post update signal
297     PostUpdate();
298 }
299
300 void
301 Container::removeElement(Element *e)
302 {
303     debugOutput(DEBUG_LEVEL_VERBOSE,
304                 "removing handler %p on path %s\n",
305                 e, path().c_str());
306     for ( ElementVectorIterator it = m_Children.begin();
307       it != m_Children.end();
308       ++it )
309     {
310         if(*it == e) {
311             m_Children.erase(it);
312             delete e;
313             return;
314         }
315     }
316     debugError("BUG: Element %p not found!\n", e);
317 }
318
319 // NOTE: call with access lock held!
320 Element *
321 Container::findElementForControl(Control::Element *e)
322 {
323     for ( ElementVectorIterator it = m_Children.begin();
324       it != m_Children.end();
325       ++it )
326     {
327         if(&(*it)->m_Slave == e) return (*it);
328     }
329     return NULL;
330 }
331
332 void
333 Container::updated(int new_nb_elements)
334 {
335     debugOutput( DEBUG_LEVEL_VERBOSE, "Got updated signal, new count='%d'\n",
336                  new_nb_elements );
337     // we lock the tree first
338     Lock();
339
340     // also lock the slave tree
341     m_Slave.lockControl();
342
343     // update our tree
344     updateTree();
345
346     // now unlock the slave tree
347     m_Slave.unlockControl();
348
349     // and unlock the access
350     Unlock();
351 }
352
353 /**
354  * \brief create a correct DBusControl counterpart for a given Control::Element
355  */
356 Element *
357 Container::createHandler(Element *parent, Control::Element& e) {
358     debugOutput( DEBUG_LEVEL_VERBOSE, "Creating handler for '%s'\n",
359                  e.getName().c_str() );
360     try {
361         if (dynamic_cast<Control::Container *>(&e) != NULL) {
362             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Container\n");
363            
364             return new Container(conn(), std::string(path()+"/"+e.getName()),
365                 parent, *dynamic_cast<Control::Container *>(&e));
366         }
367        
368         if (dynamic_cast<Control::Continuous *>(&e) != NULL) {
369             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Continuous\n");
370            
371             return new Continuous(conn(), std::string(path()+"/"+e.getName()),
372                 parent, *dynamic_cast<Control::Continuous *>(&e));
373         }
374        
375         if (dynamic_cast<Control::Discrete *>(&e) != NULL) {
376             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Discrete\n");
377            
378             return new Discrete(conn(), std::string(path()+"/"+e.getName()),
379                 parent, *dynamic_cast<Control::Discrete *>(&e));
380         }
381        
382         if (dynamic_cast<Control::Text *>(&e) != NULL) {
383             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Text\n");
384            
385             return new Text(conn(), std::string(path()+"/"+e.getName()),
386                 parent, *dynamic_cast<Control::Text *>(&e));
387         }
388    
389         if (dynamic_cast<Control::Register *>(&e) != NULL) {
390             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Register\n");
391            
392             return new Register(conn(), std::string(path()+"/"+e.getName()),
393                 parent, *dynamic_cast<Control::Register *>(&e));
394         }
395    
396         // note that we have to check this before checking the Enum,
397         // since Enum is a base class
398         if (dynamic_cast<Control::AttributeEnum *>(&e) != NULL) {
399             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::AttributeEnum\n");
400            
401             return new AttributeEnum(conn(), std::string(path()+"/"+e.getName()),
402                 parent, *dynamic_cast<Control::AttributeEnum *>(&e));
403         }
404        
405         if (dynamic_cast<Control::Enum *>(&e) != NULL) {
406             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Enum\n");
407            
408             return new Enum(conn(), std::string(path()+"/"+e.getName()),
409                 parent, *dynamic_cast<Control::Enum *>(&e));
410         }
411        
412         if (dynamic_cast<Control::Boolean *>(&e) != NULL) {
413             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Boolean\n");
414            
415             return new Boolean(conn(), std::string(path()+"/"+e.getName()),
416                 parent, *dynamic_cast<Control::Boolean *>(&e));
417         }
418        
419         if (dynamic_cast<ConfigRom *>(&e) != NULL) {
420             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a ConfigRom\n");
421            
422             return new ConfigRomX(conn(), std::string(path()+"/"+e.getName()),
423                 parent, *dynamic_cast<ConfigRom *>(&e));
424         }
425        
426         if (dynamic_cast<Control::MatrixMixer *>(&e) != NULL) {
427             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::MatrixMixer\n");
428            
429             return new MatrixMixer(conn(), std::string(path()+"/"+e.getName()),
430                 parent, *dynamic_cast<Control::MatrixMixer *>(&e));
431         }
432        
433         if (dynamic_cast<Control::CrossbarRouter *>(&e) != NULL) {
434             debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::CrossbarRouter\n");
435            
436             return new CrossbarRouter(conn(), std::string(path()+"/"+e.getName()),
437                 parent, *dynamic_cast<Control::CrossbarRouter *>(&e));
438         }
439        
440         debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Element\n");
441         return new Element(conn(), std::string(path()+"/"+e.getName()), parent, e);
442     } catch (...) {
443         debugWarning("Could not register %s\n", std::string(path()+"/"+e.getName()).c_str());
444         if(e.isControlLocked()) {
445             e.unlockControl();
446         }
447         if(isLocked()) {
448             Unlock();
449         }
450         return NULL;
451     };
452 }
453
454 // --- Continuous
455
456 Continuous::Continuous( DBus::Connection& connection, std::string p, Element* parent, Control::Continuous &slave)
457 : Element(connection, p, parent, slave)
458 , m_Slave(slave)
459 {
460     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Continuous on '%s'\n",
461                  path().c_str() );
462 }
463
464 double
465 Continuous::setValue( const double& value )
466 {
467     m_Slave.setValue(value);
468 /*   
469     SleepRelativeUsec(1000*500);
470    
471     debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%lf) => %lf\n", value, m_Slave.getValue() );
472    
473     return m_Slave.getValue();*/
474     return value;
475 }
476
477 double
478 Continuous::getValue(  )
479 {
480     double val = m_Slave.getValue();
481     debugOutput( DEBUG_LEVEL_VERBOSE, "getValue() => %lf\n", val );
482     return val;
483 }
484
485 double
486 Continuous::setValueIdx( const int32_t & idx, const double& value )
487 {
488     m_Slave.setValue(idx, value);
489 /*   
490     SleepRelativeUsec(1000*500);
491    
492     debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%lf) => %lf\n", value, m_Slave.getValue() );
493    
494     return m_Slave.getValue();*/
495     return value;
496 }
497
498 double
499 Continuous::getValueIdx( const int32_t & idx )
500 {
501     double val = m_Slave.getValue(idx);
502     debugOutput( DEBUG_LEVEL_VERBOSE, "getValue(%d) => %lf\n", idx, val );
503     return val;
504 }
505
506 double
507 Continuous::getMinimum()
508 {
509     double val = m_Slave.getMinimum();
510     debugOutput( DEBUG_LEVEL_VERBOSE, "getMinimum() => %lf\n", val );
511     return val;
512 }
513
514 double
515 Continuous::getMaximum()
516 {
517     double val = m_Slave.getMaximum();
518     debugOutput( DEBUG_LEVEL_VERBOSE, "getMaximum() => %lf\n", val );
519     return val;
520 }
521
522 // --- Discrete
523
524 Discrete::Discrete( DBus::Connection& connection, std::string p, Element* parent, Control::Discrete &slave)
525 : Element(connection, p, parent, slave)
526 , m_Slave(slave)
527 {
528     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Discrete on '%s'\n",
529                  path().c_str() );
530 }
531
532 int32_t
533 Discrete::setValue( const int32_t& value )
534 {
535     m_Slave.setValue(value);
536    
537 /*    SleepRelativeUsec(1000*500);
538     debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%d) => %d\n", value, m_Slave.getValue() );
539    
540     return m_Slave.getValue();*/
541     return value;
542 }
543
544 int32_t
545 Discrete::getValue()
546 {
547     int32_t val = m_Slave.getValue();
548     debugOutput( DEBUG_LEVEL_VERBOSE, "getValue() => %d\n", val );
549     return val;
550 }
551
552 int32_t
553 Discrete::setValueIdx( const int32_t& idx, const int32_t& value )
554 {
555     m_Slave.setValue(idx, value);
556    
557 /*    SleepRelativeUsec(1000*500);
558     debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%d) => %d\n", value, m_Slave.getValue() );
559    
560     return m_Slave.getValue();*/
561     return value;
562 }
563
564 int32_t
565 Discrete::getValueIdx( const int32_t& idx )
566 {
567     int32_t val = m_Slave.getValue(idx);
568     debugOutput( DEBUG_LEVEL_VERBOSE, "getValue(%d) => %d\n", idx, val );
569     return val;
570 }
571
572 // --- Text
573
574 Text::Text( DBus::Connection& connection, std::string p, Element* parent, Control::Text &slave)
575 : Element(connection, p, parent, slave)
576 , m_Slave(slave)
577 {
578     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Text on '%s'\n",
579                  path().c_str() );
580 }
581
582 std::string
583 Text::setValue( const std::string& value )
584 {
585     m_Slave.setValue(value);
586    
587 /*    SleepRelativeUsec(1000*500);
588     debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%d) => %d\n", value, m_Slave.getValue() );
589    
590     return m_Slave.getValue();*/
591     return value;
592 }
593
594 std::string
595 Text::getValue()
596 {
597     std::string val = m_Slave.getValue();
598     debugOutput( DEBUG_LEVEL_VERBOSE, "getValue() => %s\n", val.c_str() );
599     return val;
600 }
601
602 // --- Register
603
604 Register::Register( DBus::Connection& connection, std::string p, Element* parent, Control::Register &slave)
605 : Element(connection, p, parent, slave)
606 , m_Slave(slave)
607 {
608     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Register on '%s'\n",
609                  path().c_str() );
610 }
611
612 uint64_t
613 Register::setValue( const uint64_t& addr, const uint64_t& value )
614 {
615     m_Slave.setValue(addr, value);
616    
617 /*    SleepRelativeUsec(1000*500);
618     debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%d) => %d\n", value, m_Slave.getValue() );
619    
620     return m_Slave.getValue();*/
621     return value;
622 }
623
624 uint64_t
625 Register::getValue( const uint64_t& addr )
626 {
627     uint64_t val = m_Slave.getValue(addr);
628     debugOutput( DEBUG_LEVEL_VERBOSE, "getValue(%lld) => %lld\n", addr, val );
629     return val;
630 }
631
632 // --- Enum
633
634 Enum::Enum( DBus::Connection& connection, std::string p, Element* parent, Control::Enum &slave)
635 : Element(connection, p, parent, slave)
636 , m_Slave(slave)
637 {
638     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Enum on '%s'\n",
639                  path().c_str() );
640 }
641
642 int32_t
643 Enum::select( const int32_t& idx )
644 {
645     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "select(%d)\n", idx );
646     return  m_Slave.select(idx);
647 }
648
649 int32_t
650 Enum::selected()
651 {
652     int retval = m_Slave.selected();
653     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "selected() => %d\n", retval );
654     return retval;
655 }
656
657 int32_t
658 Enum::count()
659 {
660     int retval = m_Slave.count();
661     debugOutput( DEBUG_LEVEL_VERBOSE, "count() => %d\n", retval );
662     return retval;
663 }
664
665 std::string
666 Enum::getEnumLabel( const int32_t & idx )
667 {
668     std::string retval = m_Slave.getEnumLabel(idx);
669     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "getEnumLabel(%d) => %s\n", idx, retval.c_str() );
670     return retval;
671 }
672
673 // --- AttributeEnum
674 AttributeEnum::AttributeEnum( DBus::Connection& connection, std::string p, Element* parent, Control::AttributeEnum &slave)
675 : Element(connection, p, parent, slave)
676 , m_Slave(slave)
677 {
678     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Enum on '%s'\n",
679                  path().c_str() );
680 }
681
682 int32_t
683 AttributeEnum::select( const int32_t& idx )
684 {
685     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "select(%d)\n", idx );
686     return  m_Slave.select(idx);
687 }
688
689 int32_t
690 AttributeEnum::selected()
691 {
692     int retval = m_Slave.selected();
693     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "selected() => %d\n", retval );
694     return retval;
695 }
696
697 int32_t
698 AttributeEnum::count()
699 {
700     int retval = m_Slave.count();
701     debugOutput( DEBUG_LEVEL_VERBOSE, "count() => %d\n", retval );
702     return retval;
703 }
704
705 int32_t
706 AttributeEnum::attributeCount()
707 {
708     int retval = m_Slave.attributeCount();
709     debugOutput( DEBUG_LEVEL_VERBOSE, "attributeCount() => %d\n", retval );
710     return retval;
711 }
712
713 std::string
714 AttributeEnum::getEnumLabel( const int32_t & idx )
715 {
716     std::string retval = m_Slave.getEnumLabel(idx);
717     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "getEnumLabel(%d) => %s\n", idx, retval.c_str() );
718     return retval;
719 }
720
721 std::string
722 AttributeEnum::getAttributeValue( const int32_t & idx )
723 {
724     std::string retval = m_Slave.getAttributeValue(idx);
725     debugOutput( DEBUG_LEVEL_VERBOSE, "getAttributeValue(%d) => %s\n", idx, retval.c_str() );
726     return retval;
727 }
728
729 std::string
730 AttributeEnum::getAttributeName( const int32_t & idx )
731 {
732     std::string retval = m_Slave.getAttributeName(idx);
733     debugOutput( DEBUG_LEVEL_VERBOSE, "getAttributeName(%d) => %s\n", idx, retval.c_str() );
734     return retval;
735 }
736
737 // --- ConfigRom
738
739 ConfigRomX::ConfigRomX( DBus::Connection& connection, std::string p, Element* parent, ConfigRom &slave)
740 : Element(connection, p, parent, slave)
741 , m_Slave(slave)
742 {
743     debugOutput( DEBUG_LEVEL_VERBOSE, "Created ConfigRomX on '%s'\n",
744                  path().c_str() );
745 }
746
747 std::string
748 ConfigRomX::getGUID( )
749 {
750     return m_Slave.getGuidString();
751 }
752
753 std::string
754 ConfigRomX::getVendorName( )
755 {
756     return m_Slave.getVendorName();
757 }
758
759 std::string
760 ConfigRomX::getModelName( )
761 {
762     return m_Slave.getModelName();
763 }
764
765 int32_t
766 ConfigRomX::getVendorId( )
767 {
768     return m_Slave.getNodeVendorId();
769 }
770
771 int32_t
772 ConfigRomX::getModelId( )
773 {
774     return m_Slave.getModelId();
775 }
776
777 int32_t
778 ConfigRomX::getUnitVersion( )
779 {
780     return m_Slave.getUnitVersion();
781 }
782
783 // --- MatrixMixer
784
785 MatrixMixer::MatrixMixer( DBus::Connection& connection, std::string p, Element* parent, Control::MatrixMixer &slave)
786 : Element(connection, p, parent, slave)
787 , m_Slave(slave)
788 {
789     debugOutput( DEBUG_LEVEL_VERBOSE, "Created MatrixMixer on '%s'\n",
790                  path().c_str() );
791 }
792
793 int32_t
794 MatrixMixer::getRowCount( ) {
795     return m_Slave.getRowCount();
796 }
797
798 int32_t
799 MatrixMixer::getColCount( ) {
800     return m_Slave.getColCount();
801 }
802
803 int32_t
804 MatrixMixer::canWrite( const int32_t& row, const int32_t& col) {
805     return m_Slave.canWrite(row,col);
806 }
807
808 double
809 MatrixMixer::setValue( const int32_t& row, const int32_t& col, const double& val ) {
810     return m_Slave.setValue(row,col,val);
811 }
812
813 double
814 MatrixMixer::getValue( const int32_t& row, const int32_t& col) {
815     return m_Slave.getValue(row,col);
816 }
817
818 bool
819 MatrixMixer::hasNames() {
820     return m_Slave.hasNames();
821 }
822 std::string
823 MatrixMixer::getRowName( const int32_t& row) {
824     return m_Slave.getRowName(row);
825 }
826 std::string
827 MatrixMixer::getColName( const int32_t& col) {
828     return m_Slave.getColName(col);
829 }
830 bool
831 MatrixMixer::setRowName( const int32_t& row, const std::string& name) {
832     return m_Slave.setRowName(row, name);
833 }
834 bool
835 MatrixMixer::setColName( const int32_t& col, const std::string& name) {
836     return m_Slave.setColName(col, name);
837 }
838
839 bool
840 MatrixMixer::canConnect() {
841     return m_Slave.canConnect();
842 }
843 std::vector<std::string>
844 MatrixMixer::availableConnectionsForRow( const int32_t& row) {
845     return m_Slave.availableConnectionsForRow(row);
846 }
847 std::vector<std::string>
848 MatrixMixer::availableConnectionsForCol( const int32_t& col) {
849     return m_Slave.availableConnectionsForCol(col);
850 }
851 bool
852 MatrixMixer::connectRowTo( const int32_t& row, const std::string& target) {
853     return m_Slave.connectRowTo(row, target);
854 }
855 bool
856 MatrixMixer::connectColTo( const int32_t& col, const std::string& target) {
857     return m_Slave.connectColTo(col, target);
858 }
859
860 // --- CrossbarRouter
861
862 CrossbarRouter::CrossbarRouter( DBus::Connection& connection, std::string p, Element* parent, Control::CrossbarRouter &slave)
863 : Element(connection, p, parent, slave)
864 , m_Slave(slave)
865 {
866     debugOutput( DEBUG_LEVEL_VERBOSE, "Created CrossbarRouter on '%s'\n",
867                  path().c_str() );
868 }
869
870 /*int32_t
871 CrossbarRouter::getSourceIndex(const std::string &name)
872 {
873     return m_Slave.getSourceIndex(name);
874 }
875
876 int32_t
877 CrossbarRouter::getDestinationIndex(const std::string &name)
878 {
879     return m_Slave.getDestinationIndex(name);
880 }*/
881
882 std::vector< std::string >
883 CrossbarRouter::getSourceNames()
884 {
885     return m_Slave.getSourceNames();
886 }
887
888 std::vector< std::string >
889 CrossbarRouter::getDestinationNames()
890 {
891     return m_Slave.getDestinationNames();
892 }
893
894 std::vector< std::string >
895 CrossbarRouter::getDestinationsForSource(const std::string &idx)
896 {
897     return m_Slave.getDestinationsForSource(idx);
898 }
899
900 std::string
901 CrossbarRouter::getSourceForDestination(const std::string &idx)
902 {
903     return m_Slave.getSourceForDestination(idx);
904 }
905
906 bool
907 CrossbarRouter::canConnect(const std::string &source, const std::string &dest)
908 {
909     return m_Slave.canConnect(source, dest);
910 }
911
912 bool
913 CrossbarRouter::setConnectionState(const std::string &source, const std::string &dest, const bool &enable)
914 {
915     return m_Slave.setConnectionState(source, dest, enable);
916 }
917
918 bool
919 CrossbarRouter::getConnectionState(const std::string &source, const std::string &dest)
920 {
921     return m_Slave.getConnectionState(source, dest);
922 }
923
924 bool
925 CrossbarRouter::clearAllConnections()
926 {
927     return m_Slave.clearAllConnections();
928 }
929
930 bool
931 CrossbarRouter::hasPeakMetering()
932 {
933     return m_Slave.hasPeakMetering();
934 }
935
936 double
937 CrossbarRouter::getPeakValue(const std::string &dest)
938 {
939     return m_Slave.getPeakValue(dest);
940 }
941 std::vector< DBus::Struct<std::string, double> >
942 CrossbarRouter::getPeakValues()
943 {
944     std::map<std::string, double> peakvalues = m_Slave.getPeakValues();
945     std::vector< DBus::Struct<std::string, double> > ret;
946     for (std::map<std::string, double>::iterator it=peakvalues.begin(); it!=peakvalues.end(); ++it) {
947         DBus::Struct<std::string, double> tmp;
948         tmp._1 = it->first;
949         tmp._2 = it->second;
950         ret.push_back(tmp);
951     }
952     return ret;
953     /*std::vector< DBus::Struct<int, double> > out;
954     Control::CrossbarRouter::PeakValues values = m_Slave.getPeakValues();
955     for ( unsigned int i=0; i<values.size(); ++i ) {
956         DBus::Struct<int, double> tmp;
957         tmp._1 = values[i].destination;
958         tmp._2 = values[i].peakvalue;
959         out.push_back(tmp);
960     }
961     return out;*/
962 }
963
964 // --- Boolean
965
966 Boolean::Boolean( DBus::Connection& connection, std::string p, Element* parent, Control::Boolean &slave)
967 : Element(connection, p, parent, slave)
968 , m_Slave(slave)
969 {
970     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Boolean on '%s'\n",
971                  path().c_str() );
972 }
973
974 bool
975 Boolean::select( const bool& value )
976 {
977     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "select(%d)\n", value );
978     return  m_Slave.select(value);
979 }
980
981 bool
982 Boolean::selected()
983 {
984     bool retval = m_Slave.selected();
985     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "selected() => %d\n", retval );
986     return retval;
987 }
988
989 std::string
990 Boolean::getBooleanLabel( const bool& value )
991 {
992     std::string retval = m_Slave.getBooleanLabel(value);
993     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "getBooleanLabel(%d) => %s\n", value, retval.c_str() );
994     return retval;
995 }
996
997
998 } // end of namespace Control
Note: See TracBrowser for help on using the browser.