add 'nf7::' prefix to flags of File::TypeInfo

This commit is contained in:
falsycat 2022-08-15 00:29:03 +09:00
parent ed970d45c6
commit 0f5e3c6246
15 changed files with 40 additions and 33 deletions

View File

@ -54,7 +54,9 @@ class GenericTypeInfo : public File::TypeInfo {
private: private:
static std::unordered_set<std::string> AddFlags( static std::unordered_set<std::string> AddFlags(
std::unordered_set<std::string>&& flags) noexcept { std::unordered_set<std::string>&& flags) noexcept {
if (std::is_constructible<T, Env&>::value) flags.insert("File_Factory"); if (std::is_constructible<T, Env&>::value) {
flags.insert("nf7::File::TypeInfo::Factory");
}
return flags; return flags;
} }
}; };

View File

@ -25,11 +25,14 @@ bool FileFactory::Update() noexcept {
for (const auto& reg : nf7::File::registry()) { for (const auto& reg : nf7::File::registry()) {
const auto& t = *reg.second; const auto& t = *reg.second;
const bool name_match = const bool match =
type_filter_.empty() || t.name().find(type_filter_) != std::string::npos; t.flags().contains("nf7::File::TypeInfo::Factory") &&
(type_filter_.empty() ||
t.name().find(type_filter_) != std::string::npos) &&
filter_(t);
const bool sel = (type_ == &t); const bool sel = (type_ == &t);
if (!name_match || !filter_(t)) { if (!match) {
if (sel) type_ = nullptr; if (sel) type_ = nullptr;
continue; continue;
} }

View File

@ -19,7 +19,8 @@ namespace {
class AudioContext final : public nf7::File, public nf7::DirItem { class AudioContext final : public nf7::File, public nf7::DirItem {
public: public:
static inline const nf7::GenericTypeInfo<AudioContext> kType = {"Audio/Context", {"DirItem",}}; static inline const nf7::GenericTypeInfo<AudioContext> kType = {
"Audio/Context", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Drives miniaudio context."); ImGui::TextUnformatted("Drives miniaudio context.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::audio::Queue"); ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::audio::Queue");

View File

@ -35,7 +35,8 @@ namespace {
class Device final : public nf7::File, public nf7::DirItem, public nf7::Node { class Device final : public nf7::File, public nf7::DirItem, public nf7::Node {
public: public:
static inline const GenericTypeInfo<Device> kType = {"Audio/Device", {"DirItem",}}; static inline const GenericTypeInfo<Device> kType = {
"Audio/Device", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Manages ring buffer and sends PCM samples to actual device."); ImGui::TextUnformatted("Manages ring buffer and sends PCM samples to actual device.");
ImGui::Bullet(); ImGui::Bullet();

View File

@ -17,10 +17,10 @@
namespace nf7 { namespace nf7 {
namespace { namespace {
class LuaContext final : public nf7::File, class LuaContext final : public nf7::File, public nf7::DirItem {
public nf7::DirItem {
public: public:
static inline const GenericTypeInfo<LuaContext> kType = {"LuaJIT/Context", {"DirItem",}}; static inline const GenericTypeInfo<LuaContext> kType = {
"LuaJIT/Context", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Drives LuaJIT thread and task queue."); ImGui::TextUnformatted("Drives LuaJIT thread and task queue.");
ImGui::Bullet(); ImGui::TextUnformatted( ImGui::Bullet(); ImGui::TextUnformatted(

View File

@ -39,7 +39,7 @@ namespace {
class Node final : public nf7::File, public nf7::DirItem, public nf7::Node { class Node final : public nf7::File, public nf7::DirItem, public nf7::Node {
public: public:
static inline const GenericTypeInfo<Node> kType = static inline const GenericTypeInfo<Node> kType =
{"LuaJIT/Node", {"DirItem",}}; {"LuaJIT/Node", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Defines new Node using LuaJIT/Obj."); ImGui::TextUnformatted("Defines new Node using LuaJIT/Obj.");
ImGui::Bullet(); ImGui::Bullet();

View File

@ -36,11 +36,10 @@ using namespace std::literals;
namespace nf7 { namespace nf7 {
namespace { namespace {
class Obj final : public nf7::File, class Obj final : public nf7::File, public nf7::DirItem, public nf7::luajit::Obj {
public nf7::DirItem,
public nf7::luajit::Obj {
public: public:
static inline const GenericTypeInfo<Obj> kType = {"LuaJIT/Obj", {"DirItem",}}; static inline const GenericTypeInfo<Obj> kType = {
"LuaJIT/Obj", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted( ImGui::TextUnformatted(
"Compiles and runs LuaJIT script, and caches the object returned from the script."); "Compiles and runs LuaJIT script, and caches the object returned from the script.");

View File

@ -33,7 +33,7 @@ namespace {
class Imm final : public nf7::File, public nf7::DirItem, public nf7::Node { class Imm final : public nf7::File, public nf7::DirItem, public nf7::Node {
public: public:
static inline const GenericTypeInfo<Imm> kType = static inline const GenericTypeInfo<Imm> kType =
{"Node/Imm", {"DirItem", "Node"}}; {"Node/Imm", {"nf7::DirItem", "nf7::Node"}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Emits an immediate value when get an input."); ImGui::TextUnformatted("Emits an immediate value when get an input.");
ImGui::Bullet(); ImGui::TextUnformatted( ImGui::Bullet(); ImGui::TextUnformatted(

View File

@ -40,11 +40,10 @@ using namespace std::literals;
namespace nf7 { namespace nf7 {
namespace { namespace {
class Network final : public nf7::File, class Network final : public nf7::File, public nf7::DirItem, public nf7::Node {
public nf7::DirItem,
public nf7::Node {
public: public:
static inline const GenericTypeInfo<Network> kType = {"Node/Network", {"DirItem"}}; static inline const GenericTypeInfo<Network> kType = {
"Node/Network", {"nf7::DirItem"}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("A Node composed of multiple child Nodes, whose sockets are linked to each other"); ImGui::TextUnformatted("A Node composed of multiple child Nodes, whose sockets are linked to each other");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node"); ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node");
@ -86,7 +85,7 @@ class Network final : public nf7::File,
ItemList&& items = {}, ItemList&& items = {},
NodeLinkStore&& links = {}) noexcept : NodeLinkStore&& links = {}) noexcept :
File(kType, env), DirItem(DirItem::kMenu | DirItem::kTooltip), File(kType, env), DirItem(DirItem::kMenu | DirItem::kTooltip),
factory_(*this, [](auto& t) { return t.flags().contains("Node"); }), factory_(*this, [](auto& t) { return t.flags().contains("nf7::Node"); }),
win_(*this, "Editor Node/Network", win), win_(*this, "Editor Node/Network", win),
items_(std::move(items)), links_(std::move(links)) { items_(std::move(items)), links_(std::move(links)) {
Initialize(); Initialize();
@ -697,7 +696,8 @@ class Network::Initiator final : public Network::ChildNode,
public nf7::Node, public nf7::Node,
public Network::InternalNode { public Network::InternalNode {
public: public:
static inline const GenericTypeInfo<Initiator> kType = {"Node/Network/Initiator", {"Node"}}; static inline const GenericTypeInfo<Initiator> kType = {
"Node/Network/Initiator", {"nf7::Node"}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted( ImGui::TextUnformatted(
"Emits a pulse immediately when Node/Network gets the first input."); "Emits a pulse immediately when Node/Network gets the first input.");

View File

@ -31,8 +31,8 @@ namespace {
class Ref final : public nf7::File, public nf7::Node { class Ref final : public nf7::File, public nf7::Node {
public: public:
static inline const nf7::GenericTypeInfo<Ref> kType = static inline const nf7::GenericTypeInfo<Ref> kType = {
{"Node/Ref", {"Node"}}; "Node/Ref", {"nf7::Node"}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Refers other Node."); ImGui::TextUnformatted("Refers other Node.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node"); ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node");

View File

@ -29,8 +29,8 @@ namespace {
class Call final : public nf7::FileBase, public nf7::Sequencer { class Call final : public nf7::FileBase, public nf7::Sequencer {
public: public:
static inline const nf7::GenericTypeInfo<Call> kType = static inline const nf7::GenericTypeInfo<Call> kType = {
{"Sequencer/Call", {"Sequencer"}}; "Sequencer/Call", {"nf7::Sequencer"}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Calls a Node."); ImGui::TextUnformatted("Calls a Node.");
ImGui::Bullet(); ImGui::TextUnformatted( ImGui::Bullet(); ImGui::TextUnformatted(
@ -49,7 +49,7 @@ class Call final : public nf7::FileBase, public nf7::Sequencer {
Sequencer::kParamPanel), Sequencer::kParamPanel),
life_(*this), life_(*this),
callee_(*this, "callee", callee), callee_(*this, "callee", callee),
callee_editor_(*this, [](auto& t) { return t.flags().contains("Node"); }), callee_editor_(*this, [](auto& t) { return t.flags().contains("nf7::Node"); }),
callee_popup_("CalleeEditorPopup", callee_editor_), callee_popup_("CalleeEditorPopup", callee_editor_),
mem_(*this, Data {*this, expects}){ mem_(*this, Data {*this, expects}){
callee_.onChildMementoChange = [this]() { callee_.onChildMementoChange = [this]() {

View File

@ -45,8 +45,8 @@ namespace {
class TL final : public nf7::File, public nf7::DirItem, public nf7::Node { class TL final : public nf7::File, public nf7::DirItem, public nf7::Node {
public: public:
static inline const nf7::GenericTypeInfo<TL> kType = static inline const nf7::GenericTypeInfo<TL> kType = {
{"Sequencer/Timeline", {"DirItem"}}; "Sequencer/Timeline", {"nf7::DirItem"}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Timeline data"); ImGui::TextUnformatted("Timeline data");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node"); ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node");
@ -133,7 +133,7 @@ class TL final : public nf7::File, public nf7::DirItem, public nf7::Node {
AddItemPopup(TL& f) noexcept : AddItemPopup(TL& f) noexcept :
Popup("AddItemPopup"), Popup("AddItemPopup"),
owner_(&f), owner_(&f),
factory_(f, [](auto& t) { return t.flags().contains("Sequencer"); }) { factory_(f, [](auto& t) { return t.flags().contains("nf7::Sequencer"); }) {
} }
void Open(uint64_t t, TL::Layer& l) noexcept { void Open(uint64_t t, TL::Layer& l) noexcept {

View File

@ -32,7 +32,7 @@ class Dir final : public File,
public nf7::Dir, public nf7::Dir,
public nf7::DirItem { public nf7::DirItem {
public: public:
static inline const GenericTypeInfo<Dir> kType = {"System/Dir", {"DirItem"}}; static inline const GenericTypeInfo<Dir> kType = {"System/Dir", {"nf7::DirItem"}};
static constexpr const char* kTypeDescription = "generic directory"; static constexpr const char* kTypeDescription = "generic directory";
using ItemMap = std::map<std::string, std::unique_ptr<File>>; using ItemMap = std::map<std::string, std::unique_ptr<File>>;
@ -43,7 +43,7 @@ class Dir final : public File,
nf7::DirItem::kMenu | nf7::DirItem::kMenu |
nf7::DirItem::kTooltip | nf7::DirItem::kTooltip |
nf7::DirItem::kDragDropTarget), nf7::DirItem::kDragDropTarget),
factory_(*this, [](auto& t) { return t.flags().contains("DirItem"); }, factory_(*this, [](auto& t) { return t.flags().contains("nf7::DirItem"); },
nf7::gui::FileFactory::kNameInput | nf7::gui::FileFactory::kNameInput |
nf7::gui::FileFactory::kNameDupCheck), nf7::gui::FileFactory::kNameDupCheck),
items_(std::move(items)), win_(*this, "TreeView System/Dir", src) { items_(std::move(items)), win_(*this, "TreeView System/Dir", src) {

View File

@ -26,7 +26,8 @@ namespace {
class Logger final : public nf7::File, class Logger final : public nf7::File,
public nf7::DirItem { public nf7::DirItem {
public: public:
static inline const GenericTypeInfo<Logger> kType = {"System/Logger", {"DirItem"}}; static inline const GenericTypeInfo<Logger> kType = {
"System/Logger", {"nf7::DirItem"}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Records log output from other files."); ImGui::TextUnformatted("Records log output from other files.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Logger"); ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Logger");

View File

@ -36,7 +36,7 @@ class NativeFile final : public File,
public nf7::DirItem { public nf7::DirItem {
public: public:
static inline const GenericTypeInfo<NativeFile> kType = { static inline const GenericTypeInfo<NativeFile> kType = {
"System/NativeFile", {"AsyncBuffer", "DirItem"}}; "System/NativeFile", {"nf7::AsyncBuffer", "nf7::DirItem"}};
static void UpdateTypeTooltip() noexcept { static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Reads/Writes a file placed on native filesystem."); ImGui::TextUnformatted("Reads/Writes a file placed on native filesystem.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::AsyncBuffer"); ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::AsyncBuffer");