change a method to specify file type description

This commit is contained in:
falsycat 2022-11-13 15:39:41 +09:00
parent 6887410e19
commit 14066c1256
20 changed files with 68 additions and 180 deletions

View File

@ -14,18 +14,13 @@
namespace nf7 {
template <typename T>
concept GenericTypeInfo_UpdateTooltip_ = requires() { T::UpdateTypeTooltip(); };
template <typename T>
concept GenericTypeInfo_Description_ = requires() { T::kTypeDescription; };
template <typename T>
class GenericTypeInfo : public nf7::File::TypeInfo {
public:
GenericTypeInfo(const std::string& name, std::unordered_set<std::string>&& v) noexcept :
TypeInfo(name, AddFlags(std::move(v))) {
GenericTypeInfo(const std::string& name,
std::unordered_set<std::string>&& v,
const std::string& desc = "(no description)") noexcept :
TypeInfo(name, AddFlags(std::move(v))), desc_(desc) {
}
std::unique_ptr<nf7::File> Deserialize(nf7::Deserializer& ar) const override
@ -47,16 +42,12 @@ class GenericTypeInfo : public nf7::File::TypeInfo {
}
void UpdateTooltip() const noexcept override {
if constexpr (nf7::GenericTypeInfo_UpdateTooltip_<T>) {
T::UpdateTypeTooltip();
} else if constexpr (nf7::GenericTypeInfo_Description_<T>) {
ImGui::TextUnformatted(T::kTypeDescription);
} else {
ImGui::TextUnformatted("(no description)");
}
ImGui::TextUnformatted(desc_.c_str());
}
private:
std::string desc_;
static std::unordered_set<std::string> AddFlags(
std::unordered_set<std::string>&& flags) noexcept {
if (std::is_constructible<T, nf7::Env&>::value) {

View File

@ -22,15 +22,7 @@ namespace {
class AudioContext final : public nf7::File, public nf7::DirItem {
public:
static inline const nf7::GenericTypeInfo<AudioContext> kType = {
"Audio/Context", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Drives miniaudio context.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::audio::Queue");
ImGui::Bullet(); ImGui::TextUnformatted(
"there's no merit to use multiple contexts");
ImGui::Bullet(); ImGui::TextUnformatted(
"the context remains alive after file deletion until unused");
}
"Audio/Context", {"nf7::DirItem",}, "drives miniaudio context"};
class Queue;

View File

@ -50,10 +50,8 @@ class Device final : public nf7::FileBase,
public nf7::GenericConfig, public nf7::DirItem, public nf7::Node {
public:
static inline const nf7::GenericTypeInfo<Device> kType = {
"Audio/Device", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Provides a ring buffer to send/receive PCM samples.");
}
"Audio/Device", {"nf7::DirItem",},
"provides a ring buffer to send/receive PCM samples"};
class Instance;
class Lambda;

View File

@ -22,15 +22,7 @@ namespace {
class FontContext final : public nf7::File, public nf7::DirItem {
public:
static inline const nf7::GenericTypeInfo<FontContext> kType = {
"Font/Context", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Drives freetype context.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::font::Queue");
ImGui::Bullet(); ImGui::TextUnformatted(
"there's few merit to use multiple contexts");
ImGui::Bullet(); ImGui::TextUnformatted(
"the context remains alive after file deletion until unused");
}
"Font/Context", {"nf7::DirItem",}, "drives freetype context"};
class Queue;

View File

@ -91,10 +91,6 @@ class ObjBase : public nf7::FileBase,
struct TypeInfo;
static void UpdateTypeTooltip() noexcept {
T::UpdateTypeTooltip();
}
ObjBase(nf7::Env& env, T&& data = {}) noexcept :
nf7::FileBase(TypeInfo::kType, env),
nf7::GenericConfig(mem_),
@ -288,10 +284,6 @@ class ObjBase : public nf7::FileBase,
struct Buffer {
public:
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("OpenGL buffer");
}
static inline const std::vector<std::string> kInputs = {
"upload",
};
@ -392,16 +384,13 @@ struct Buffer {
};
template <>
struct ObjBase<Buffer>::TypeInfo final {
static inline const nf7::GenericTypeInfo<ObjBase<Buffer>> kType = {"GL/Buffer", {"nf7::DirItem"}};
static inline const nf7::GenericTypeInfo<ObjBase<Buffer>> kType = {
"GL/Buffer", {"nf7::DirItem"}, "OpenGL buffer"};
};
struct Texture {
public:
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("OpenGL texture");
}
static inline const std::vector<std::string> kInputs = {
"upload", "download",
};
@ -676,16 +665,13 @@ struct Texture {
};
template <>
struct ObjBase<Texture>::TypeInfo final {
static inline const nf7::GenericTypeInfo<ObjBase<Texture>> kType = {"GL/Texture", {"nf7::DirItem"}};
static inline const nf7::GenericTypeInfo<ObjBase<Texture>> kType = {
"GL/Texture", {"nf7::DirItem"}, "OpenGL texture"};
};
struct Shader {
public:
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("OpenGL shader");
}
static inline const std::vector<std::string> kInputs = {};
static inline const std::vector<std::string> kOutputs = {};
@ -768,16 +754,13 @@ struct Shader {
};
template <>
struct ObjBase<Shader>::TypeInfo final {
static inline const nf7::GenericTypeInfo<ObjBase<Shader>> kType = {"GL/Shader", {"nf7::DirItem"}};
static inline const nf7::GenericTypeInfo<ObjBase<Shader>> kType = {
"GL/Shader", {"nf7::DirItem"}, "OpenGL shader"};
};
struct Program {
public:
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("OpenGL program");
}
static inline const std::vector<std::string> kInputs = {
"draw",
};
@ -1056,16 +1039,13 @@ struct Program {
};
template <>
struct ObjBase<Program>::TypeInfo final {
static inline const nf7::GenericTypeInfo<ObjBase<Program>> kType = {"GL/Program", {"nf7::DirItem"}};
static inline const nf7::GenericTypeInfo<ObjBase<Program>> kType = {
"GL/Program", {"nf7::DirItem"}, "OpenGL program"};
};
struct VertexArray {
public:
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("OpenGL Vertex Array Object");
}
static inline const std::vector<std::string> kInputs = {
};
static inline const std::vector<std::string> kOutputs = {
@ -1250,21 +1230,17 @@ struct VertexArray {
};
template <>
struct ObjBase<VertexArray>::TypeInfo final {
static inline const nf7::GenericTypeInfo<ObjBase<VertexArray>> kType = {"GL/VertexArray", {"nf7::DirItem"}};
static inline const nf7::GenericTypeInfo<ObjBase<VertexArray>> kType = {
"GL/VertexArray", {"nf7::DirItem"}, "OpenGL vertex array"};
};
struct Framebuffer {
public:
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("OpenGL Framebuffer Object");
}
static inline const std::vector<std::string> kInputs = {
"clear", "blit",
};
static inline const std::vector<std::string> kOutputs = {
};
static inline const std::vector<std::string> kOutputs = {};
using Product = nf7::gl::Framebuffer;
@ -1435,7 +1411,8 @@ struct Framebuffer {
};
template <>
struct ObjBase<Framebuffer>::TypeInfo final {
static inline const nf7::GenericTypeInfo<ObjBase<Framebuffer>> kType = {"GL/Framebuffer", {"nf7::DirItem"}};
static inline const nf7::GenericTypeInfo<ObjBase<Framebuffer>> kType = {
"GL/Framebuffer", {"nf7::DirItem"}, "OpenGL framebuffer"};
};
}

View File

@ -21,16 +21,8 @@ namespace {
class LuaContext final : public nf7::File, public nf7::DirItem {
public:
static inline const nf7::GenericTypeInfo<nf7::LuaContext> kType = {
"LuaJIT/Context", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Drives LuaJIT thread and task queue.");
ImGui::Bullet(); ImGui::TextUnformatted(
"implements nf7::luajit::Queue");
ImGui::Bullet(); ImGui::TextUnformatted(
"create multiple contexts to execute LuaJIT paralelly");
ImGui::Bullet(); ImGui::TextUnformatted(
"the thread remains alive after file deletion until unused");
}
"LuaJIT/Context", {"nf7::DirItem",},
"drives LuaJIT thread and task queue"};
class Queue;

View File

@ -43,11 +43,10 @@ namespace {
class Node final : public nf7::FileBase,
public nf7::GenericConfig, public nf7::DirItem, public nf7::Node {
public:
static inline const nf7::GenericTypeInfo<Node> kType =
{"LuaJIT/Node", {"nf7::DirItem", "nf7::Node"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Defines new pure Node without creating nfile.");
}
static inline const nf7::GenericTypeInfo<Node> kType = {
"LuaJIT/Node", {"nf7::DirItem", "nf7::Node"},
"defines new pure Node without creating nfile"
};
class Lambda;

View File

@ -34,15 +34,9 @@ namespace {
class Imm final : public nf7::FileBase,
public nf7::DirItem, public nf7::Node {
public:
static inline const nf7::GenericTypeInfo<Imm> kType =
{"Node/Imm", {"nf7::DirItem", "nf7::Node"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Emits an immediate value when get an input.");
ImGui::Bullet(); ImGui::TextUnformatted(
"implements nf7::Node");
ImGui::Bullet(); ImGui::TextUnformatted(
"changes will be applied to active lambdas immediately");
}
static inline const nf7::GenericTypeInfo<Imm> kType = {
"Node/Imm", {"nf7::DirItem", "nf7::Node"},
"emits an immediate value when get an input"};
class Lambda;

View File

@ -54,13 +54,9 @@ class Network final : public nf7::FileBase,
public nf7::GenericConfig, public nf7::DirItem, public nf7::Node {
public:
static inline const GenericTypeInfo<Network> kType = {
"Node/Network", {"nf7::DirItem"}};
static void UpdateTypeTooltip() noexcept {
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(
"connection changes will be applied to active lambdas immediately");
}
"Node/Network", {"nf7::DirItem"},
"defines new Node by child Nodes and their links",
};
class InternalNode;
@ -683,12 +679,9 @@ class Network::Initiator final : public nf7::File,
public Network::InternalNode {
public:
static inline const nf7::GenericTypeInfo<Initiator> kType = {
"Node/Network/Initiator", {}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted(
"Emits a pulse immediately when Node/Network gets the first input.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node");
}
"Node/Network/Initiator", {},
"emits a pulse immediately when Node/Network gets the first input",
};
Initiator(nf7::Env& env) noexcept :
nf7::File(kType, env), nf7::Node(nf7::Node::kCustomNode) {

View File

@ -36,16 +36,7 @@ namespace {
class Ref final : public nf7::FileBase, public nf7::Node {
public:
static inline const nf7::GenericTypeInfo<Ref> kType = {
"Node/Ref", {"nf7::Node"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Refers other Node.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node");
ImGui::Bullet(); ImGui::TextUnformatted(
"the referencee's changes won't be applied to active lambdas "
"until their recreation");
ImGui::Bullet(); ImGui::TextUnformatted(
"press 'sync' button on Node UI to resolve socket issues");
}
"Node/Ref", {"nf7::Node"}, "refers other Node"};
class Lambda;

View File

@ -28,10 +28,9 @@ class Singleton final : public nf7::FileBase,
public nf7::DirItem, public nf7::GenericConfig, public nf7::Node {
public:
static inline const nf7::GenericTypeInfo<Singleton> kType = {
"Node/Singleton", {"nf7::DirItem",}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Shares a single lambda between multiple callers.");
}
"Node/Singleton", {"nf7::DirItem",},
"shares a single lambda between multiple callers",
};
class SharedLambda;
class Lambda;

View File

@ -32,15 +32,10 @@ namespace {
class Adaptor final : public nf7::FileBase,
public nf7::Sequencer {
public:
static inline const nf7::GenericTypeInfo<Adaptor> kType =
{"Sequencer/Adaptor", {"nf7::Sequencer"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Wraps and Adapts other Sequencer.");
ImGui::Bullet(); ImGui::TextUnformatted(
"implements nf7::Sequencer");
ImGui::Bullet(); ImGui::TextUnformatted(
"changes will be applied to active lambdas immediately");
}
static inline const nf7::GenericTypeInfo<Adaptor> kType = {
"Sequencer/Adaptor", {"nf7::Sequencer"},
"wraps and adapts other Sequencer",
};
class Session;
class Lambda;

View File

@ -28,14 +28,9 @@ namespace {
class Call final : public nf7::FileBase, public nf7::Sequencer {
public:
static inline const nf7::GenericTypeInfo<Call> kType = {
"Sequencer/Call", {"nf7::Sequencer"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Calls a Node.");
ImGui::Bullet(); ImGui::TextUnformatted(
"implements nf7::Sequencer");
ImGui::Bullet(); ImGui::TextUnformatted(
"changes will be applied to active lambdas immediately");
}
"Sequencer/Call", {"nf7::Sequencer"},
"calls an external Node as a Sequencer",
};
class Lambda;
class SessionLambda;

View File

@ -47,11 +47,8 @@ namespace {
class TL final : public nf7::FileBase, public nf7::DirItem, public nf7::Node {
public:
static inline const nf7::GenericTypeInfo<TL> kType = {
"Sequencer/Timeline", {"nf7::DirItem"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Timeline data");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node");
}
"Sequencer/Timeline", {"nf7::DirItem"},
};
struct Timing;

View File

@ -34,8 +34,9 @@ namespace {
class Dir final : public nf7::FileBase,
public nf7::DirItem {
public:
static inline const GenericTypeInfo<Dir> kType = {"System/Dir", {"nf7::DirItem"}};
static constexpr const char* kTypeDescription = "generic directory";
static inline const nf7::GenericTypeInfo<Dir> kType = {
"System/Dir", {"nf7::DirItem"}, "generic directory",
};
using ItemMap = std::map<std::string, std::unique_ptr<File>>;

View File

@ -40,15 +40,8 @@ class Logger final : public nf7::FileBase,
public nf7::GenericConfig, public nf7::DirItem {
public:
static inline const nf7::GenericTypeInfo<Logger> kType = {
"System/Logger", {"nf7::DirItem"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Records log output from other files.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Logger");
ImGui::Bullet(); ImGui::TextUnformatted(
"logged are children and grandchildren of a dir that has this with name '_logger'");
ImGui::Bullet(); ImGui::TextUnformatted(
"recorded logs won't be permanentized");
}
"System/Logger", {"nf7::DirItem"}, "records log output from other files",
};
struct Row final {
public:

View File

@ -41,11 +41,9 @@ class NFile final : public nf7::FileBase,
public nf7::GenericConfig, public nf7::DirItem, public nf7::Node {
public:
static inline const nf7::GenericTypeInfo<NFile> kType = {
"System/NFile", {"nf7::DirItem"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("Read/Write a file placed on native filesystem.");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node");
}
"System/NFile", {"nf7::DirItem"},
"read/write a file placed on native filesystem",
};
class Lambda;

View File

@ -17,7 +17,7 @@ class Save final : public nf7::Node::Lambda,
public std::enable_shared_from_this<Save> {
public:
static inline nf7::GenericTypeInfo<nf7::PureNodeFile<Save>> kType = {
"System/Node/Save", {"nf7::DirItem"},
"System/Node/Save", {},
};
static inline const nf7::Node::Meta kMeta = { {"exec"}, {}, };
@ -32,7 +32,7 @@ class Save final : public nf7::Node::Lambda,
class Exit final : public nf7::Node::Lambda {
public:
static inline nf7::GenericTypeInfo<nf7::PureNodeFile<Exit>> kType = {
"System/Node/Exit", {"nf7::DirItem"},
"System/Node/Exit", {},
};
static inline const nf7::Node::Meta kMeta = { {"exec"}, {}, };
@ -45,7 +45,7 @@ class Exit final : public nf7::Node::Lambda {
class Panic final : public nf7::Node::Lambda {
public:
static inline nf7::GenericTypeInfo<nf7::PureNodeFile<Panic>> kType = {
"System/Node/Panic", {"nf7::DirItem"},
"System/Node/Panic", {},
};
static inline const nf7::Node::Meta kMeta = { {"exec"}, {}, };

View File

@ -35,15 +35,10 @@ class Curve final : public nf7::FileBase,
public nf7::Node,
public nf7::Sequencer {
public:
static inline const nf7::GenericTypeInfo<Curve> kType =
{"Value/Curve", {"nf7::DirItem", "nf7::Node", "nf7::Sequencer"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("bezier curve");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Sequencer");
ImGui::Bullet(); ImGui::TextUnformatted(
"changes will be applied to active lambdas immediately");
}
static inline const nf7::GenericTypeInfo<Curve> kType = {
"Value/Curve", {"nf7::DirItem", "nf7::Node", "nf7::Sequencer"},
"bezier curve editor",
};
class NodeLambda;
class SeqLambda;

View File

@ -43,11 +43,7 @@ class Plot final : public nf7::FileBase,
public nf7::Node {
public:
static inline const nf7::GenericTypeInfo<Plot> kType =
{"Value/Plot", {"nf7::DirItem"}};
static void UpdateTypeTooltip() noexcept {
ImGui::TextUnformatted("plotter");
ImGui::Bullet(); ImGui::TextUnformatted("implements nf7::Node");
}
{"Value/Plot", {"nf7::DirItem"}, "data plotter"};
class Lambda;