visitor-pattern Questions

2

Solved

If all the types in my boost::variant support the same method, is there a way to call it generically (i.e. not calling it seperately for each method of the static_visitor)? I'm trying to get somet...
Torchbearer asked 20/6, 2012 at 0:19

1

While using std::visit / std::variant I see in the profiler output that std::__detail::__variant::__gen_vtable_impl functions take the most time. I did a test like this: // 3 class families, all ...
Doubt asked 7/3, 2018 at 7:46

4

When using the Visitor Pattern, can the visit(object) method update or modify the object it visits or is it simply supposed to only use the object in performing some computation and returning the c...
Bolinger asked 16/9, 2017 at 23:38

5

Solved

There is a lot of talk on decoupling the algorithms from the classes. But, one thing stays aside not explained. They use visitor like this abstract class Expr { public <T> T accept(Visitor&l...
Argon asked 3/2, 2012 at 16:43

4

I know there are similar questions already, but looking at them I still have some doubts about how I should design my code. I have a service that allows for User registration / login /update / dele...
Nocturn asked 17/2, 2018 at 9:24

6

Solved

The Visitor pattern allows operations on objects to be written without extending the object class. Sure. But why not just write a global function, or a static class, that manipulates my object coll...
Stieglitz asked 22/6, 2012 at 10:43

2

Solved

I'm looking at the explanation of the visitor pattern here which shows the following code: public class ShoppingCart { public double calculatePostage() { PostageVisitor visitor = new PostageVisi...
Baynebridge asked 11/11, 2017 at 17:51

2

Solved

I am using antlr v4 for extracting parse tree of java programs for other purposes. I have started from this sample: ANTLR v4 visitor sample And I have tested the steps on given link to check if it...

7

Solved

I have a problem with duplication of identical code for const and non-const versions. I can illustrate the problem with some code. Here are two sample visitors, one which modifies the visited objec...
Jussive asked 17/10, 2011 at 9:53

3

Solved

I've seen examples in both ways, particularly Wikipedia shows an example where the visited object decides the visiting order and I think this is a sounding approach. I'm in a situation in which I ...
Banner asked 29/11, 2014 at 21:16

2

Solved

I have an application where I am performing an operation on a series of elements and the exact nature of the operation depends on the type of the element being operated upon. For reasons of encapsu...
Carniola asked 1/5, 2013 at 20:58

1

Solved

I have implemented the Visitors of JSqlparser to parse SQL queries. The code is working absolutely fine. I am not sure how to do unit testing for those visitors. For example I have the following sq...
Diorio asked 27/1, 2017 at 6:13

3

Solved

My collegue suggested me to write a visitor pattern to navigate the AST. Can anyone tell me more how would I start writing it? As far as I understand, each Node in AST would have visit() method (?...

2

Solved

I am using SimpleXML framework for deserializing backend answers. I made some assumptions about elements. Some elements do not meet these requirements. For example, I expect an element to have chil...
Flannery asked 25/10, 2016 at 10:10

8

Solved

I believe to understand the intent of Decorator and Visitor design pattern. Though i can list following differences Decorator works on an object, Visitor works on composite structure, Decorato...
Amalgamate asked 20/2, 2012 at 15:25

1

I am new to python (~ a month), and I wish I had switched to it sooner (after years of perl). Problem: I want objects to have different functionality to the same method call based on their type. ...
Sturmabteilung asked 30/9, 2016 at 20:56

1

Solved

I am trying to implement Oppen's algorithm in C++. The basic routines in this algorithm (print and scan) dispatch on a token type. It seems natural to implement this dispatch using the visitor pat...
Stook asked 29/9, 2016 at 8:38

6

Solved

One of the reasons to consider the Visitor_pattern: A practical result of this separation is the ability to add new operations to existing object structures without modifying those structures. As...
Yance asked 12/8, 2016 at 14:34

1

I am using a composite pattern with multiple leaf node classes which have specialist operations and a visitor pattern to allow those operations to be performed. In this example I've left out all th...
Nonplus asked 6/4, 2016 at 2:59

7

Solved

Since C++11 we can make template functions which can accept any sequence of arguments: template <typename... Ts> void func(Ts &&... ts) { step_one(std::forward<Ts>(ts)...); s...
Surbeck asked 22/7, 2016 at 14:19

2

Solved

I can successfully replace simple parameter types in a lambda expression thanks to some answers on a previous question but I cannot figure out how to replace parameters from an incoming lambda to a...
Realist asked 21/7, 2016 at 8:43

1

Solved

Does Qt's QVariant class has any existing (and convenient) Visitor pattern implementation? If not, is it possible to achieve something similar to boost::apply_visitor(), i.e. minimize the the dupl...
Br asked 28/6, 2016 at 8:52

1

Solved

I am using the ExpressionVisitor to parse an expression tree to find out if it contains a specified parameter. Once I have found the parameter, there is no point in continuing the traversal. Is th...

2

Solved

I'm in the process of writing a data layer for a part of our system which logs information about automated jobs that run every day - name of the job, how long it ran, what the result was, etc. I'm...
Madrid asked 22/6, 2012 at 20:56

6

Solved

Is it possible to create a user extendable visitor pattern in C#? (preferably .net 3.5) I have a set of classes in a library that I wish to add functionality to with the visitor pattern. The probl...
Plasm asked 10/6, 2011 at 5:38

© 2022 - 2024 — McMap. All rights reserved.