-
Notifications
You must be signed in to change notification settings - Fork 139
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
Repeating life cycles #168
Changes from 1 commit
7446f34
6608266
9cb0804
d3aa914
282a3fb
0217506
450d711
fd64f4b
f42c533
29e2dda
59d1843
d99209a
6f1c2f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,31 +93,41 @@ class LifecycleMethodCall { | |
std::optional<std::string> defined_in_derived_class_; | ||
}; | ||
|
||
class LifecycleGraphNode { | ||
public: | ||
LifecycleGraphNode( | ||
std::vector<LifecycleMethodCall> method_calls, | ||
std::vector<std::string> successors) | ||
: method_calls_(std::move(method_calls)), | ||
successors_(std::move(successors)) {} | ||
|
||
const std::vector<LifecycleMethodCall>& method_calls() const; | ||
const std::vector<std::string>& successors() const; | ||
bool operator==(const LifecycleGraphNode& other) const; | ||
|
||
INCLUDE_DEFAULT_COPY_CONSTRUCTORS_AND_ASSIGNMENTS(LifecycleGraphNode) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for consistency with the rest of our codebase, please move this right after the constructor |
||
|
||
private: | ||
std::vector<LifecycleMethodCall> method_calls_; | ||
std::vector<std::string> successors_; | ||
}; | ||
|
||
|
||
class LifeCycleMethodGraph { | ||
public: | ||
LifeCycleMethodGraph() : entry_point_("", "", {}, std::nullopt) {} | ||
void addNode(const LifecycleMethodCall& node); | ||
void addEdge(const LifecycleMethodCall& from, const LifecycleMethodCall& to); | ||
const std::vector<LifecycleMethodCall>& getNeighbours(const LifecycleMethodCall& node) const; | ||
LifeCycleMethodGraph() {} | ||
void addNode(const std::string& node_name,std::vector<LifecycleMethodCall> method_calls,std::vector<std::string> successors); | ||
|
||
const LifecycleGraphNode* getNode(const std::string& node_name) const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: we use snake_case for method names, so it should be |
||
bool operator==(const LifeCycleMethodGraph& other) const; | ||
|
||
INCLUDE_DEFAULT_COPY_CONSTRUCTORS_AND_ASSIGNMENTS(LifeCycleMethodGraph) | ||
|
||
static LifeCycleMethodGraph from_json(const Json::Value& value); | ||
|
||
private: | ||
struct NodeHasher { | ||
std::size_t operator()(const LifecycleMethodCall& node) const { | ||
return std::hash<std::string>{}(node.to_string()); | ||
} | ||
}; | ||
|
||
std::unordered_map<LifecycleMethodCall, std::vector<LifecycleMethodCall>, NodeHasher> adj_list_; | ||
|
||
// Define the entry point of the graph | ||
LifecycleMethodCall entry_point_; | ||
|
||
|
||
std::unordered_map<std::string, LifecycleGraphNode> nodes_; | ||
}; | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: inline these since the implementation is really small
can we inline the implementation of these, since those should be small?