Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to provide alternatives in sequence #67

Open
Flamefire opened this issue Dec 15, 2018 · 1 comment
Open

How to provide alternatives in sequence #67

Flamefire opened this issue Dec 15, 2018 · 1 comment

Comments

@Flamefire
Copy link
Collaborator

Suppose I have the following class:

struct Foo{
  virtual void before();
  virtual void do();
  virtual void after();
};

With the sequence approach I can make sure, those functions are called in order when having a single instance.

But what do I do when I have multiple instances? Example:

Foo* f1 = new Foo;
Foo* f2 = new Foo;
container.add(f1, f2);
// Expect (f1.before && f2.before) + (f1.do && f2.do)  + (f1.after && f2.after) 
container.process();

How can I ensure, that both before are called first, then both do etc while the order of the calls to the same function do not matter?

@mat007
Copy link
Owner

mat007 commented Dec 15, 2018

You probably need to use several sequences for that, which I admit is a little cumbersome…

Something like:

  • s1 : f1.before -> f1.do
  • s2 : f1.before -> f2.do
  • s3 : f2.before -> f1.do
  • s4 : f2.before -> f2.do

etc…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants