OptionValueFileSpecList.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //===-- OptionValueFileSpecList.h -------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H
  9. #define LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H
  10. #include <mutex>
  11. #include "lldb/Core/FileSpecList.h"
  12. #include "lldb/Interpreter/OptionValue.h"
  13. namespace lldb_private {
  14. class OptionValueFileSpecList
  15. : public Cloneable<OptionValueFileSpecList, OptionValue> {
  16. public:
  17. OptionValueFileSpecList() = default;
  18. OptionValueFileSpecList(const OptionValueFileSpecList &other)
  19. : Cloneable(other), m_current_value(other.GetCurrentValue()) {}
  20. ~OptionValueFileSpecList() override = default;
  21. // Virtual subclass pure virtual overrides
  22. OptionValue::Type GetType() const override { return eTypeFileSpecList; }
  23. void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
  24. uint32_t dump_mask) override;
  25. Status
  26. SetValueFromString(llvm::StringRef value,
  27. VarSetOperationType op = eVarSetOperationAssign) override;
  28. void Clear() override {
  29. std::lock_guard<std::recursive_mutex> lock(m_mutex);
  30. m_current_value.Clear();
  31. m_value_was_set = false;
  32. }
  33. bool IsAggregateValue() const override { return true; }
  34. // Subclass specific functions
  35. FileSpecList GetCurrentValue() const {
  36. std::lock_guard<std::recursive_mutex> lock(m_mutex);
  37. return m_current_value;
  38. }
  39. void SetCurrentValue(const FileSpecList &value) {
  40. std::lock_guard<std::recursive_mutex> lock(m_mutex);
  41. m_current_value = value;
  42. }
  43. void AppendCurrentValue(const FileSpec &value) {
  44. std::lock_guard<std::recursive_mutex> lock(m_mutex);
  45. m_current_value.Append(value);
  46. }
  47. protected:
  48. lldb::OptionValueSP Clone() const override;
  49. mutable std::recursive_mutex m_mutex;
  50. FileSpecList m_current_value;
  51. };
  52. } // namespace lldb_private
  53. #endif // LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H