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

Revision 2803, 26.0 kB (checked in by jwoithe, 3 years ago)

Cosmetic: capitalise "L" in "Linux".

"Linux" is a proper noun so it should start with a capital letter. These
changes are almost all within comments.

This patch was originally proposed by pander on the ffado-devel mailing
list. It has been expanded to cover all similar cases to maintain
consistency throughout the source tree.

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(%" PRId64 ") => %" PRId64 "\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 bool
674 Enum::devConfigChanged(const int32_t& idx)
675 {
676     return m_Slave.devConfigChanged( idx );
677 }
678
679 // --- AttributeEnum
680 AttributeEnum::AttributeEnum( DBus::Connection& connection, std::string p, Element* parent, Control::AttributeEnum &slave)
681 : Element(connection, p, parent, slave)
682 , m_Slave(slave)
683 {
684     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Enum on '%s'\n",
685                  path().c_str() );
686 }
687
688 int32_t
689 AttributeEnum::select( const int32_t& idx )
690 {
691     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "select(%d)\n", idx );
692     return  m_Slave.select(idx);
693 }
694
695 int32_t
696 AttributeEnum::selected()
697 {
698     int retval = m_Slave.selected();
699     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "selected() => %d\n", retval );
700     return retval;
701 }
702
703 int32_t
704 AttributeEnum::count()
705 {
706     int retval = m_Slave.count();
707     debugOutput( DEBUG_LEVEL_VERBOSE, "count() => %d\n", retval );
708     return retval;
709 }
710
711 int32_t
712 AttributeEnum::attributeCount()
713 {
714     int retval = m_Slave.attributeCount();
715     debugOutput( DEBUG_LEVEL_VERBOSE, "attributeCount() => %d\n", retval );
716     return retval;
717 }
718
719 std::string
720 AttributeEnum::getEnumLabel( const int32_t & idx )
721 {
722     std::string retval = m_Slave.getEnumLabel(idx);
723     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "getEnumLabel(%d) => %s\n", idx, retval.c_str() );
724     return retval;
725 }
726
727 std::string
728 AttributeEnum::getAttributeValue( const int32_t & idx )
729 {
730     std::string retval = m_Slave.getAttributeValue(idx);
731     debugOutput( DEBUG_LEVEL_VERBOSE, "getAttributeValue(%d) => %s\n", idx, retval.c_str() );
732     return retval;
733 }
734
735 std::string
736 AttributeEnum::getAttributeName( const int32_t & idx )
737 {
738     std::string retval = m_Slave.getAttributeName(idx);
739     debugOutput( DEBUG_LEVEL_VERBOSE, "getAttributeName(%d) => %s\n", idx, retval.c_str() );
740     return retval;
741 }
742
743 // --- ConfigRom
744
745 ConfigRomX::ConfigRomX( DBus::Connection& connection, std::string p, Element* parent, ConfigRom &slave)
746 : Element(connection, p, parent, slave)
747 , m_Slave(slave)
748 {
749     debugOutput( DEBUG_LEVEL_VERBOSE, "Created ConfigRomX on '%s'\n",
750                  path().c_str() );
751 }
752
753 std::string
754 ConfigRomX::getGUID( )
755 {
756     return m_Slave.getGuidString();
757 }
758
759 std::string
760 ConfigRomX::getVendorName( )
761 {
762     return m_Slave.getVendorName();
763 }
764
765 std::string
766 ConfigRomX::getModelName( )
767 {
768     return m_Slave.getModelName();
769 }
770
771 int32_t
772 ConfigRomX::getVendorId( )
773 {
774     return m_Slave.getNodeVendorId();
775 }
776
777 int32_t
778 ConfigRomX::getModelId( )
779 {
780     return m_Slave.getModelId();
781 }
782
783 int32_t
784 ConfigRomX::getUnitVersion( )
785 {
786     return m_Slave.getUnitVersion();
787 }
788
789 // --- MatrixMixer
790
791 MatrixMixer::MatrixMixer( DBus::Connection& connection, std::string p, Element* parent, Control::MatrixMixer &slave)
792 : Element(connection, p, parent, slave)
793 , m_Slave(slave)
794 {
795     debugOutput( DEBUG_LEVEL_VERBOSE, "Created MatrixMixer on '%s'\n",
796                  path().c_str() );
797 }
798
799 int32_t
800 MatrixMixer::getRowCount( ) {
801     return m_Slave.getRowCount();
802 }
803
804 int32_t
805 MatrixMixer::getColCount( ) {
806     return m_Slave.getColCount();
807 }
808
809 int32_t
810 MatrixMixer::canWrite( const int32_t& row, const int32_t& col) {
811     return m_Slave.canWrite(row,col);
812 }
813
814 double
815 MatrixMixer::setValue( const int32_t& row, const int32_t& col, const double& val ) {
816     return m_Slave.setValue(row,col,val);
817 }
818
819 double
820 MatrixMixer::getValue( const int32_t& row, const int32_t& col) {
821     return m_Slave.getValue(row,col);
822 }
823
824 bool
825 MatrixMixer::hasNames() {
826     return m_Slave.hasNames();
827 }
828 std::string
829 MatrixMixer::getRowName( const int32_t& row) {
830     return m_Slave.getRowName(row);
831 }
832 std::string
833 MatrixMixer::getColName( const int32_t& col) {
834     return m_Slave.getColName(col);
835 }
836 bool
837 MatrixMixer::setRowName( const int32_t& row, const std::string& name) {
838     return m_Slave.setRowName(row, name);
839 }
840 bool
841 MatrixMixer::setColName( const int32_t& col, const std::string& name) {
842     return m_Slave.setColName(col, name);
843 }
844
845 bool
846 MatrixMixer::canConnect() {
847     return m_Slave.canConnect();
848 }
849 std::vector<std::string>
850 MatrixMixer::availableConnectionsForRow( const int32_t& row) {
851     return m_Slave.availableConnectionsForRow(row);
852 }
853 std::vector<std::string>
854 MatrixMixer::availableConnectionsForCol( const int32_t& col) {
855     return m_Slave.availableConnectionsForCol(col);
856 }
857 bool
858 MatrixMixer::connectRowTo( const int32_t& row, const std::string& target) {
859     return m_Slave.connectRowTo(row, target);
860 }
861 bool
862 MatrixMixer::connectColTo( const int32_t& col, const std::string& target) {
863     return m_Slave.connectColTo(col, target);
864 }
865
866 // --- CrossbarRouter
867
868 CrossbarRouter::CrossbarRouter( DBus::Connection& connection, std::string p, Element* parent, Control::CrossbarRouter &slave)
869 : Element(connection, p, parent, slave)
870 , m_Slave(slave)
871 {
872     debugOutput( DEBUG_LEVEL_VERBOSE, "Created CrossbarRouter on '%s'\n",
873                  path().c_str() );
874 }
875
876 /*int32_t
877 CrossbarRouter::getSourceIndex(const std::string &name)
878 {
879     return m_Slave.getSourceIndex(name);
880 }
881
882 int32_t
883 CrossbarRouter::getDestinationIndex(const std::string &name)
884 {
885     return m_Slave.getDestinationIndex(name);
886 }*/
887
888 std::vector< std::string >
889 CrossbarRouter::getSourceNames()
890 {
891     return m_Slave.getSourceNames();
892 }
893
894 std::vector< std::string >
895 CrossbarRouter::getDestinationNames()
896 {
897     return m_Slave.getDestinationNames();
898 }
899
900 std::vector< std::string >
901 CrossbarRouter::getDestinationsForSource(const std::string &idx)
902 {
903     return m_Slave.getDestinationsForSource(idx);
904 }
905
906 std::string
907 CrossbarRouter::getSourceForDestination(const std::string &idx)
908 {
909     return m_Slave.getSourceForDestination(idx);
910 }
911
912 bool
913 CrossbarRouter::canConnect(const std::string &source, const std::string &dest)
914 {
915     return m_Slave.canConnect(source, dest);
916 }
917
918 bool
919 CrossbarRouter::setConnectionState(const std::string &source, const std::string &dest, const bool &enable)
920 {
921     return m_Slave.setConnectionState(source, dest, enable);
922 }
923
924 bool
925 CrossbarRouter::getConnectionState(const std::string &source, const std::string &dest)
926 {
927     return m_Slave.getConnectionState(source, dest);
928 }
929
930 bool
931 CrossbarRouter::clearAllConnections()
932 {
933     return m_Slave.clearAllConnections();
934 }
935
936 bool
937 CrossbarRouter::hasPeakMetering()
938 {
939     return m_Slave.hasPeakMetering();
940 }
941
942 double
943 CrossbarRouter::getPeakValue(const std::string &dest)
944 {
945     return m_Slave.getPeakValue(dest);
946 }
947 std::vector< DBus::Struct<std::string, double> >
948 CrossbarRouter::getPeakValues()
949 {
950     std::map<std::string, double> peakvalues = m_Slave.getPeakValues();
951     std::vector< DBus::Struct<std::string, double> > ret;
952     for (std::map<std::string, double>::iterator it=peakvalues.begin(); it!=peakvalues.end(); ++it) {
953         DBus::Struct<std::string, double> tmp;
954         tmp._1 = it->first;
955         tmp._2 = it->second;
956         ret.push_back(tmp);
957     }
958     return ret;
959     /*std::vector< DBus::Struct<int, double> > out;
960     Control::CrossbarRouter::PeakValues values = m_Slave.getPeakValues();
961     for ( unsigned int i=0; i<values.size(); ++i ) {
962         DBus::Struct<int, double> tmp;
963         tmp._1 = values[i].destination;
964         tmp._2 = values[i].peakvalue;
965         out.push_back(tmp);
966     }
967     return out;*/
968 }
969
970 // --- Boolean
971
972 Boolean::Boolean( DBus::Connection& connection, std::string p, Element* parent, Control::Boolean &slave)
973 : Element(connection, p, parent, slave)
974 , m_Slave(slave)
975 {
976     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Boolean on '%s'\n",
977                  path().c_str() );
978 }
979
980 bool
981 Boolean::select( const bool& value )
982 {
983     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "select(%d)\n", value );
984     return  m_Slave.select(value);
985 }
986
987 bool
988 Boolean::selected()
989 {
990     bool retval = m_Slave.selected();
991     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "selected() => %d\n", retval );
992     return retval;
993 }
994
995 std::string
996 Boolean::getBooleanLabel( const bool& value )
997 {
998     std::string retval = m_Slave.getBooleanLabel(value);
999     debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "getBooleanLabel(%d) => %s\n", value, retval.c_str() );
1000     return retval;
1001 }
1002
1003
1004 } // end of namespace Control
Note: See TracBrowser for help on using the browser.