![]() |
undoStudio
The IDE of the undoRT ecosystem
|
Singleton service that manages the lifecycle of an undoProject. More...
#include <ProjectManager.hpp>

Public Types | |
| using | OnProjectChanged = std::function< void()> |
Public Member Functions | |
| bool | createProject (const std::string &parentDir, const std::string &name) |
| Create a new project in parentDir/name/ and scaffold all folders. | |
| bool | openProject (const std::string &projectDir) |
| Open an existing project from projectDir. | |
| void | closeProject () |
| Close the current project and reset all state. | |
| bool | saveProject () |
| Write all project configuration files to disk. | |
| bool | isProjectOpen () const |
| const ProjectConfig & | getConfig () const |
| const std::vector< PLCConfig > & | getPLCs () const |
| const std::vector< TaskConfig > & | getTasks () const |
| std::string | getProjectPath () const |
| std::string | getProjectName () const |
| Strictness | getStrictness () const |
| Semantic strictness declared by the open project (Strict when none is open) | |
| const std::vector< std::string > & | recentProjects () const |
| The projects opened most recently, newest first. | |
| size_t | maxRecentProjects () const |
| How many projects the list keeps. | |
| void | setMaxRecentProjects (size_t count) |
| Set how many projects the list keeps. | |
| void | rememberProject (const std::string &projectPath) |
| Put a project at the head of the list, or move it there if it was there. | |
| void | forgetProject (const std::string &projectPath) |
| Take a project out of the list. | |
| void | clearRecentProjects () |
| Empty the list. | |
| void | loadRecents () const |
| Read the list from the state file, once. | |
| bool | addPLC (const std::string &name, const std::string &description="") |
| bool | removePLC (const std::string &name) |
| bool | renamePLC (const std::string &oldName, const std::string &newName) |
| bool | hasPLC (const std::string &name) const |
| bool | addTask (const TaskConfig &task) |
| bool | removeTask (const std::string &name) |
| bool | updateTask (const TaskConfig &task) |
| const TaskConfig * | findTask (const std::string &name) const |
| TaskConfig * | findTask (const std::string &name) |
| bool | setExports (const std::string &plcName, const std::vector< std::string > &programs) |
| std::vector< std::string > | getExports (const std::string &plcName) const |
| std::string | configDir () const |
| .undoProject/ | |
| std::string | undoCorePath () const |
| undoCore/ | |
| std::string | tasksPath () const |
| undoCore/tasks/ | |
| std::string | undoLogicPath () const |
| undoLogic/ | |
| std::string | sharedLibsPath () const |
| std::string | sharedGVLsPath () const |
| std::string | sharedDUTsPath () const |
| std::string | sharedPOUsPath () const |
| std::string | plcPath (const std::string &plcName) const |
| undoLogic/undoPLC_X/ | |
| std::string | plcLibsPath (const std::string &plcName) const |
| std::string | plcGVLsPath (const std::string &plcName) const |
| std::string | plcDUTsPath (const std::string &plcName) const |
| std::string | plcPOUsPath (const std::string &plcName) const |
| std::string | plcExportsPath (const std::string &plcName) const |
| std::string | taskFilePath (const std::string &taskName) const |
| undoCore/tasks/taskName.json | |
| NodeRole | classifyPath (const std::string &path) const |
| Classify a filesystem path relative to the open project. | |
| bool | isConfigFile (const std::string &path) const |
| Whether a path is a configuration file this service owns. | |
| std::string | ownerPLC (const std::string &path) const |
| Find which PLC a path belongs to. | |
| void | setOnProjectChanged (OnProjectChanged cb) |
Static Public Member Functions | |
| static ProjectManager & | getInstance () |
Static Public Attributes | |
| static constexpr size_t | kDefaultMaxRecent = 10 |
| How many projects are kept when nothing has been configured. | |
| static constexpr size_t | kMinRecentLimit = 1 |
| The least and the most a configured limit may be. | |
| static constexpr size_t | kMaxRecentLimit = 100 |
Private Member Functions | |
| ProjectManager ()=default | |
| ~ProjectManager ()=default | |
| ProjectManager (const ProjectManager &)=delete | |
| ProjectManager & | operator= (const ProjectManager &)=delete |
| bool | readProjectJSON () |
| bool | readPLCsJSON () |
| bool | readTasksJSON () |
| bool | readExportsJSON (const std::string &plcName) |
| bool | writeProjectJSON () const |
| bool | writePLCsJSON () const |
| bool | writeTasksJSON () const |
| bool | writeExportsJSON (const std::string &plcName) const |
| bool | writeTaskDetailJSON (const TaskConfig &t) const |
| bool | scaffoldProject (const std::string &path, const std::string &name) |
| bool | scaffoldPLC (const std::string &plcPath) |
| void | notifyChanged () |
Static Private Member Functions | |
| static bool | mkdirs (const std::string &path) |
| static std::string | today () |
Private Attributes | |
| bool | m_isOpen = false |
| std::string | m_projectPath |
| ProjectConfig | m_config |
| std::vector< PLCConfig > | m_plcs |
| std::vector< TaskConfig > | m_tasks |
| std::vector< std::string > | m_recentProjects |
| bool | m_recentsLoaded = false |
| std::map< std::string, std::vector< std::string > > | m_exports |
| OnProjectChanged | m_onChanged |
Singleton service that manages the lifecycle of an undoProject.
| using undoStudio::core::ProjectManager::OnProjectChanged = std::function<void()> |
|
privatedefault |
|
privatedefault |
|
privatedelete |
| bool undoStudio::core::ProjectManager::addPLC | ( | const std::string & | name, |
| const std::string & | description = "" |
||
| ) |
| bool undoStudio::core::ProjectManager::addTask | ( | const TaskConfig & | task | ) |
| NodeRole undoStudio::core::ProjectManager::classifyPath | ( | const std::string & | path | ) | const |
Classify a filesystem path relative to the open project.
| void undoStudio::core::ProjectManager::clearRecentProjects | ( | ) |
Empty the list.
| void undoStudio::core::ProjectManager::closeProject | ( | ) |
Close the current project and reset all state.
| std::string undoStudio::core::ProjectManager::configDir | ( | ) | const |
.undoProject/
| bool undoStudio::core::ProjectManager::createProject | ( | const std::string & | parentDir, |
| const std::string & | name | ||
| ) |
Create a new project in parentDir/name/ and scaffold all folders.
| parentDir | Parent directory (must exist) |
| name | Project name (becomes the folder name and project.json name) |
| TaskConfig * undoStudio::core::ProjectManager::findTask | ( | const std::string & | name | ) |
| const TaskConfig * undoStudio::core::ProjectManager::findTask | ( | const std::string & | name | ) | const |
| void undoStudio::core::ProjectManager::forgetProject | ( | const std::string & | projectPath | ) |
Take a project out of the list.
| projectPath | Absolute path of the project |
|
inline |
| std::vector< std::string > undoStudio::core::ProjectManager::getExports | ( | const std::string & | plcName | ) | const |
|
static |
|
inline |
|
inline |
|
inline |
|
inline |
Semantic strictness declared by the open project (Strict when none is open)
|
inline |
| bool undoStudio::core::ProjectManager::hasPLC | ( | const std::string & | name | ) | const |
| bool undoStudio::core::ProjectManager::isConfigFile | ( | const std::string & | path | ) | const |
Whether a path is a configuration file this service owns.
The editor asks, because these are JSON and so open in the JSON viewer, which shows a tree and cannot be typed into. exports.json in particular is a file the user is told to edit by hand, so it is opened as text instead of as a picture of itself.
|
inline |
| void undoStudio::core::ProjectManager::loadRecents | ( | ) | const |
Read the list from the state file, once.
Const because it is a cache: reading the list does not change what the list is, and recentProjects() is const and has to be able to fill it.
| size_t undoStudio::core::ProjectManager::maxRecentProjects | ( | ) | const |
How many projects the list keeps.
Read from the state file and clamped to kMinRecentLimit..kMaxRecentLimit. Clamped rather than refused because the file is the IDE's own and is edited by hand when something has gone wrong with it: a limit of zero would leave a list that can never be filled, and one of ten thousand would make every frame after a project is opened walk a list nobody asked for.
|
staticprivate |
|
inlineprivate |
| bool undoStudio::core::ProjectManager::openProject | ( | const std::string & | projectDir | ) |
Open an existing project from projectDir.
| projectDir | Directory that contains .undoProject/ |
|
privatedelete |
| std::string undoStudio::core::ProjectManager::ownerPLC | ( | const std::string & | path | ) | const |
Find which PLC a path belongs to.
| std::string undoStudio::core::ProjectManager::plcDUTsPath | ( | const std::string & | plcName | ) | const |
| std::string undoStudio::core::ProjectManager::plcExportsPath | ( | const std::string & | plcName | ) | const |
| std::string undoStudio::core::ProjectManager::plcGVLsPath | ( | const std::string & | plcName | ) | const |
| std::string undoStudio::core::ProjectManager::plcLibsPath | ( | const std::string & | plcName | ) | const |
| std::string undoStudio::core::ProjectManager::plcPath | ( | const std::string & | plcName | ) | const |
undoLogic/undoPLC_X/
| std::string undoStudio::core::ProjectManager::plcPOUsPath | ( | const std::string & | plcName | ) | const |
|
private |
|
private |
|
private |
|
private |
|
inline |
The projects opened most recently, newest first.
Remembered so they can be offered as a list. A project is not reopened on its own: the IDE starting with somebody's project already on disk is a surprise, and a list is one click away from the same place.
Reading the list is what pulls it off disk, on the first call of the run. It has to be here rather than in the code that opens or forgets a project: those are the only calls that used to load it, so a run in which nobody opened anything showed an empty list while the entries sat in the file. That reads as a lost history, and the history was in the state file the whole time.
| void undoStudio::core::ProjectManager::rememberProject | ( | const std::string & | projectPath | ) |
Put a project at the head of the list, or move it there if it was there.
| projectPath | Absolute path of the project |
| bool undoStudio::core::ProjectManager::removePLC | ( | const std::string & | name | ) |
| bool undoStudio::core::ProjectManager::removeTask | ( | const std::string & | name | ) |
| bool undoStudio::core::ProjectManager::renamePLC | ( | const std::string & | oldName, |
| const std::string & | newName | ||
| ) |
| bool undoStudio::core::ProjectManager::saveProject | ( | ) |
Write all project configuration files to disk.
|
private |
|
private |
| bool undoStudio::core::ProjectManager::setExports | ( | const std::string & | plcName, |
| const std::vector< std::string > & | programs | ||
| ) |
| void undoStudio::core::ProjectManager::setMaxRecentProjects | ( | size_t | count | ) |
Set how many projects the list keeps.
| count | The new limit, clamped the same way maxRecentProjects() is |
|
inline |
| std::string undoStudio::core::ProjectManager::sharedDUTsPath | ( | ) | const |
| std::string undoStudio::core::ProjectManager::sharedGVLsPath | ( | ) | const |
| std::string undoStudio::core::ProjectManager::sharedLibsPath | ( | ) | const |
| std::string undoStudio::core::ProjectManager::sharedPOUsPath | ( | ) | const |
| std::string undoStudio::core::ProjectManager::taskFilePath | ( | const std::string & | taskName | ) | const |
undoCore/tasks/taskName.json
| std::string undoStudio::core::ProjectManager::tasksPath | ( | ) | const |
undoCore/tasks/
|
staticprivate |
| std::string undoStudio::core::ProjectManager::undoCorePath | ( | ) | const |
undoCore/
| std::string undoStudio::core::ProjectManager::undoLogicPath | ( | ) | const |
undoLogic/
| bool undoStudio::core::ProjectManager::updateTask | ( | const TaskConfig & | task | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |
How many projects are kept when nothing has been configured.
|
staticconstexpr |
|
staticconstexpr |
The least and the most a configured limit may be.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
Opened projects, newest first. Mutable because reading the list fills it, and reading is const.
|
mutableprivate |
|
private |