[fdo-dev] Enumerating connection properties
Mateusz Loskot
mateusz at loskot.net
Tue Oct 24 10:52:47 EDT 2006
Mateusz Loskot wrote:
> Greg Boone wrote:
>
>> This allows a caller to specify
>> a subset of the connection properties in order to find out the valid
>> values for the remaining properties. This behavior is defined by the
>> provider itself and allows a user to specify a subset of the connection
>> properties, connect and then request that the provider enumerate the
>> remaining connection property values.
>
> Why there is no interface to ask provider which properties are
> connection-less and which require pending connection?
>
> Or does it mean every enumerable property does always need pending
> connection?
> So, if IsPropertyEnumerable() returns TRUE, then one should not call
> FdoIConnectionPropertyDictionary::EnumeratePropertyValues()
> if connection is not Open()
May be it will be more clear if I present some code snippet that
explains what I'm asking about.
Following code only lists connection properties for OSGeo.MySQL.3.2.
I want to list *only* these properties accessible *without* any
connection, open or pending.
The question is (marked inline): How to detect these properties ?
/////////////////////////////////////////////////////////////////////////////
FdoPtr<IConnectionManager> mgr;
mgr = FdoFeatureAccessManager::GetConnectionManager();
FdoPtr<FdoIConnection> conn;
conn = mgr->CreateConnection(L"OSGeo.MySQL.3.2");
FdoPtr<FdoIConnectionInfo> ci;
ci = conn->GetConnectionInfo();
FdoPtr<FdoIConnectionPropertyDictionary> dict;
dict = ci->GetConnectionProperties();
FdoInt32 dictSize = 0;
FdoString** names = dict->GetPropertyNames(dictSize);
for (FdoInt32 i = 0; i < dictSize; i++)
{
FdoString* property = names[i];
// Display property name
std::wcout << property << std::endl;
// Display property details, if it's protected, required
// ...
////////////////////////////////////////
// How do I know which property I can enumerated without
// connection and which I can not?
////////////////////////////////////////
// Enumerate what's enumerable
if (dict->IsPropertyEnumerable(property))
{
FdoInt32 valuesSize = 0;
FdoString** values = dict->EnumeratePropertyValues(property,
valuesSize);
for (FdoInt32 j = 0; j < valuesSize; j++)
{
std::wcout << values[j] << std::endl;
}
}
}
/////////////////////////////////////////////////////////////////////////////
May be the condition logic above
if (dict->IsPropertyEnumerable(property))
should look as follows:
FdoConnectionState state = conn->GetConnectionState();
if (FdoConnectionState_Open==state || FdoConnectionState_Pending==state)
{
// Now, I can safely list what's enumerable?
if (dict->IsPropertyEnumerable(property)) {}
}
I'd like to underline that
1) I'm aware some properties can be listed only if connection is
open or pending.
2) I'd like to list properites which *can* be listed without
connecting to any data source.
Is this feasible?
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net
More information about the Fdo-internals
mailing list