📄 projectmanager.cpp
字号:
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================
#include <stdafx.h> // Precompiled headers.
#include <copyright.h>
#include <kernel/structures/projectmanager.h>
#include <kernel/structures/project.h>
#include <kernel/basic/message.h>
//-------------------------------------------------------------------
// Initialization of static variables.
//===================================================================
Project::Handles *ProjectManager::projects_ = NULL;
//-------------------------------------------------------------------
// Methods for class ProjectManager.
//===================================================================
//-------------------------------------------------------------------
// Method........: GetProject
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Returns the project that the given structure is a
// member of.
// Comments......:
// Revisions.....:
//===================================================================
Project *
ProjectManager::GetProject(const Structure *structure) {
// Any projects present?
if (projects_ == NULL)
return NULL;
// Valid input?
if (structure == NULL)
return NULL;
int i;
// Check for direct match with a project.
for (i = 0; i < projects_->size(); i++) {
if ((*projects_)[i].GetPointer() == structure)
return (*projects_)[i].GetPointer();
}
// Check project membership.
for (i = 0; i < projects_->size(); i++) {
if (structure->FindParent(*(*projects_)[i]) != NULL)
return (*projects_)[i].GetPointer();
}
return NULL;
}
//-------------------------------------------------------------------
// Method........: InsertProject
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Insert a new project into the pool.
// Comments......:
// Revisions.....:
//===================================================================
bool
ProjectManager::InsertProject(const Project *project) {
// Any projects present?
if (projects_ == NULL)
projects_ = new Project::Handles;
// Valid input?
if (project == NULL)
return false;
int i;
// Check is project is already present.
for (i = 0; i < projects_->size(); i++) {
if ((*projects_)[i] == project)
return false;
}
Handle<Project> handle(const_cast(Project *, project));
// Add project to pool
projects_->push_back(handle);
return true;
}
//-------------------------------------------------------------------
// Method........: RemoveProject
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Removes from the pool the project that the given
// structure is a member of.
// Comments......:
// Revisions.....:
//===================================================================
bool
ProjectManager::RemoveProject(const Structure *structure) {
// Any projects present?
if (projects_ == NULL)
return false;
// Valid input?
if (structure == NULL)
return false;
int i;
// Check for direct match with a project.
for (i = 0; i < projects_->size(); i++) {
if ((*projects_)[i].GetPointer() == structure) {
Message::Debug("Removing project " + (*projects_)[i]->GetName() + " from project pool.");
projects_->erase(projects_->begin() + i);
return true;
}
}
// Check project membership.
for (i = 0; i < projects_->size(); i++) {
if (structure->FindParent(*(*projects_)[i]) != NULL) {
Message::Debug("Removing project " + (*projects_)[i]->GetName() + " from project pool.");
projects_->erase(projects_->begin() + i);
return true;
}
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -