PeriDyno
1.0.0
Loading...
Searching...
No Matches
D:
Peridyno
peridyno
src
Framework
NodeFactory.cpp
Go to the documentation of this file.
1
#include "
NodeFactory.h
"
2
3
namespace
dyno
4
{
5
std::atomic<NodeFactory*>
NodeFactory::pInstance
;
6
std::mutex
NodeFactory::mMutex
;
7
8
//Thread-safe singleton mode
9
NodeFactory
*
NodeFactory::instance
()
10
{
11
NodeFactory
* ins =
pInstance
.load(std::memory_order_acquire);
12
if
(!ins) {
13
std::lock_guard<std::mutex> tLock(
mMutex
);
14
ins =
pInstance
.load(std::memory_order_relaxed);
15
if
(!ins) {
16
ins =
new
NodeFactory
();
17
pInstance
.store(ins, std::memory_order_release);
18
}
19
}
20
21
return
ins;
22
}
23
24
void
NodeGroup::addAction
(std::string
caption
, std::string icon, std::function<std::shared_ptr<Node>()> act)
25
{
26
mActions
.push_back(std::make_shared<NodeAction>(
caption
, icon, act));
27
}
28
29
void
NodeGroup::addAction
(std::shared_ptr<NodeAction> nAct)
30
{
31
mActions
.push_back(nAct);
32
}
33
34
bool
NodePage::hasGroup
(std::string name)
35
{
36
return
mGroups
.find(name) !=
mGroups
.end();
37
}
38
39
std::shared_ptr<dyno::NodeGroup>
NodePage::addGroup
(std::string name)
40
{
41
if
(
mGroups
.find(name) ==
mGroups
.end())
42
{
43
mGroups
[name] = std::make_shared<NodeGroup>(name);
44
}
45
46
return
mGroups
[name];
47
}
48
49
bool
NodeFactory::hasPage
(std::string name)
50
{
51
return
mPages
.find(name) !=
mPages
.end();
52
}
53
54
std::shared_ptr<NodePage>
NodeFactory::addPage
(std::string name, std::string icon)
55
{
56
if
(
mPages
.find(name) ==
mPages
.end())
57
{
58
mPages
[name] = std::make_shared<NodePage>(name, icon);
59
}
60
61
return
mPages
[name];
62
}
63
}
NodeFactory.h
dyno::NodeFactory::NodeFactory
NodeFactory()=default
dyno::NodeFactory::instance
static NodeFactory * instance()
Definition
NodeFactory.cpp:9
dyno::NodeFactory::pInstance
static std::atomic< NodeFactory * > pInstance
Definition
NodeFactory.h:117
dyno::NodeFactory::addPage
std::shared_ptr< NodePage > addPage(std::string name, std::string icon)
Definition
NodeFactory.cpp:54
dyno::NodeFactory::hasPage
bool hasPage(std::string name)
Definition
NodeFactory.cpp:49
dyno::NodeFactory::mMutex
static std::mutex mMutex
Definition
NodeFactory.h:118
dyno::NodeFactory::mPages
std::map< std::string, std::shared_ptr< NodePage > > mPages
Definition
NodeFactory.h:120
dyno::NodeGroup::mActions
std::vector< std::shared_ptr< NodeAction > > mActions
Definition
NodeFactory.h:68
dyno::NodeGroup::caption
std::string caption()
Definition
NodeFactory.h:63
dyno::NodeGroup::addAction
void addAction(std::shared_ptr< NodeAction > nAct)
Definition
NodeFactory.cpp:29
dyno::NodePage::mGroups
std::map< std::string, std::shared_ptr< NodeGroup > > mGroups
Definition
NodeFactory.h:94
dyno::NodePage::hasGroup
bool hasGroup(std::string name)
Definition
NodeFactory.cpp:34
dyno::NodePage::addGroup
std::shared_ptr< NodeGroup > addGroup(std::string name)
Definition
NodeFactory.cpp:39
dyno
This is an implementation of AdditiveCCD based on peridyno.
Definition
Array.h:25
Generated by
1.13.2