Changeset 575
- Timestamp:
- 08/27/07 14:26:33 (15 years ago)
- Files:
-
- trunk/libffado/external/dbus/src/introspection.cpp (modified) (1 diff)
- trunk/libffado/src/debugmodule/debugmodule.h (modified) (1 diff)
- trunk/libffado/src/libcontrol/BasicElements.cpp (added)
- trunk/libffado/src/libcontrol/BasicElements.h (added)
- trunk/libffado/src/libcontrol/Element.cpp (added)
- trunk/libffado/src/libcontrol/Element.h (added)
- trunk/libffado/src/SConscript (modified) (1 diff)
- trunk/libffado/tests/controlclient.cpp (modified) (1 diff)
- trunk/libffado/tests/controlclient.h (modified) (2 diffs)
- trunk/libffado/tests/controlserver.cpp (modified) (1 diff)
- trunk/libffado/tests/controlserver.h (modified) (1 diff)
- trunk/libffado/tests/SConscript (modified) (1 diff)
- trunk/libffado/tests/test-dbus-server.cpp (modified) (2 diffs)
- trunk/libffado/tests/test-dbus.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/external/dbus/src/introspection.cpp
r562 r575 115 115 ObjectAdaptorPList::const_iterator oci; 116 116 117 debug_log("nb children: %d", children.size()); 117 118 for(oci = children.begin(); oci != children.end(); ++oci) 118 119 { 120 119 121 std::string name = (*oci)->path().substr(path.length()+1); 120 name.substr(name.find('/')); 121 122 123 std::string::size_type loc = name.find('/'); 124 if( loc != std::string::npos ) { 125 name.substr(loc); 126 } 127 122 128 xml << "<node name=\"" << name << "\"/>"; 123 129 } trunk/libffado/src/debugmodule/debugmodule.h
r555 r575 27 27 28 28 #include "../fbtypes.h" 29 29 #include <assert.h> 30 30 31 31 #include <vector> trunk/libffado/src/SConscript
r573 r575 68 68 libutil/TimeSource.cpp \ 69 69 libutil/TimestampedBuffer.cpp \ 70 libcontrol/Element.cpp \ 71 libcontrol/BasicElements.cpp \ 70 72 ' ) 71 73 trunk/libffado/tests/controlclient.cpp
r574 r575 25 25 #include "controlclient.h" 26 26 27 namespace Control {27 namespace DBusControl { 28 28 29 IMPL_DEBUG_MODULE( ControlClient, ControlClient, DEBUG_LEVEL_VERBOSE ); 29 // --- 30 30 31 ControlClient::ControlClient( DBus::Connection& connection, const char* path, const char* name ) 31 IMPL_DEBUG_MODULE( ContignousClient, ContignousClient, DEBUG_LEVEL_VERBOSE ); 32 33 ContignousClient::ContignousClient( DBus::Connection& connection, const char* path, const char* name ) 32 34 : DBus::ObjectProxy(connection, path, name) 33 35 { 34 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Cont rolClient '%s' on '%s'\n",36 debugOutput( DEBUG_LEVEL_VERBOSE, "Created ContignousClient '%s' on '%s'\n", 35 37 name, path ); 36 38 } trunk/libffado/tests/controlclient.h
r574 r575 32 32 #include "controlclient-glue.h" 33 33 34 static const char* SERVER_NAME = "org.ffado.Control .Test";35 static const char* SERVER_PATH = "/org/ffado/Control/Test ";34 static const char* SERVER_NAME = "org.ffado.Control"; 35 static const char* SERVER_PATH = "/org/ffado/Control/Test/Fader"; 36 36 37 namespace Control {37 namespace DBusControl { 38 38 39 class ControlClient 40 : public org::ffado::Control::Test, 39 // simple fader element 40 class ContignousClient 41 : public org::ffado::Control::Element::Fader, 41 42 public DBus::IntrospectableProxy, 42 43 public DBus::ObjectProxy … … 44 45 public: 45 46 46 Cont rolClient( DBus::Connection& connection, const char* path, const char* name );47 ContignousClient( DBus::Connection& connection, const char* path, const char* name ); 47 48 48 49 private: trunk/libffado/tests/controlserver.cpp
r574 r575 24 24 25 25 #include "controlserver.h" 26 #include "libcontrol/Element.h" 27 #include "libcontrol/BasicElements.h" 26 28 27 namespace Control {29 namespace DBusControl { 28 30 29 IMPL_DEBUG_MODULE( ControlServer, ControlServer, DEBUG_LEVEL_VERBOSE );31 IMPL_DEBUG_MODULE( Element, Element, DEBUG_LEVEL_VERBOSE ); 30 32 31 ControlServer::ControlServer( DBus::Connection& connection ) 32 : DBus::ObjectAdaptor(connection, SERVER_PATH) 33 // --- Element 34 Element::Element( DBus::Connection& connection, std::string p, Control::Element &slave) 35 : DBus::ObjectAdaptor(connection, p) 36 , m_Slave(slave) 33 37 { 34 debugOutput( DEBUG_LEVEL_VERBOSE, "Created ControlServeron '%s'\n",35 SERVER_PATH);38 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Element on '%s'\n", 39 path().c_str() ); 36 40 } 37 41 38 DBus::Int32 ControlServer::Echo( const DBus::Int32& value ) 42 DBus::UInt64 43 Element::getId( ) 39 44 { 40 debugOutput( DEBUG_LEVEL_VERBOSE, "Echo(%d)\n", value ); 41 return value; 45 return m_Slave.getId(); 42 46 } 43 47 44 std::map< DBus::String, DBus::String > ControlServer::Info() 48 DBus::String 49 Element::getName( ) 45 50 { 46 debugOutput( DEBUG_LEVEL_VERBOSE, "Info()\n" ); 47 48 std::map< DBus::String, DBus::String > info; 49 50 info["testset1"] = "set1"; 51 info["testset2"] = "set2"; 52 53 return info; 51 return DBus::String(m_Slave.getName()); 54 52 } 55 53 54 // --- Container 55 Container::Container( DBus::Connection& connection, std::string p, Control::Container &slave) 56 : Element(connection, p, slave) 57 , m_Slave(slave) 58 { 59 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Container on '%s'\n", 60 path().c_str() ); 61 62 // add children for the slave container 63 for ( Control::ConstElementVectorIterator it = slave.getElements().begin(); 64 it != slave.getElements().end(); 65 ++it ) 66 { 67 Element *e=createHandler(*(*it)); 68 if (e) { 69 m_Children.push_back(e); 70 } else { 71 debugWarning("Failed to create handler for Control::Element %s\n", 72 (*it)->getName().c_str()); 73 } 74 } 75 } 76 77 Container::~Container() { 78 for ( ElementVectorIterator it = m_Children.begin(); 79 it != m_Children.end(); 80 ++it ) 81 { 82 delete (*it); 83 } 84 } 85 86 /** 87 * \brief create a correct DBusControl counterpart for a given Control::Element 88 */ 89 Element * 90 Container::createHandler(Control::Element& e) { 91 debugOutput( DEBUG_LEVEL_VERBOSE, "Creating handler for '%s'\n", 92 e.getName().c_str() ); 93 94 if (dynamic_cast<Control::Container *>(&e) != NULL) { 95 debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Container\n"); 96 97 return new Container(conn(), std::string(path()+"/"+e.getName()), 98 *dynamic_cast<Control::Container *>(&e)); 99 } 100 if (dynamic_cast<Control::Contignous *>(&e) != NULL) { 101 debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Contignous\n"); 102 103 return new Contignous(conn(), std::string(path()+"/"+e.getName()), 104 *dynamic_cast<Control::Contignous *>(&e)); 105 } 106 debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Element\n"); 107 return new Element(conn(), std::string(path()+"/"+e.getName()), e); 108 } 109 110 // --- Contignous 111 112 Contignous::Contignous( DBus::Connection& connection, std::string p, Control::Contignous &slave) 113 : Element(connection, p, slave) 114 , m_Slave(slave) 115 { 116 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Contignous on '%s'\n", 117 path().c_str() ); 118 } 119 120 DBus::Double 121 Contignous::setValue( const DBus::Double& value ) 122 { 123 m_Slave.setValue(value); 124 debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%lf) => %lf\n", value, m_Slave.getValue() ); 125 126 return m_Slave.getValue(); 127 } 128 129 DBus::Double 130 Contignous::getValue( ) 131 { 132 debugOutput( DEBUG_LEVEL_VERBOSE, "getValue() => %lf\n", m_Slave.getValue() ); 133 return m_Slave.getValue(); 134 } 56 135 57 136 } // end of namespace Control trunk/libffado/tests/controlserver.h
r574 r575 32 32 #include "controlserver-glue.h" 33 33 34 static const char* SERVER_NAME = "org.ffado.Control.Test"; 35 static const char* SERVER_PATH = "/org/ffado/Control/Test"; 34 #include "libcontrol/BasicElements.h" 36 35 37 namespace Control {36 namespace DBusControl { 38 37 39 class Element { 40 public: 41 Element() {}; 42 }; 43 44 class ControlServer 45 : public org::ffado::Control::Test, 46 public DBus::IntrospectableAdaptor, 47 public DBus::ObjectAdaptor 38 class Element 39 : public org::ffado::Control::Element::Element 40 , public DBus::IntrospectableAdaptor 41 , public DBus::ObjectAdaptor 48 42 { 49 43 public: 50 44 51 ControlServer( DBus::Connection& connection ); 52 53 DBus::Int32 Echo( const DBus::Int32 & value ); 54 std::map< DBus::String, DBus::String > Info(); 45 Element( DBus::Connection& connection, 46 std::string p, 47 Control::Element &slave ); 48 49 DBus::UInt64 getId( ); 50 DBus::String getName( ); 55 51 56 52 private: 53 Control::Element &m_Slave; 54 55 protected: 57 56 DECLARE_DEBUG_MODULE; 57 }; 58 typedef std::vector<Element *> ElementVector; 59 typedef std::vector<Element *>::iterator ElementVectorIterator; 60 typedef std::vector<Element *>::const_iterator ConstElementVectorIterator; 61 62 class Container 63 : public org::ffado::Control::Element::Container 64 , public Element 65 { 66 public: 67 Container( DBus::Connection& connection, 68 std::string p, 69 Control::Container &slave ); 70 virtual ~Container(); 71 72 Element *createHandler(Control::Element& e); 73 private: 74 Control::Container &m_Slave; 75 ElementVector m_Children; 76 }; 77 78 class Contignous 79 : public org::ffado::Control::Element::Fader 80 , public Element 81 { 82 public: 83 Contignous( DBus::Connection& connection, 84 std::string p, 85 Control::Contignous &slave ); 86 87 DBus::Double setValue( const DBus::Double & value ); 88 DBus::Double getValue( ); 89 90 private: 91 Control::Contignous &m_Slave; 58 92 }; 59 93 trunk/libffado/tests/SConscript
r574 r575 15 15 # 16 16 #for app in ["test-ffado", "test-extplugcmd", "test-fw410", "test-volume", "test-mixer", "test-cycletimer", "test-timestampedbuffer", "test-ieee1394service", "test-streamdump"]: 17 17 18 for app in ["test-ffado", "test-fw410", "test-cycletimer", "test-timestampedbuffer", "test-ieee1394service", "test-streamdump"]: 18 19 env.Program( target=app, source = app+".cpp" ) trunk/libffado/tests/test-dbus-server.cpp
r574 r575 99 99 } 100 100 101 static const char* SERVER_NAME = "org.ffado.Control"; 102 101 103 void start_server() { 102 104 … … 106 108 DBus::Connection conn = DBus::Connection::SessionBus(); 107 109 conn.request_name(SERVER_NAME); 110 111 Control::Contignous c0("test0"); 112 c0.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 113 DBusControl::Contignous fader(conn, "/org/ffado/Control/Test/Fader", c0); 108 114 109 Control::ControlServer server(conn); 115 Control::Container cont("container1"); 116 cont.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 117 118 Control::Container cont1("container2"); 119 cont1.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 120 121 cont.addElement(&cont1); 122 123 Control::Contignous c1("test1"); 124 c1.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 125 cont.addElement(&c1); 126 127 Control::Contignous c2("test2"); 128 c2.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 129 cont.addElement(&c2); 130 131 Control::Contignous c3("test3"); 132 c3.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 133 cont.addElement(&c3); 134 135 Control::Contignous c4("test4"); 136 c4.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 137 cont1.addElement(&c4); 138 139 Control::Contignous c5("test5"); 140 c5.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 141 cont1.addElement(&c5); 142 143 // Note: create handlers AFTER all children are added 144 145 // we do dynamic allocation such that we are sure 146 // the container is deleted before the children become invalid 147 DBusControl::Container *container 148 = new DBusControl::Container(conn, "/org/ffado/Control/Test/Container", cont); 110 149 111 150 dispatcher.enter(); 112 151 152 delete container; 153 113 154 } 114 155 trunk/libffado/tests/test-dbus.cpp
r574 r575 107 107 DBus::Connection conn = DBus::Connection::SessionBus(); 108 108 109 Control::ControlClient client(conn, SERVER_PATH, SERVER_NAME);109 DBusControl::ContignousClient client(conn, SERVER_PATH, SERVER_NAME); 110 110 111 111 int i=0; … … 113 113 { 114 114 try { 115 client. Echo(i++);115 client.setValue(i++); 116 116 } catch(...) { 117 cout << "error on Echo()\n";117 cout << "error on setValue()\n"; 118 118 }; 119 119 // try {