[xsd-users] Visitors (again?)

Timothy Astle timothy.astle at caris.com
Tue Sep 9 07:54:49 EDT 2014


Thankyou very much! Great answer :)

Tim


On 09/09/2014 3:58 AM, Oliver Schneider wrote:
> Hi Tim,
>
> You can easily add a visit function to all your custom classes.
> look at
> http://wiki.codesynthesis.com/Tree/Customization_guide#Customizing_the_generated_type_.E2.80.94_the_complex_case
>
> Then add a void accept(Visitor& v) { v.visit(*this); } function.
>
> If you have c++11 you can even easily templatize this (can be done w/o
> c++11, but the inclusion of the template would be a mess)
> I created a Visitable template:
>
> template<template <class> class T, class base>
>      class Visitable : public base
>      {
>      public:
>          using base::base;
>          typedef T<base> Derived;
>          typedef Visitable<T, base> VisitableBase;
>          void accept(Visitor& visitor) { visitor.visit(*this); }
>          virtual base*
>              _clone(xml_schema::flags flags = 0,
>              xml_schema::container* container = 0) const override
>          {
>              return new Derived(static_cast<const Derived&>(*this),
> flags, container);
>          }
>          virtual ~Visitable() = default;
>      };
>
> I use this by instanciating the custom class this way:
>
> template<typename base>
> class Custom_impl : public Visitable<Custom_impl, base>
> {
> public:
>      using base::base;
> };
>
> Simple enough, and easily extendable
>
> greetings
>
> /oliver
>
> Am 04.09.2014 17:11, schrieb Timothy Astle:
>> I've checked the list archives aboutthis andseen a few related
>> threads, but I'd like to get a summary / update.  It seems like I'mnot
>> the first one interested in this topic.  Also keep in mind that I'm
>> new to this library, so please be kind.  :)
>>
>> Is there any means to generate sourcethat allows for visitors?
>> Similar to what we're adding to
>> <https://java.net/jira/browse/OGC-55>the OGC Sche
>> <https://java.net/jira/browse/OGC-55>mas in JAXB
>> <https://java.net/jira/browse/OGC-55>.
>>
>> There are situations where we'd like to take OGC Filters andtraverse
>> them to produce queries.
>>
>> If someone can point me in the right direction, it'd be much appreciated.
>>
>> Cheers,
>>
>> Tim
>>

-- 
Tim Astle
Development Manager
Web Technologies

*CARIS* <http://www.caris.com>
115 Waggoners Lane
Fredericton, New Brunswick
Canada    E3B 2L4
Tel: +1.506.458.8533     Fax: +1.506.459.3849
www.caris.com <http://www.caris.com>

*Connect with CARIS*
Twitter <http://www.twitter.com/CARIS_GIS> | LinkedIn 
<http://www.linkedin.com/groups?mostPopular=&gid=3217878> | Facebook 
<https://www.facebook.com/pages/CARIS-The-Marine-GIS-Experts/123907500987669?v=app_4949752878> 
| Google+ 
<https://plus.google.com/b/114389770462919844434/114389770462919844434/posts> 
| YouTube <http://www.youtube.com/user/CARISGIS>

Download your free copy of CARIS Easy View today!
www.caris.com/easyview <http://www.caris.com/easyview>

_________________________________________________________________________
This email and any files transmitted with it are confidential and 
intended only for the addressee(s). If you are not the intended 
recipient(s) please notify us by email reply. You should not use, 
disclose, distribute or copy this communication if received in error.

Any views or opinions expressed in this email are solely those of the 
author and do not necessarily represent those of the company. No binding 
contract will result from this email until such time as a written 
document is signed on behalf of the company.



More information about the xsd-users mailing list