IgANet
IGAnets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
fqn.hpp
Go to the documentation of this file.
1
15#pragma once
16
17#include <core/core.hpp>
18
19namespace iganet::utils {
20
23public:
24 virtual ~FullQualifiedName() = default;
28 inline const virtual std::string &name() const noexcept {
29 // If the name optional is empty at this point, we grab the name of the
30 // dynamic type via RTTI. Note that we cannot do this in the constructor,
31 // because in the constructor of a base class `this` always refers to the
32 // base type. Inheritance effectively does not work in constructors. Also,
33 // this note from http://en.cppreference.com/w/cpp/language/typeid: If
34 // typeid is used on an object under construction or destruction (in a
35 // destructor or in a constructor, including constructor's initializer list
36 // or default member initializers), then the std::type_info object referred
37 // to by this typeid represents the class that is being constructed or
38 // destroyed even if it is not the most-derived class.
39 if (!name_.has_value()) {
40 name_ = c10::demangle(typeid(*this).name());
41#if defined(_WIN32)
42 // Windows adds "struct" or "class" as a prefix.
43 if (name_->find("struct ") == 0) {
44 name_->erase(name_->begin(), name_->begin() + 7);
45 } else if (name_->find("class ") == 0) {
46 name_->erase(name_->begin(), name_->begin() + 6);
47 }
48#endif // defined(_WIN32)
49 }
50 return *name_;
51 }
52
54 inline virtual void
55 pretty_print(std::ostream &os = Log(log::info)) const noexcept = 0;
56
57protected:
59 mutable at::optional<std::string> name_;
60};
61
62} // namespace iganet::utils
Full qualified name descriptor.
Definition fqn.hpp:22
virtual void pretty_print(std::ostream &os=Log(log::info)) const noexcept=0
Returns a string representation.
virtual const std::string & name() const noexcept
Returns the full qualified name of the object.
Definition fqn.hpp:28
at::optional< std::string > name_
String storing the full qualified name of the object.
Definition fqn.hpp:59
virtual ~FullQualifiedName()=default
Core components.
Definition blocktensor.hpp:24
struct iganet::@0 Log
Logger.