Skip to content

Commit

Permalink
[chip-tool] Clean up ComplexArguments once a command is done (#25343)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored Feb 27, 2023
1 parent e97ca93 commit 07e7a0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/chip-tool/commands/clusters/ComplexArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ class ComplexArgument
virtual ~ComplexArgument() {}

virtual CHIP_ERROR Parse(const char * label, const char * json) = 0;

virtual void Reset() = 0;
};

template <typename T>
Expand Down Expand Up @@ -402,6 +404,8 @@ class TypedComplexArgument : public ComplexArgument
return ComplexArgumentParser::Setup(label, *mRequest, value);
}

void Reset() { *mRequest = T(); }

private:
T * mRequest;
};
5 changes: 5 additions & 0 deletions examples/chip-tool/commands/common/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,11 @@ void Command::ResetArguments()
}
vectorArgument->clear();
}
else if (type == ArgumentType::Complex)
{
auto argument = static_cast<ComplexArgument *>(arg.value);
argument->Reset();
}
}
}
}

0 comments on commit 07e7a0e

Please sign in to comment.