<br><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 21, 2012 at 12:14 PM, Etienne Tourigny <span dir="ltr"><<a href="mailto:etourigny.dev@gmail.com" target="_blank">etourigny.dev@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I agree that it would be good to implement this idea.  However it<br>

requires a few changes in the API.<br>
<br>
Could this be done before 2.0, or after?  As it won't cause breakage<br>
it probably would be ok to add afterwards. But I think that if it's<br>
done after 2.0 not many plugins will use it.<br>
However, this would probably be low in the priorities so it probably<br>
won't make it.<br></blockquote><div><br></div><div>Both options are possible and I would be in favour of having it earlier than later... maybe it will become apparent that some breakage would be useful, so it would not need postponing until 3.0.</div>
<div><br></div><div>Anyway regarding usage of new APIs in plugins, I wouldn't be afraid that plugin writers would not pick up new APIs. We have been introducing new APIs in 1.x releases quite often and people could decide whether they will prefer convenience of new APIs or compatibility with old versions.</div>
<div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I was perhaps thinking of a less complex way - a function which<br>
returns a vector of QgsMapLayer given an uri, to replace<br>
QgisApp::addMapLayers() but that is available outside of QgisApp.<br>
Also the same for addVectorLayer() and addRasterLayer() (returning a<br>
list of vector and raster layers, resp.)<br></blockquote><div><br></div><div>Isn't such function just a step away from a simple data source class? Because such function would be provider-specific anyway...</div><div>
 </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Then this code could be migrated to proper QgsVectorDataSource /<br>

QgsRasterDataSource when possible.<br>
<br>
Which class could this go into?<br></blockquote><div><br></div><div>As a temporary solution you could just create a static method in QgsOgrProvider class and create a unit test in c++ (as it would not be available from python). But I would really like to encourage you to start with data sources :-) The interface in the beginning could be as simple as:</div>
<div><br></div><div>class QgsDataSource</div><div>{</div><div>public:</div><div><div>  static QgsDataSource* open( QString baseUri, QString provider );</div></div><div><br></div><div>  QStringList layerNames() = 0;  // get list of sub-layers<br>
</div><div>  QString uriForLayer( QString layerName ) = 0; // return full provider URI for a particular sub-layer</div><div>};<br></div><div><br></div><div>OGR provider would have its QgsDataSource implementation, QgsDataSource::open(path, "ogr") would simply create an instance of OGR's implmentation.</div>
<div><br></div><div>Regards</div><div>Martin</div></div></div>