-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #44 - Move import export helper functions out of PTN_EngineImp
Create ActionsThreadOptionConversions to help convert the enumeration ACTIONS_THREAD_OPTION to and from string.
- Loading branch information
Showing
8 changed files
with
140 additions
and
84 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
PTN_Engine/ImportExport/ActionsThreadOptionConversions.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* This file is part of PTN Engine | ||
* | ||
* Copyright (c) 2024 Eduardo Valgôde | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "PTN_Engine/ImportExport/ActionsThreadOptionConversions.h" | ||
#include "PTN_Engine/PTN_Exception.h" | ||
|
||
namespace ptne | ||
{ | ||
using namespace std; | ||
|
||
const string ActionsThreadOptionConversions::ACTIONS_THREAD_OPTION_SINGLE_THREAD = "SINGLE_THREAD"; | ||
const string ActionsThreadOptionConversions::ACTIONS_THREAD_OPTION_EVENT_LOOP = "EVENT_LOOP"; | ||
const string ActionsThreadOptionConversions::ACTIONS_THREAD_OPTION_DETACHED = "DETACHED"; | ||
const string ActionsThreadOptionConversions::ACTIONS_THREAD_OPTION_JOB_QUEUE = "JOB_QUEUE"; | ||
|
||
PTN_Engine::ACTIONS_THREAD_OPTION | ||
ActionsThreadOptionConversions::toACTIONS_THREAD_OPTION(const string &actionsThreadOptionStr) | ||
{ | ||
using enum PTN_Engine::ACTIONS_THREAD_OPTION; | ||
if (actionsThreadOptionStr == ACTIONS_THREAD_OPTION_SINGLE_THREAD) | ||
{ | ||
return SINGLE_THREAD; | ||
} | ||
else if (actionsThreadOptionStr == ACTIONS_THREAD_OPTION_EVENT_LOOP) | ||
{ | ||
return EVENT_LOOP; | ||
} | ||
else if (actionsThreadOptionStr == ACTIONS_THREAD_OPTION_DETACHED) | ||
{ | ||
return DETACHED; | ||
} | ||
else if (actionsThreadOptionStr == ACTIONS_THREAD_OPTION_JOB_QUEUE) | ||
{ | ||
return JOB_QUEUE; | ||
} | ||
else | ||
{ | ||
throw PTN_Exception("Could not convert " + actionsThreadOptionStr + " to ACTIONS_THREAD_OPTION"); | ||
} | ||
} | ||
|
||
string ActionsThreadOptionConversions::toString(PTN_Engine::ACTIONS_THREAD_OPTION actionsThreadOption) | ||
{ | ||
using enum PTN_Engine::ACTIONS_THREAD_OPTION; | ||
switch (actionsThreadOption) | ||
{ | ||
default: | ||
{ | ||
throw PTN_Exception("Could not convert to string"); | ||
} | ||
case DETACHED: | ||
{ | ||
return ACTIONS_THREAD_OPTION_DETACHED; | ||
} | ||
case SINGLE_THREAD: | ||
{ | ||
return ACTIONS_THREAD_OPTION_SINGLE_THREAD; | ||
} | ||
case EVENT_LOOP: | ||
{ | ||
return ACTIONS_THREAD_OPTION_EVENT_LOOP; | ||
} | ||
case JOB_QUEUE: | ||
{ | ||
return ACTIONS_THREAD_OPTION_JOB_QUEUE; | ||
} | ||
} | ||
} | ||
|
||
} // namespace ptne |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* This file is part of PTN Engine | ||
* | ||
* Copyright (c) 2024 Eduardo Valgôde | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "PTN_Engine/PTN_Engine.h" | ||
namespace ptne | ||
{ | ||
|
||
class ActionsThreadOptionConversions | ||
{ | ||
public: | ||
static PTN_Engine::ACTIONS_THREAD_OPTION toACTIONS_THREAD_OPTION(const std::string &actionsThreadOptionStr); | ||
static std::string toString(PTN_Engine::ACTIONS_THREAD_OPTION actionsThreadOption); | ||
|
||
private: | ||
static const std::string ACTIONS_THREAD_OPTION_SINGLE_THREAD; | ||
static const std::string ACTIONS_THREAD_OPTION_EVENT_LOOP; | ||
static const std::string ACTIONS_THREAD_OPTION_DETACHED; | ||
static const std::string ACTIONS_THREAD_OPTION_JOB_QUEUE; | ||
}; | ||
|
||
} // namespace ptne |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters