-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[REQ] Accessing the parent Cell from a State #31
Comments
Can you work on a PR for this? It's been a while since I don't program in C++, but if I remember correctly, it is possible to define default implementations for these functions right? I'm thinking about backward compatibility: it would be desirable if your new |
Yeah I can work on a PR. But AFAIK you can't do a default implementation because States are added as template types i.e. there's no base type for a default implementation. |
Looking at it now, it would be nice to be able to reference the parent cell at all times, not just while printing. My use case is I'm computing fire spread from cell A to cell B. To compute cell B, I need params from cell A (slope, fuel, etc). Since I only have state A, I need to store slope, fuel, etc in state A. Anything const should be stored in the cells to avoid duplication. Would storing a const ref to the cell from the state be acceptable? In the state ctor, it could take a cell reference and optionally store that. This would mean removing the default ctor or using pointers instead and allow null cell pointers |
Give it a try. It should be OK if you don't touch the cell reference. A const pointer should work. Be careful with circular references though, they usually are the source of problems. |
Is your feature request related to a problem? Please describe.
Yes.
I'd like a way to print the latitude and longitude of the State from the loggers. Currently, I'm writing the lat/long into each State and printing it from there. Since the data is constant (as it is based on the cell position), it should be stored in the Cell instead. However, I can't access the Cell from the State.
Describe the solution you'd like
A way of accessing the parent Cell from a State during printing. Maybe instead of using stream operators, an explicit
std::string getString(const State& state, const Cell& parentCell)
in the State class would work?Describe alternatives you've considered
Thanks
The text was updated successfully, but these errors were encountered: