List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:June 5 2009 11:32pm
Subject:Re: Why dynamic allocation for Option objects?
View as plain text  
Kevin Regan wrote:
> I'm wondering why you do this:
> 
> connection->set_option(new mysqlpp::FoundRowsOption(true));

It's needed by set_option_default(), which lets you set an option only 
if it hasn't already been given an option.  It looks through the list of 
already-applied options and sets the given option only if one like it 
hasn't already been seen.

It could also be useful if the semantics of the underlying API ever 
change such that some options can only be set after the connection is 
up.  We could thus add a deferred option list, applying them 
automatically in DBDriver::connect() on successful connection.  Then 
MySQL++ client code that assumes you can set options at any time 
wouldn't have to change.

Sure, we could do both things without requiring dynamic allocation in 
client code by making copies of the objects when adding them to our 
internal lists, but why?  Much more efficient to just keep lists of 
pointers.
Thread
Why dynamic allocation for Option objects?Kevin Regan6 Jun
  • Re: Why dynamic allocation for Option objects?Warren Young6 Jun
    • RE: Why dynamic allocation for Option objects?Kevin Regan11 Jun
      • Re: Why dynamic allocation for Option objects?Jonathan Wakely11 Jun
        • RE: Why dynamic allocation for Option objects?Kevin Regan13 Jun
          • RE: Why dynamic allocation for Option objects?Kevin Regan13 Jun
          • Re: Why dynamic allocation for Option objects?Jonathan Wakely13 Jun
            • RE: Why dynamic allocation for Option objects?Kevin Regan14 Jun
              • Re: Why dynamic allocation for Option objects?Jonathan Wakely14 Jun
                • RE: Why dynamic allocation for Option objects?Kevin Regan14 Jun
                  • Re: Why dynamic allocation for Option objects?Jonathan Wakely15 Jun
                    • RE: Why dynamic allocation for Option objects?Kevin Regan15 Jun
                      • Re: Why dynamic allocation for Option objects?Jonathan Wakely15 Jun
              • Re: Why dynamic allocation for Option objects?Warren Young16 Jun
        • Re: Why dynamic allocation for Option objects?Warren Young16 Jun