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

Providing read access to time member of engine class for actions #7

Closed
arminms opened this issue Sep 17, 2015 · 2 comments
Closed

Providing read access to time member of engine class for actions #7

arminms opened this issue Sep 17, 2015 · 2 comments
Assignees

Comments

@arminms
Copy link
Owner

arminms commented Sep 17, 2015

In order to implement #6, there should be a way for actions to know the time of the simulation.

@arminms arminms self-assigned this Sep 17, 2015
@arminms
Copy link
Owner Author

arminms commented Sep 18, 2015

One approach is to add a fifth template parameter to action base for time as follows:

template
<
    class NetworkType
,   class ContentsType
,   class ConfigType
,   class RngType
,   class TimeType
>
class action_base

and then initialize it in init() member function:

    void init(
        NetworkType& net
    ,   ContentsType& cnt
    ,   ConfigType& cnf
    ,   RngType& rng
    ,   TimeType& time)

And assign it as a const reference member.

@arminms
Copy link
Owner Author

arminms commented Sep 18, 2015

A better solution is to introduce a virtual function to action_base class rather than having a const pointer to time variable:

class action_base
{
public:
    virtual action_base::update_weight(const TimeType& time)
    {    do_update_weight(time);   }

private:
    do_update_weight(const TimeType& time) = 0;
}

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

No branches or pull requests

1 participant