Skip to content

Commit 4a61cf8

Browse files
committed
chore: rename res.loaded -> res.valid
1 parent ce0ccc1 commit 4a61cf8

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

source/MaaFramework/API/MaaResource.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ MaaBool MaaResourceLoaded(MaaResourceHandle res)
7171
return false;
7272
}
7373

74-
return res->loaded();
74+
return res->valid();
7575
}
7676

7777
MaaBool MaaResourceSetOption(MaaResourceHandle res, MaaResOption key, MaaOptionValue value, MaaOptionValueSize val_size)

source/MaaFramework/API/MaaTypes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct MaaResourceAPI : public MaaInstanceSink
2727
virtual MaaResId post_path(std::filesystem::path path) = 0;
2828
virtual MaaStatus status(MaaResId res_id) const = 0;
2929
virtual MaaStatus wait(MaaResId res_id) const = 0;
30-
virtual MaaBool loaded() const = 0;
30+
virtual MaaBool valid() const = 0;
3131

3232
virtual std::string get_hash() const = 0;
3333
virtual std::vector<std::string> get_task_list() const = 0;

source/MaaFramework/Instance/InstanceMgr.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ bool InstanceMgr::bind_resource(MaaResourceAPI* resource)
3737
return false;
3838
}
3939

40-
if (!resource->loaded()) {
41-
LogWarn << "Resource not loaded";
40+
if (!resource->valid()) {
41+
LogWarn << "Resource not valid";
4242
}
4343

4444
if (resource_) {
@@ -72,7 +72,7 @@ bool InstanceMgr::bind_controller(MaaControllerAPI* controller)
7272

7373
bool InstanceMgr::inited() const
7474
{
75-
return resource_ && controller_ && resource_->loaded() && controller_->connected();
75+
return resource_ && controller_ && resource_->valid() && controller_->connected();
7676
}
7777

7878
bool InstanceMgr::set_option(MaaInstOption key, MaaOptionValue value, MaaOptionValueSize val_size)

source/MaaFramework/Resource/PipelineResMgr.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool PipelineResMgr::load_all_json(const std::filesystem::path& path)
6262
return false;
6363
}
6464

65-
bool loaded = false;
65+
bool valid = false;
6666

6767
std::set<std::string> existing_keys;
6868
for (auto& entry : std::filesystem::recursive_directory_iterator(path)) {
@@ -89,10 +89,10 @@ bool PipelineResMgr::load_all_json(const std::filesystem::path& path)
8989
return false;
9090
}
9191

92-
loaded = true;
92+
valid = true;
9393
}
9494

95-
return loaded;
95+
return valid;
9696
}
9797

9898
bool PipelineResMgr::open_and_parse_file(const std::filesystem::path& path, std::set<std::string>& existing_keys)
@@ -416,8 +416,8 @@ bool PipelineResMgr::parse_recognition(const json::value& input, Recognition::Ty
416416
case Type::Custom:
417417
out_param = CustomRecognizerParam {};
418418
return parse_custom_recognition_param(input, std::get<CustomRecognizerParam>(out_param),
419-
same_type ? std::get<CustomRecognizerParam>(default_param)
420-
: CustomRecognizerParam {});
419+
same_type ? std::get<CustomRecognizerParam>(default_param)
420+
: CustomRecognizerParam {});
421421
default:
422422
LogError << "Unknown recognition" << VAR(static_cast<int>(out_type));
423423
return false;
@@ -607,8 +607,8 @@ bool PipelineResMgr::parse_ocrer_param(const json::value& input, MAA_VISION_NS::
607607
}
608608

609609
bool PipelineResMgr::parse_custom_recognition_param(const json::value& input,
610-
MAA_VISION_NS::CustomRecognizerParam& output,
611-
const MAA_VISION_NS::CustomRecognizerParam& default_value)
610+
MAA_VISION_NS::CustomRecognizerParam& output,
611+
const MAA_VISION_NS::CustomRecognizerParam& default_value)
612612
{
613613
if (!get_and_check_value(input, "custom_recognition", output.name, default_value.name) &&
614614
!get_and_check_value(input, "custom_recognizer", output.name, default_value.name)) {

source/MaaFramework/Resource/ResourceMgr.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ MaaResId ResourceMgr::post_path(std::filesystem::path path)
3939
{
4040
LogInfo << VAR(path);
4141

42-
loaded_ = false;
42+
valid_ = false;
4343
hash_cache_.clear();
4444

4545
if (!res_loader_) {
@@ -69,9 +69,9 @@ MaaStatus ResourceMgr::wait(MaaResId res_id) const
6969
return res_loader_->status(res_id);
7070
}
7171

72-
MaaBool ResourceMgr::loaded() const
72+
MaaBool ResourceMgr::valid() const
7373
{
74-
return loaded_;
74+
return valid_;
7575
}
7676

7777
// https://stackoverflow.com/questions/20511347/a-good-hash-function-for-a-vector
@@ -133,12 +133,12 @@ bool ResourceMgr::run_load(typename AsyncRunner<std::filesystem::path>::Id id, s
133133

134134
notifier.notify(MaaMsg_Resource_StartLoading, details);
135135

136-
loaded_ = load(path);
136+
valid_ = load(path);
137137

138138
details.emplace("hash", get_hash());
139-
notifier.notify(loaded_ ? MaaMsg_Resource_LoadingCompleted : MaaMsg_Resource_LoadingFailed, details);
139+
notifier.notify(valid_ ? MaaMsg_Resource_LoadingCompleted : MaaMsg_Resource_LoadingFailed, details);
140140

141-
return loaded_;
141+
return valid_;
142142
}
143143

144144
bool ResourceMgr::load(const std::filesystem::path& path)

source/MaaFramework/Resource/ResourceMgr.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ResourceMgr : public MaaResourceAPI
2424

2525
virtual MaaStatus status(MaaResId res_id) const override;
2626
virtual MaaStatus wait(MaaResId res_id) const override;
27-
virtual MaaBool loaded() const override;
27+
virtual MaaBool valid() const override;
2828

2929
virtual std::string get_hash() const override;
3030
virtual std::vector<std::string> get_task_list() const override;
@@ -52,7 +52,7 @@ class ResourceMgr : public MaaResourceAPI
5252
private:
5353
std::vector<std::filesystem::path> paths_;
5454
mutable std::string hash_cache_;
55-
std::atomic_bool loaded_ = true;
55+
std::atomic_bool valid_ = true;
5656

5757
std::unique_ptr<AsyncRunner<std::filesystem::path>> res_loader_ = nullptr;
5858
MessageNotifier<MaaResourceCallback> notifier;

0 commit comments

Comments
 (0)