-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathSolidDesignerCommandRegister.cpp
More file actions
54 lines (43 loc) · 1.99 KB
/
Copy pathSolidDesignerCommandRegister.cpp
File metadata and controls
54 lines (43 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "SolidDesignerCommandRegister.h"
#include "AliceDiagnosticMacro.h"
#include "AliceISession.h"
#include "AliceICommandRouter.h"
#include "AliceICommandRegistry.h"
#include "SolidDesignerCommandFactory.h"
#include "SolidDesignerCommand.h"
#include "AliceCoreAppUtil.h"
using namespace sdr;
using namespace alice;
bool SolidDesignerCommandRegister::RegisterCommands()
{
ISession* pSession = CoreAppUtil::GetCurrentSession();
DIAG_RETURN_FALSE_IF_FALSE(pSession, "pSession is null", "hananiah", "2025.11.2");
const std::shared_ptr<alice::ICommandRouter>& pCmdRouter = pSession->GetCommandRouter();
DIAG_RETURN_FALSE_IF_FALSE(pCmdRouter, "pCmdRouter is null", "hananiah", "2025.11.2");
ICommandRegistry* pCmdRegistry = pCmdRouter->GetCommandRegistry();
DIAG_RETURN_FALSE_IF_FALSE(pCmdRegistry, "pCmdRouter is null", "hananiah", "2025.11.2");
SolidDesignerCommandFactory& oCmdFactory = SolidDesignerCommandFactory::GetInstance();
std::vector<std::shared_ptr<alice::ICommand>> vecCommands = oCmdFactory.CreateCommands();
for (const auto& pCmd : vecCommands)
{
pCmdRegistry->RegisterCommand(pCmd);
}
return true;
}
bool SolidDesignerCommandRegister::UnRegisterCommands()
{
ISession* pSession = CoreAppUtil::GetCurrentSession();
DIAG_RETURN_FALSE_IF_FALSE(pSession, "pSession is null", "hananiah", "2025.11.2");
const std::shared_ptr<alice::ICommandRouter>& pCmdRouter = pSession->GetCommandRouter();
DIAG_RETURN_FALSE_IF_FALSE(pCmdRouter, "pCmdRouter is null", "hananiah", "2025.11.2");
ICommandRegistry* pCmdRegistry = pCmdRouter->GetCommandRegistry();
DIAG_RETURN_FALSE_IF_FALSE(pCmdRegistry, "pCmdRouter is null", "hananiah", "2025.11.2");
std::wstring strModuleId = GuidUtils::ToWString(soliddesignercommand::MODULE_ID);
pCmdRegistry->UnRegisterCommandByModule(strModuleId);
return true;
}
sdr::SolidDesignerCommandRegister& SolidDesignerCommandRegister::GetInstance()
{
static SolidDesignerCommandRegister s_Instance;
return s_Instance;
}