Clarify usage of smart pointers
- Members should be smart (shared or unique)
- Prefer function args to be bare, unless the arg is intended to be
stored by the callee
- Function args that are smart should be const refs to avoid an extra
copy
Change-Id: I8052fa432bcffbabff9d67a8d568640cac64d4ad
diff --git a/modules/input/evdev/InputHub.h b/modules/input/evdev/InputHub.h
index bec327a..dfab3db 100644
--- a/modules/input/evdev/InputHub.h
+++ b/modules/input/evdev/InputHub.h
@@ -89,10 +89,10 @@
/** Callback interface for receiving input events, including device changes. */
class InputCallbackInterface {
public:
- virtual void onInputEvent(std::shared_ptr<InputDeviceNode> node, InputEvent& event,
+ virtual void onInputEvent(const std::shared_ptr<InputDeviceNode>& node, InputEvent& event,
nsecs_t event_time) = 0;
- virtual void onDeviceAdded(std::shared_ptr<InputDeviceNode> node) = 0;
- virtual void onDeviceRemoved(std::shared_ptr<InputDeviceNode> node) = 0;
+ virtual void onDeviceAdded(const std::shared_ptr<InputDeviceNode>& node) = 0;
+ virtual void onDeviceRemoved(const std::shared_ptr<InputDeviceNode>& node) = 0;
protected:
InputCallbackInterface() = default;
@@ -129,7 +129,7 @@
*/
class InputHub : public InputHubInterface {
public:
- explicit InputHub(std::shared_ptr<InputCallbackInterface> cb);
+ explicit InputHub(const std::shared_ptr<InputCallbackInterface>& cb);
virtual ~InputHub() override;
virtual status_t registerDevicePath(const std::string& path) override;
@@ -143,8 +143,8 @@
private:
status_t readNotify();
status_t scanDir(const std::string& path);
- status_t openNode(const std::string& path, std::shared_ptr<InputDeviceNode>* outNode);
- status_t closeNode(const std::shared_ptr<InputDeviceNode>& node);
+ std::shared_ptr<InputDeviceNode> openNode(const std::string& path);
+ status_t closeNode(const InputDeviceNode* node);
status_t closeNodeByFd(int fd);
std::shared_ptr<InputDeviceNode> findNodeByPath(const std::string& path);