> On Thursday 19 June 2008 16:18:02 Bjoern Ricks wrote:
>
>> I started coding to get rid of osync_xml_validate and to have only one
>> instance of a xml schema for each objtype. Therefore I tried to reuse
>> the oop singleton pattern in C via a static GList. Could you please
>> review my first intuition because I am more familiar with C++ than C.
>>
>
> Thanks for looking into this!
>
> The idea of using C++-singleton-like sounds interesting. I wonder if we would
> change some more stuff, if this would be still required. For example make all
> OSyncXMLFormat "inherit" of OSyncXMLFormatSchema? We just force/require for
> all XMLFormats a schema file, by changing osync_xmlformat_new parameter list
> to:
>
> osync_xmlformat_new(const char *objtype, OSyncXMLFormatSchema *schema,
> OSyncError **error);
>
> And putting an OSyncXMLFormatSchema pointer into the internal struct.
>
> Thoughts?
>
> [...]
>
That could be a better solution than to use static variables for each
objtype. I was thinking about that too. But I didn't dare to change the
parameter list.
But the new solution has another problem. Where should the
OSyncXMLFormatSchemas be created (and released)? We need only one
instance per objtype. Is there one osnyc engine per application? Then
the engine could be the right part to create OSyncXMLFormatSchemas.
>
>
>> /**
>> * @brief Validate the xmlformat against its schema in inidivual path
>> * @param xmlformat The pointer to a xmlformat object
>> @@ -399,8 +473,9 @@
>> osync_bool osync_xmlformat_validate(OSyncXMLFormat *xmlformat)
>> {
>> osync_assert(xmlformat);
>> -
>> - return _osync_xmlformat_validate(xmlformat, NULL);
>> +
>> + OSyncXMLFormatSchema * schema =
>> osync_xmlformat_schema_get_instance(xmlformat, NULL); + return
>> osync_xmlformat_schema_validate(schema, xmlformat);
>>
>
> We should avoid code which is ignoring the error handling by passing NULL
> instead of a OSyncError reference. (I know there is/was some code doing
> so ... but we should get rid of those old code. It's just bad/wrong/....).
> Feel free to change the paramter list vor the _validate() function to
> (OSyncXMLFormat *xmlformat, OSyncError **error). You might set also an error
> when osync_xmlformat_schema_validate is false:
> osync_error_set(*error, OSYNC_ERROR_GENERIC /*or something different */, "XML
> Format validation failed.");
>
:-) I was irritated because osync_xmlformat_validate had no error
parameter. Therefore I had to use a NULL value. So we should change the
function signature.
--
------------------------------------------------------------------------
University of Applied Sciences Osnabrueck
Faculty of Engineering and Computer Science
Dipl.-Inf. (FH) Bjoern Ricks
P.O. Box 1940 - 49009 Osnabrueck - Germany
Phone: +49 541/969-3452 Fax: +49 541/969-13452
Email:
b.ricks@... <mailto:
b.ricks@...>
Web:
http://www.ecs.fh-osnabrueck.de/ricks.html-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php_______________________________________________
Opensync-devel mailing list
Opensync-devel@...
https://lists.sourceforge.net/lists/listinfo/opensync-devel