Content-Length: 337092 | pFad | http://github.com/libfive/libfive/pull/569/files

42 OracleClause: hide singleton in cpp by Nekto89 · Pull Request #569 · libfive/libfive · GitHub
Skip to content

OracleClause: hide singleton in cpp #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions libfive/include/libfive/oracle/oracle_clause.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
libfive: a CAD kernel for modeling with implicit functions
Copyright (C) 2017 Matt Keeter
Copyright (C) 2017-2024 Matt Keeter

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
Expand Down Expand Up @@ -70,6 +70,15 @@ class OracleClause
installed()[name] = { ser, de };
}

/*
* Uninstalls a particular class's serializer / deserializer pair.
* Must be called with the class's name().
*/
static void uninstall(const std::string& name)
{
installed().erase(name);
}

/*
* Serializes an oracle clause by looking up an installed serializer.
* data is pushed back into the data vector
Expand Down Expand Up @@ -126,11 +135,7 @@ class OracleClause
* order dependencies.
* https://isocpp.org/wiki/faq/ctors#construct-on-first-use-v2
*/
static std::map<std::string, SerDe>& installed()
{
static std::map<std::string, SerDe> m;
return m;
}
static std::map<std::string, SerDe>& installed();
};

} // namespace libfive
Expand All @@ -145,5 +150,8 @@ public: \
T##_Installer() { \
OracleClause::install<T>(#T); \
}\
~T##_Installer() { \
OracleClause::uninstall(#T); \
}\
};\
static T##_Installer T##_Installer_Instance;
6 changes: 6 additions & 0 deletions libfive/src/oracle/oracle_clause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ std::unique_ptr<const OracleClause> OracleClause::remap(
return std::make_unique<TransformedOracleClause>(self, X_, Y_, Z_);
}

std::map<std::string, OracleClause::SerDe>& OracleClause::installed()
{
static std::map<std::string, SerDe> m;
return m;
}

} // namespace libfive








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/libfive/libfive/pull/569/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy