card: use object vectors
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 6 Nov 2015 20:19:44 +0000 (22:19 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 6 Nov 2015 20:19:44 +0000 (22:19 +0200)
libkms++/card.cpp
libkms++/card.h

index 038d494ee7d7c653e124c6d11530a920ec66f9d9..06a237f6dd7fffafcd21b1901370da6af3b5d38d 100644 (file)
@@ -153,11 +153,7 @@ void Card::print_short() const
 
 Property* Card::get_prop(const string& name) const
 {
-       for (auto pair : m_obmap) {
-               auto prop = dynamic_cast<Property*>(pair.second);
-               if (!prop)
-                       continue;
-
+       for (auto prop : m_properties) {
                if (name == prop->name())
                        return prop;
        }
@@ -167,10 +163,8 @@ Property* Card::get_prop(const string& name) const
 
 Connector* Card::get_first_connected_connector() const
 {
-       for(auto pair : m_obmap) {
-               auto c = dynamic_cast<Connector*>(pair.second);
-
-               if (c && c->connected())
+       for(auto c : m_connectors) {
+               if (c->connected())
                        return c;
        }
 
@@ -192,12 +186,7 @@ const vector<DrmObject*> Card::get_objects() const
 
 Crtc* Card::get_crtc_by_index(uint32_t idx) const
 {
-       for(auto pair : m_obmap) {
-               auto crtc = dynamic_cast<Crtc*>(pair.second);
-               if (crtc && crtc->idx() == idx)
-                       return crtc;
-       }
-       throw invalid_argument(string("Crtc #") + to_string(idx) + " not found");
+       return m_crtcs[idx];
 }
 
 Connector* Card::get_connector(uint32_t id) const { return dynamic_cast<Connector*>(get_object(id)); }
index cfc1cf20b9c06c148b46583b9cca9c9cf394b6cf..7232467ce6592a14957d6047d7f725f06bfe9e29 100644 (file)
@@ -27,9 +27,9 @@ public:
        Crtc* get_crtc(uint32_t id) const;
        Crtc* get_crtc_by_index(uint32_t idx) const;
        Encoder* get_encoder(uint32_t id) const;
+       Plane* get_plane(uint32_t id) const;
        Property* get_prop(uint32_t id) const;
        Property* get_prop(const std::string& name) const;
-       Plane* get_plane(uint32_t id) const;
 
        bool master() const { return m_master; }
        bool has_atomic() const { return m_has_atomic; }