MeshLib C++ Docs
Loading...
Searching...
No Matches
MRUITestEngineControl.h
Go to the documentation of this file.
1#pragma once
2
3#include "exports.h"
4#include "MRMesh/MRExpected.h"
5
6#include <cassert>
7#include <optional>
8#include <string>
9#include <vector>
10
12{
13
17
27
28[[nodiscard]] inline std::string_view toString( EntryType type )
29{
30 const char* ret = nullptr;
31 switch ( type )
32 {
33 case Control::EntryType::button: ret = "button"; break;
34 case Control::EntryType::valueInt: ret = "valueInt"; break;
35 case Control::EntryType::valueUint: ret = "valueUint"; break;
36 case Control::EntryType::valueReal: ret = "valueReal"; break;
37 case Control::EntryType::valueString: ret = "valueString"; break;
38 case Control::EntryType::group: ret = "group"; break;
39 }
40 assert( ret && "Unknown enum." );
41 if ( !ret )
42 ret = "??";
43 return ret;
44}
45
47{
48 std::string name;
50
54 std::string status;
55};
56
58[[nodiscard]] MRVIEWER_API std::string pathToString( const std::vector<std::string>& path );
59
61[[nodiscard]] MRVIEWER_API Expected<std::vector<TypedEntry>> listEntries( const std::vector<std::string>& path );
62
64using PathedEntry = std::pair<std::vector<std::string>, TypedEntry>;
65
69[[nodiscard]] MRVIEWER_API Expected<std::vector<PathedEntry>> listAllEntries( const std::vector<std::string>& rootPath );
70
75MRVIEWER_API Expected<std::string> pressButton( const std::vector<std::string>& path );
76
78
79template <typename T>
80struct Value
81{
82 T value = 0;
83 T min = 0;
84 T max = 0;
85};
86template <>
87struct Value<std::string>
88{
89 std::string value;
90
91 std::optional<std::vector<std::string>> allowedValues;
92};
97
99template <typename T>
100MRVIEWER_API Expected<Value<T>> readValue( const std::vector<std::string>& path );
101
102extern template MRVIEWER_API Expected<Value<std::int64_t >> readValue( const std::vector<std::string>& path );
103extern template MRVIEWER_API Expected<Value<std::uint64_t>> readValue( const std::vector<std::string>& path );
104extern template MRVIEWER_API Expected<Value<double >> readValue( const std::vector<std::string>& path );
105extern template MRVIEWER_API Expected<Value<std::string >> readValue( const std::vector<std::string>& path );
106
111template <typename T>
112MRVIEWER_API Expected<std::string> writeValue( const std::vector<std::string>& path, T value );
113
114extern template MRVIEWER_API Expected<std::string> writeValue( const std::vector<std::string>& path, std::int64_t value );
115extern template MRVIEWER_API Expected<std::string> writeValue( const std::vector<std::string>& path, std::uint64_t value );
116extern template MRVIEWER_API Expected<std::string> writeValue( const std::vector<std::string>& path, double value );
117extern template MRVIEWER_API Expected<std::string> writeValue( const std::vector<std::string>& path, std::string value );
118
119
120}
tl::expected< T, E > Expected
Definition MRExpected.h:31
Definition MRUITestEngineControl.h:12
std::pair< std::vector< std::string >, TypedEntry > PathedEntry
listAllEntries returns this: each element is (fullPath, entry) where fullPath.back() == entry....
Definition MRUITestEngineControl.h:64
Expected< std::vector< PathedEntry > > listAllEntries(const std::vector< std::string > &rootPath)
Value< std::string > ValueString
Definition MRUITestEngineControl.h:96
Expected< std::string > writeValue(const std::vector< std::string > &path, T value)
Value< std::uint64_t > ValueUint
Definition MRUITestEngineControl.h:94
Expected< Value< T > > readValue(const std::vector< std::string > &path)
Returns the value at the path, or returns an error if the path or type is wrong.
std::string pathToString(const std::vector< std::string > &path)
Returns the elements of path combined into a single string.
Value< std::int64_t > ValueInt
Definition MRUITestEngineControl.h:93
Expected< std::string > pressButton(const std::vector< std::string > &path)
Expected< std::vector< TypedEntry > > listEntries(const std::vector< std::string > &path)
Returns the contents of path, or an error if the path is wrong.
Value< double > ValueReal
Definition MRUITestEngineControl.h:95
std::string_view toString(EntryType type)
Definition MRUITestEngineControl.h:28
EntryType
Definition MRUITestEngineControl.h:19
@ valueString
Definition MRUITestEngineControl.h:25
@ valueUint
Definition MRUITestEngineControl.h:23
@ valueInt
Definition MRUITestEngineControl.h:22
@ button
Definition MRUITestEngineControl.h:20
@ group
Definition MRUITestEngineControl.h:21
@ valueReal
Definition MRUITestEngineControl.h:24
Definition MRUITestEngineControl.h:47
std::string name
Definition MRUITestEngineControl.h:48
std::string status
Definition MRUITestEngineControl.h:54
EntryType type
Definition MRUITestEngineControl.h:49
Read/write values: (drags, sliders, etc)
Definition MRUITestEngineControl.h:81
double min
Definition MRUITestEngineControl.h:83
double value
Definition MRUITestEngineControl.h:82
double max
Definition MRUITestEngineControl.h:84