#include <QJsonArray> #include <QJsonObject> #include "Project.h" namespace p4_project_services { const QString Project::CONTENT_TYPE = "application/vnd.perforce.project.v1+json"; // A ViewNode updates the underlying JSON document as it receives changes // from afar. A ViewNode can be 'detached', but, is expected to be attached // to a JSON array instance before being serialized. class Project::ViewNode : public View { public: ViewNode(Project::Impl & impl); virtual ~ViewNode(); virtual void setDepotPath(const QString & path); virtual void setViewPath(const QString & path); void setParent(BranchNode *parent, int index); void setObject(const QJsonObject & object); private: Project::Impl & mImpl; BranchNode *mParent; int mIndex; QJsonObject mObject; // Disabled methods private: ViewNode(); ViewNode(const ViewNode & v); }; // The BranchNode maintains a reference to the Project implementation, // in order to maintain the underlying JSON document for all manipulation. class Project::BranchNode : public Branch { public: BranchNode(Impl & impl); virtual ~BranchNode(); virtual void setId(const QString & id); virtual void setName(const QString & name); virtual void clearView(); virtual void addView(const ViewPtr & v); virtual void setStream(const QString & stream); void setIndex(int index); void setObject(const QJsonObject & o); void replaceViewObject(int index, const QJsonObject & o); private: void addEmptyView(); private: Impl & mImpl; int mIndex; QJsonObject mObject; // Disabled methods private: BranchNode(); BranchNode(const BranchNode & b); }; // Most of the actual project structure keeps a JSON document up to date. class Project::Impl { public: QJsonDocument mDocument; QList<BranchPtr> mBranches; void replaceBranchObject(int index, const QJsonObject & o); void updateBranches(); void resetDocument(const QJsonDocument & d); void addBranch(const BranchPtr & branch); void clearBranches(); }; Project::ViewNode::ViewNode(Impl & impl) : mImpl(impl), mIndex(-1), mObject() { View::View(); } Project::ViewNode::~ViewNode() { View::~View(); } void Project::ViewNode::setDepotPath(const QString & path) { mObject["depotPath"] = path; if (0 <= mIndex) { mImpl.replaceBranchObject(mIndex, mObject); } View::setDepotPath(path); } void Project::ViewNode::setViewPath(const QString & path) { mObject["viewPath"] = path; if (0 <= mIndex) { mImpl.replaceBranchObject(mIndex, mObject); } View::setViewPath(path); } void Project::ViewNode::setParent(BranchNode *parent, int index) { mParent = parent; mIndex = index; mParent->replaceViewObject(mIndex, mObject); } void Project::ViewNode::setObject(const QJsonObject & object) { mObject = object; if (0 <= mIndex) { mImpl.replaceBranchObject(mIndex, mObject); } } Project::BranchNode::BranchNode(Impl & impl) : mImpl(impl), mIndex(-1), mObject() { Branch::Branch(); } Project::BranchNode::~BranchNode() { Branch::~Branch(); } void Project::BranchNode::addEmptyView() { // append the view object to the list, to obtain the index ViewNodePtr viewNode = ViewNodePtr::create(mImpl); Branch::addView(viewNode); int idx = Branch::view().length() - 1; viewNode->setParent(this, idx); } void Project::BranchNode::setId(const QString & id) { mObject["id"] = id; if (0 <= mIndex) { mImpl.replaceBranchObject(mIndex, mObject); } Branch::setId(id); } void Project::BranchNode::setName(const QString & name) { mObject["name"] = name; if (0 <= mIndex) { mImpl.replaceBranchObject(mIndex, mObject); } Branch::setName(name); } void Project::BranchNode::setStream(const QString & stream) { mObject["stream"] = stream; if (0 <= mIndex) { mImpl.replaceBranchObject(mIndex, mObject); } Branch::setStream(stream); } void Project::BranchNode::clearView() { mObject["view"] = QJsonArray(); if (0 <= mIndex) { mImpl.replaceBranchObject(mIndex, mObject); } Branch::clearView(); } void Project::BranchNode::addView(const ViewPtr & v) { if (!mObject.contains("view")) { mObject["view"] = QJsonArray(); } addEmptyView(); *(mView.last()) = *v; if (0 <= mIndex) { mImpl.replaceBranchObject(mIndex, mObject); } } void Project::BranchNode::setIndex(int index) { mIndex = index; mImpl.replaceBranchObject(mIndex, mObject); } void Project::BranchNode::setObject(const QJsonObject & o) { mObject = o; if (0 <= mIndex) { mImpl.replaceBranchObject(mIndex, mObject); } } void Project::BranchNode::replaceViewObject(int index, const QJsonObject & o) { auto view = mObject["view"].toArray(); view.replace(index, o); mObject["view"] = view; } void Project::Impl::replaceBranchObject(int index, const QJsonObject & o) { auto branches = mDocument.object()["branches"].toArray(); branches.replace(index, o); mDocument.object()["branches"] = o; } void Project::Impl::updateBranches() { if (mDocument.object().contains("branches")) { auto branches = mDocument.object()["branches"].toArray(); for (auto branchRef : branches) { BranchNodePtr branchNode = BranchNodePtr::create(*this); mBranches.append(branchNode); mBranches.last().staticCast<BranchNode>() ->setObject(branchRef.toObject()); } } } void Project::Impl::addBranch(const BranchPtr & branch) { BranchNodePtr branchNode = BranchNodePtr::create(*this); mBranches.append(branchNode); *(mBranches.last()) = *branch; } void Project::Impl::clearBranches() { if (mDocument.object().contains("branches")) { mDocument.object()["branches"] = QJsonArray(); } } void Project::Impl::resetDocument(const QJsonDocument & d) { mDocument = d; updateBranches(); } Project::Project() : mImpl(new Impl()) { } Project::Project(const Project & p) : mImpl(new Impl()) { mImpl->mDocument = p.mImpl->mDocument; mImpl->updateBranches(); } Project::~Project() { delete mImpl; } Project & Project::operator=(const Project & p) { mImpl->resetDocument(p.mImpl->mDocument); return *this; } QJsonDocument & Project::document() { return mImpl->mDocument; } const QJsonDocument & Project::document() const { return mImpl->mDocument; } void Project::setDocument(const QJsonDocument & document) { mImpl->mDocument = document; } QString Project::id() const { return mImpl->mDocument.object()["id"].toString(); } void Project::setId(const QString & id) { mImpl->mDocument.object()["id"] = id; } QString Project::name() const { return mImpl->mDocument.object()["name"].toString(); } void Project::setName(const QString & name) { mImpl->mDocument.object()["name"] = name; } int Project::version() const { return mImpl->mDocument.object()["version"].toDouble(); } QString Project::description() const { return mImpl->mDocument.object()["description"].toString(); } void Project::setDescription(QString description) { mImpl->mDocument.object()["description"] = description; } const QList<BranchPtr> & Project::branches() const { return mImpl->mBranches; } void Project::addBranch(const BranchPtr & branch) { mImpl->addBranch(branch); } void Project::clearBranches() { mImpl->clearBranches(); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 14025 | tjuricek |
Revise Qt SDK to a single 'helix_web_services_client' project. Most references to "Phoenix" have now been removed. Additionally, this is more similar to the other platform client SDKs in Ruby and JavaScript. Documentation via Doxygen is now available, and will be how much of the SDK reference should occur. |
||
#4 | 13506 | tjuricek |
Change to a C++03 build. Major changes: 1. QSharedPointer::create(...) is much more restricted than in C++11, so just use the .reset() method unless you're passing in a single const reference argument to the constructor. 2. Using Qt's foreach. 3. Replace lambdas with simpler helper methods. This seems to work, but we may have subtle memory issues I'm not 100% on top of yet. |
||
#3 | 13448 | tjuricek |
Add unit test for PhoenixProject class to verify techniques at manipulating and serializing the model to and from JSON. Use phoenixProjectFromJson() to load the PhoenixProject directly now. |
||
#2 | 13444 | tjuricek | Fixing references to base class constructors that are actually caught by gcc on Linux. | ||
#1 | 13443 | tjuricek |
Reorganized the Qt libraries into a separate part of the tree, to make it easier for CMake configuration. Added 'qt_build' and 'qt_test' tasks to at least execute tests and fail the build if they don't pass. Started the implementation of the project library interaction. Change: 1018651 Date: 3/4/15 11:43 AM Client: tjuricek_dhcp-141-n100_5959 User: tjuricek Status: pending Type: public Description: Reorganized the Qt libraries into a separate part of the tree, to make it easier for CMake configuration. Added 'qt_build' and 'qt_test' tasks to at least execute tests and fail the build if they don't pass. Started the implementation of the project library interaction. JobStatus: Jobs: Files: //web-services/p4ws-main/Rakefile //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/CMakeLists.txt //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/PhoenixIntegrationTests.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/README //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/PhoenixProject.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/PhoenixProject.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/PhoenixServicesClient.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/PhoenixServicesClient.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/RequestError.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/RequestError.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/Session.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/Session.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/test/SessionTests.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/test/SessionTests.h //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/CMakeLists.txt //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services.h //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/Branch.cpp //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/Branch.h //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/Project.cpp //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/Project.h //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/View.cpp //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/View.h //web-services/p4ws-main/qt/CMakeLists.txt //web-services/p4ws-main/qt/p4_phoenix_services_client/CMakeLists.txt //web-services/p4ws-main/qt/p4_phoenix_services_client/PhoenixIntegrationTests.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/README //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix.h //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/PhoenixProject.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/PhoenixProject.h //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/PhoenixServicesClient.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/PhoenixServicesClient.h //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/RequestError.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/RequestError.h //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/Session.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/Session.h //web-services/p4ws-main/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.h //web-services/p4ws-main/qt/p4_phoenix_services_client/test/SessionTests.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/test/SessionTests.h //web-services/p4ws-main/qt/p4_project_services_client/CMakeLists.txt //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeCache.txt //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeCCompiler.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeCXXCompiler.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeDetermineCompilerABI_C.bin //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeDetermineCompilerABI_CXX.bin //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeSystem.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CompilerIdC/CMakeCCompilerId.c //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CompilerIdC/a.out //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CompilerIdCXX/CMakeCXXCompilerId.cpp //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CompilerIdCXX/a.out //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/CMakeDirectoryInformation.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/CMakeOutput.log //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/Makefile.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/Makefile2 //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/TargetDirectories.txt //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/cmake.check_cache //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/DependInfo.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/build.make //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/cmake_clean.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/cmake_clean_target.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/depend.make //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/flags.make //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/link.txt //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/progress.make //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/progress.marks //web-services/p4ws-main/qt/p4_project_services_client/build/Makefile //web-services/p4ws-main/qt/p4_project_services_client/build/cmake_install.cmake //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services.h //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/Branch.cpp //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/Branch.h //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/Project.cpp //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/Project.h //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/View.cpp //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/View.h |
||
//guest/perforce_software/helix-web-services/main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/Project.cpp | |||||
#1 | 13423 | tjuricek | Renaming files to match case of primary public class. | ||
//guest/perforce_software/helix-web-services/main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/project.cpp | |||||
#1 | 13422 | tjuricek |
First-pass at Qt Client API for Phoenix web services. The underlying project data is organized as the basic 'p4_project_services' API, which is then used by the higher-level 'phoenix' API, just to cut down on a lot of potential boiler plate. The base project model should allow for custom extensions, but it's aniticpated that the product-specific stuff doesn't really need to care too much about this. We just need to make sure that if new product extensions exist that the C++ API doesn't know about, they: a.) don't explode on read because there's something new, and b.) don't just delete the extension code. Note: not tested. Going to build out a phoenix client to start coordinating design first. |