[vtk-developers] vtkSQLDatabase

David C Thompson dcthomp at sandia.gov
Tue Nov 27 20:06:06 EST 2007


Tim Shead wrote:
> I'd argue that SetURL()/GetURL() don't make much sense on a concrete
> database instance, and you don't really need them since your
> CreateFromURL() factory method can dispatch the correct parameters to
> the correct concrete database type.

I agree that SetURL shouldn't be public, but it can be useful to keep
the URL of the database around... if a reconnect is required or if you
want to present information about the database to the user, it could be
handy. How about a protected SetURL() method used by CreateFromURL()?

That would change the usage from the current classes, where an
implementation-specific instance is created and then its filename, URL,
etc. are set. Are there any cases not handled by CreateFromURL() that
are accommodated by the current code?

	David
 
> 
> > -----Original Message-----
> > From: vtk-developers-bounces+tshead=sandia.gov at vtk.org 
> > [mailto:vtk-developers-bounces+tshead=sandia.gov at vtk.org] On 
> > Behalf Of David C Thompson
> > Sent: Tuesday, November 27, 2007 5:23 PM
> > To: Wilson, Andrew T; VTK Developer List
> > Subject: [vtk-developers] vtkSQLDatabase
> > 
> > Andy (et al.),
> > 
> > We're mulling over the use of vtkSQLDatabase for a project 
> > but it would require a few additions to the existing class. 
> > Do you (or anyone) have objections to
> > 
> > 1. Adding a URL parser to the vtkSQLDatabase class?
> > 
> >    This way, sqlite, mysql, and postgres could share a common
> >    SetURL() method instead of the current SetFileName,
> >    Set{HostName,UserName,Password,Port}, SetURL trichotomy.
> >    A vtksys::RegularExpression would match
> > 
> >      file:///path     or maybe     sqlite:///path       - for SQLITE
> >      mysql://[user[:password]@]hostname[:port]/database - for MySQL
> >      pgsql://[user[:password]@]hostname[:port]/database - for Postgres
> > 
> >    It seems easily extensible to other backends and could 
> > conceivably be
> >    used to have vtkSQLDatabase create the proper subclass 
> > given the url.
> >    There would be a static method to examine a character string and
> >    return username, password, hostname, port, and database(or file
> >    path) as appropriate, with NULLs returned for portions not present:
> > 
> >    static void ParseURL( const char* URL, char*& protocol,
> >       char*& user, char*& passwd, char*& host, char*& port,
> >       char*& path );
> >    static vtkSQLDatabase* CreateFromURL( const char* URL );
> >    vtkSetStringMacro(URL);
> >    vtkGetStringMacro(URL);
> > ...





More information about the vtk-developers mailing list