diff --git a/bindings/python_internal/core.i b/bindings/python_internal/core.i index 5bc574624..ed27e0195 100644 --- a/bindings/python_internal/core.i +++ b/bindings/python_internal/core.i @@ -27,7 +27,8 @@ #include "CTiglMemoryPool.h" #include "CTiglError.h" #include "CCPACSStringVector.h" -#include "generated/CPACSUpdates.h" +#include "generated/CPACSVersionInfo.h" +#include "generated/CPACSVersionInfos.h" #include "generated/CPACSHeader.h" #include "CTiglUIDObject.h" #include "ITiglUIDRefObject.h" @@ -49,6 +50,7 @@ %include "CTiglMemoryPool.h" %include "generated/CPACSStringVectorBase.h" %include "CCPACSStringVector.h" -%include "generated/CPACSUpdates.h" +%include "generated/CPACSVersionInfo.h" +%include "generated/CPACSVersionInfos.h" %include "generated/CPACSHeader.h" diff --git a/cpacs_gen_input/PruneList.txt b/cpacs_gen_input/PruneList.txt index 05cf95c59..5661c9373 100644 --- a/cpacs_gen_input/PruneList.txt +++ b/cpacs_gen_input/PruneList.txt @@ -7,6 +7,9 @@ CPACSMissionDefinitions CPACSStudies CPACSMaterial +// in header +CPACSChangeLog + // in toolspecific CPACSToolspecific diff --git a/cpacs_gen_input/cpacs_schema.xsd b/cpacs_gen_input/cpacs_schema.xsd index c60f06237..0c8f3bebb 100644 --- a/cpacs_gen_input/cpacs_schema.xsd +++ b/cpacs_gen_input/cpacs_schema.xsd @@ -823,40 +823,26 @@ marko.alder@dlr.de Name of CPACS dataset - + Description of CPACS dataset - - - Creator of initial CPACS dataset - - - - - - Timestamp of initial CPACS dataset creation - - - - + - Version of initial CPACS dataset + Version of initial CPACS dataset according to the Semantic Versioning 2.0.0 standard. - + - CPACS version that the dataset is valid to. The element is optional, since data sets - can be valid for several CPACS versions. However, we strongly recommend to assign data sets to a - specific CPACS version as far as possible, especially since some tools and libraries (e.g. TiGL) - require this specification. + DEPRECATED: Should only be set to allow TiGL to open the file until TiGL is adopted accordingly. + Will be replaced by the cpacsVersion element in versionInfos. - + @@ -34132,4 +34118,122 @@ The fuel tank volume type should also be used for the wing fuel tank + + + + + + Version Informations + + + + + + + + + + + + + + + + + + + Version Information + + + + + + + + + + CPACS version of the dataset + + + + + + Description of CPACS dataset + + + + + + Timestamp of initial CPACS dataset creation + + + + + + Creator of initial CPACS dataset + + + + + + + + + + + + + + + + Change log + + + + + + + + + + + + + + + + + + + Log entry + + + + + + + + + + Description of CPACS dataset + + + + + + Timestamp + + + + + + Creator (tool, person, etc.) + + + + + + + + diff --git a/src/api/tigl.cpp b/src/api/tigl.cpp index b5ff085cf..51972b3e3 100644 --- a/src/api/tigl.cpp +++ b/src/api/tigl.cpp @@ -171,7 +171,15 @@ TIGL_COMMON_EXPORT TiglReturnCode tiglOpenCPACSConfiguration(TixiDocumentHandle /* check CPACS Version */ { char* cpacsVersionStr = NULL; - ReturnCode tixiRet = tixiGetTextElement(tixiHandle, "/cpacs/header/cpacsVersion", &cpacsVersionStr); + + // Default behavior: CPACS versioning since v3.5 + ReturnCode tixiRet = tixiGetTextElement(tixiHandle, "/cpacs/header/versionInfos/versionInfo[@version=../../version]/cpacsVersion", &cpacsVersionStr); + + // CPACS versioning until v3.4 + // Note: should return a deprication warning when TiGL is at v3.5 + if (tixiRet != SUCCESS) { + tixiRet = tixiGetTextElement(tixiHandle, "/cpacs/header/cpacsVersion", &cpacsVersionStr); + } if (tixiRet != SUCCESS) { // NO CPACS Version Information in Header diff --git a/src/generated/CPACSHeader.cpp b/src/generated/CPACSHeader.cpp index d25e38d1e..4d042b69e 100644 --- a/src/generated/CPACSHeader.cpp +++ b/src/generated/CPACSHeader.cpp @@ -28,7 +28,7 @@ namespace tigl namespace generated { CPACSHeader::CPACSHeader(CPACSCpacs* parent) - : m_timestamp(0) + : m_versionInfos(this) { //assert(parent != NULL); m_parent = parent; @@ -85,25 +85,6 @@ namespace generated } } - // read element creator - if (tixi::TixiCheckElement(tixiHandle, xpath + "/creator")) { - m_creator = tixi::TixiGetElement(tixiHandle, xpath + "/creator"); - if (m_creator.empty()) { - LOG(WARNING) << "Required element creator is empty at xpath " << xpath; - } - } - else { - LOG(ERROR) << "Required element creator is missing at xpath " << xpath; - } - - // read element timestamp - if (tixi::TixiCheckElement(tixiHandle, xpath + "/timestamp")) { - m_timestamp = tixi::TixiGetElement(tixiHandle, xpath + "/timestamp"); - } - else { - LOG(ERROR) << "Required element timestamp is missing at xpath " << xpath; - } - // read element version if (tixi::TixiCheckElement(tixiHandle, xpath + "/version")) { m_version = tixi::TixiGetElement(tixiHandle, xpath + "/version"); @@ -123,15 +104,12 @@ namespace generated } } - // read element updates - if (tixi::TixiCheckElement(tixiHandle, xpath + "/updates")) { - m_updates = boost::in_place(this); - try { - m_updates->ReadCPACS(tixiHandle, xpath + "/updates"); - } catch(const std::exception& e) { - LOG(ERROR) << "Failed to read updates at xpath " << xpath << ": " << e.what(); - m_updates = boost::none; - } + // read element versionInfos + if (tixi::TixiCheckElement(tixiHandle, xpath + "/versionInfos")) { + m_versionInfos.ReadCPACS(tixiHandle, xpath + "/versionInfos"); + } + else { + LOG(ERROR) << "Required element versionInfos is missing at xpath " << xpath; } } @@ -153,14 +131,6 @@ namespace generated } } - // write element creator - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/creator"); - tixi::TixiSaveElement(tixiHandle, xpath + "/creator", m_creator); - - // write element timestamp - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/timestamp"); - tixi::TixiSaveElement(tixiHandle, xpath + "/timestamp", m_timestamp); - // write element version tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/version"); tixi::TixiSaveElement(tixiHandle, xpath + "/version", m_version); @@ -176,16 +146,9 @@ namespace generated } } - // write element updates - if (m_updates) { - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/updates"); - m_updates->WriteCPACS(tixiHandle, xpath + "/updates"); - } - else { - if (tixi::TixiCheckElement(tixiHandle, xpath + "/updates")) { - tixi::TixiRemoveElement(tixiHandle, xpath + "/updates"); - } - } + // write element versionInfos + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/versionInfos"); + m_versionInfos.WriteCPACS(tixiHandle, xpath + "/versionInfos"); } @@ -209,26 +172,6 @@ namespace generated m_description = value; } - const std::string& CPACSHeader::GetCreator() const - { - return m_creator; - } - - void CPACSHeader::SetCreator(const std::string& value) - { - m_creator = value; - } - - const std::time_t& CPACSHeader::GetTimestamp() const - { - return m_timestamp; - } - - void CPACSHeader::SetTimestamp(const std::time_t& value) - { - m_timestamp = value; - } - const std::string& CPACSHeader::GetVersion() const { return m_version; @@ -249,26 +192,14 @@ namespace generated m_cpacsVersion = value; } - const boost::optional& CPACSHeader::GetUpdates() const - { - return m_updates; - } - - boost::optional& CPACSHeader::GetUpdates() - { - return m_updates; - } - - CPACSUpdates& CPACSHeader::GetUpdates(CreateIfNotExistsTag) + const CPACSVersionInfos& CPACSHeader::GetVersionInfos() const { - if (!m_updates) - m_updates = boost::in_place(this); - return *m_updates; + return m_versionInfos; } - void CPACSHeader::RemoveUpdates() + CPACSVersionInfos& CPACSHeader::GetVersionInfos() { - m_updates = boost::none; + return m_versionInfos; } } // namespace generated diff --git a/src/generated/CPACSHeader.h b/src/generated/CPACSHeader.h index b936eb464..528ac4b09 100644 --- a/src/generated/CPACSHeader.h +++ b/src/generated/CPACSHeader.h @@ -19,11 +19,9 @@ #include #include -#include #include #include -#include "CPACSUpdates.h" -#include "CreateIfNotExists.h" +#include "CPACSVersionInfos.h" #include "tigl_internal.h" namespace tigl @@ -64,49 +62,32 @@ namespace generated TIGL_EXPORT virtual const boost::optional& GetDescription() const; TIGL_EXPORT virtual void SetDescription(const boost::optional& value); - TIGL_EXPORT virtual const std::string& GetCreator() const; - TIGL_EXPORT virtual void SetCreator(const std::string& value); - - TIGL_EXPORT virtual const std::time_t& GetTimestamp() const; - TIGL_EXPORT virtual void SetTimestamp(const std::time_t& value); - TIGL_EXPORT virtual const std::string& GetVersion() const; TIGL_EXPORT virtual void SetVersion(const std::string& value); TIGL_EXPORT virtual const boost::optional& GetCpacsVersion() const; TIGL_EXPORT virtual void SetCpacsVersion(const boost::optional& value); - TIGL_EXPORT virtual const boost::optional& GetUpdates() const; - TIGL_EXPORT virtual boost::optional& GetUpdates(); - - TIGL_EXPORT virtual CPACSUpdates& GetUpdates(CreateIfNotExistsTag); - TIGL_EXPORT virtual void RemoveUpdates(); + TIGL_EXPORT virtual const CPACSVersionInfos& GetVersionInfos() const; + TIGL_EXPORT virtual CPACSVersionInfos& GetVersionInfos(); protected: CPACSCpacs* m_parent; /// Name of CPACS dataset - std::string m_name; + std::string m_name; /// Description of CPACS dataset - boost::optional m_description; - - /// Creator of initial CPACS dataset - std::string m_creator; - - /// Timestamp of initial CPACS dataset creation - std::time_t m_timestamp; + boost::optional m_description; - /// Version of initial CPACS dataset - std::string m_version; + /// Version of initial CPACS dataset according to the Semantic Versioning 2.0.0 standard. + std::string m_version; - /// CPACS version that the dataset is valid to. The element is optional, since data sets - /// can be valid for several CPACS versions. However, we strongly recommend to assign data sets to a - /// specific CPACS version as far as possible, especially since some tools and libraries (e.g. TiGL) - /// require this specification. - boost::optional m_cpacsVersion; + /// DEPRECATED: Should only be set to allow TiGL to open the file until TiGL is adopted accordingly. + /// Will be replaced by the cpacsVersion element in versionInfos. + boost::optional m_cpacsVersion; - boost::optional m_updates; + CPACSVersionInfos m_versionInfos; private: CPACSHeader(const CPACSHeader&) = delete; diff --git a/src/generated/CPACSUpdates.cpp b/src/generated/CPACSUpdates.cpp deleted file mode 100644 index 20db5a505..000000000 --- a/src/generated/CPACSUpdates.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2020 RISC Software GmbH -// -// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). -// Do not edit, all changes are lost when files are re-generated. -// -// 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 -#include "CPACSHeader.h" -#include "CPACSUpdate.h" -#include "CPACSUpdates.h" -#include "CTiglError.h" -#include "CTiglLogging.h" -#include "CTiglUIDObject.h" -#include "TixiHelper.h" - -namespace tigl -{ -namespace generated -{ - CPACSUpdates::CPACSUpdates(CPACSHeader* parent) - { - //assert(parent != NULL); - m_parent = parent; - } - - CPACSUpdates::~CPACSUpdates() - { - } - - const CPACSHeader* CPACSUpdates::GetParent() const - { - return m_parent; - } - - CPACSHeader* CPACSUpdates::GetParent() - { - return m_parent; - } - - const CTiglUIDObject* CPACSUpdates::GetNextUIDParent() const - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - CTiglUIDObject* CPACSUpdates::GetNextUIDParent() - { - if (m_parent) { - return m_parent->GetNextUIDParent(); - } - return nullptr; - } - - void CPACSUpdates::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) - { - // read element update - if (tixi::TixiCheckElement(tixiHandle, xpath + "/update")) { - tixi::TixiReadElements(tixiHandle, xpath + "/update", m_updates, 1, tixi::xsdUnbounded, this); - } - - } - - void CPACSUpdates::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const - { - // write element update - tixi::TixiSaveElements(tixiHandle, xpath + "/update", m_updates); - - } - - const std::vector>& CPACSUpdates::GetUpdates() const - { - return m_updates; - } - - std::vector>& CPACSUpdates::GetUpdates() - { - return m_updates; - } - - CPACSUpdate& CPACSUpdates::AddUpdate() - { - m_updates.push_back(make_unique(this)); - return *m_updates.back(); - } - - void CPACSUpdates::RemoveUpdate(CPACSUpdate& ref) - { - for (std::size_t i = 0; i < m_updates.size(); i++) { - if (m_updates[i].get() == &ref) { - m_updates.erase(m_updates.begin() + i); - return; - } - } - throw CTiglError("Element not found"); - } - -} // namespace generated -} // namespace tigl diff --git a/src/generated/CPACSUpdate.cpp b/src/generated/CPACSVersionInfo.cpp similarity index 62% rename from src/generated/CPACSUpdate.cpp rename to src/generated/CPACSVersionInfo.cpp index cecbed1ec..595de8975 100644 --- a/src/generated/CPACSUpdate.cpp +++ b/src/generated/CPACSVersionInfo.cpp @@ -16,8 +16,8 @@ // limitations under the License. #include -#include "CPACSUpdate.h" -#include "CPACSUpdates.h" +#include "CPACSVersionInfo.h" +#include "CPACSVersionInfos.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDObject.h" @@ -27,28 +27,28 @@ namespace tigl { namespace generated { - CPACSUpdate::CPACSUpdate(CPACSUpdates* parent) + CPACSVersionInfo::CPACSVersionInfo(CPACSVersionInfos* parent) : m_timestamp(0) { //assert(parent != NULL); m_parent = parent; } - CPACSUpdate::~CPACSUpdate() + CPACSVersionInfo::~CPACSVersionInfo() { } - const CPACSUpdates* CPACSUpdate::GetParent() const + const CPACSVersionInfos* CPACSVersionInfo::GetParent() const { return m_parent; } - CPACSUpdates* CPACSUpdate::GetParent() + CPACSVersionInfos* CPACSVersionInfo::GetParent() { return m_parent; } - const CTiglUIDObject* CPACSUpdate::GetNextUIDParent() const + const CTiglUIDObject* CPACSVersionInfo::GetNextUIDParent() const { if (m_parent) { return m_parent->GetNextUIDParent(); @@ -56,7 +56,7 @@ namespace generated return nullptr; } - CTiglUIDObject* CPACSUpdate::GetNextUIDParent() + CTiglUIDObject* CPACSVersionInfo::GetNextUIDParent() { if (m_parent) { return m_parent->GetNextUIDParent(); @@ -64,134 +64,133 @@ namespace generated return nullptr; } - void CPACSUpdate::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + void CPACSVersionInfo::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) { - // read element modification - if (tixi::TixiCheckElement(tixiHandle, xpath + "/modification")) { - m_modification = tixi::TixiGetElement(tixiHandle, xpath + "/modification"); - if (m_modification.empty()) { - LOG(WARNING) << "Required element modification is empty at xpath " << xpath; + // read attribute version + if (tixi::TixiCheckAttribute(tixiHandle, xpath, "version")) { + m_version = tixi::TixiGetAttribute(tixiHandle, xpath, "version"); + if (m_version.empty()) { + LOG(WARNING) << "Required attribute version is empty at xpath " << xpath; } } else { - LOG(ERROR) << "Required element modification is missing at xpath " << xpath; + LOG(ERROR) << "Required attribute version is missing at xpath " << xpath; } - // read element creator - if (tixi::TixiCheckElement(tixiHandle, xpath + "/creator")) { - m_creator = tixi::TixiGetElement(tixiHandle, xpath + "/creator"); - if (m_creator.empty()) { - LOG(WARNING) << "Required element creator is empty at xpath " << xpath; + // read element cpacsVersion + if (tixi::TixiCheckElement(tixiHandle, xpath + "/cpacsVersion")) { + m_cpacsVersion = tixi::TixiGetElement(tixiHandle, xpath + "/cpacsVersion"); + if (m_cpacsVersion.empty()) { + LOG(WARNING) << "Required element cpacsVersion is empty at xpath " << xpath; } } else { - LOG(ERROR) << "Required element creator is missing at xpath " << xpath; + LOG(ERROR) << "Required element cpacsVersion is missing at xpath " << xpath; } - // read element timestamp - if (tixi::TixiCheckElement(tixiHandle, xpath + "/timestamp")) { - m_timestamp = tixi::TixiGetElement(tixiHandle, xpath + "/timestamp"); + // read element description + if (tixi::TixiCheckElement(tixiHandle, xpath + "/description")) { + m_description = tixi::TixiGetElement(tixiHandle, xpath + "/description"); + if (m_description.empty()) { + LOG(WARNING) << "Required element description is empty at xpath " << xpath; + } } else { - LOG(ERROR) << "Required element timestamp is missing at xpath " << xpath; + LOG(ERROR) << "Required element description is missing at xpath " << xpath; } - // read element version - if (tixi::TixiCheckElement(tixiHandle, xpath + "/version")) { - m_version = tixi::TixiGetElement(tixiHandle, xpath + "/version"); - if (m_version.empty()) { - LOG(WARNING) << "Required element version is empty at xpath " << xpath; - } + // read element timestamp + if (tixi::TixiCheckElement(tixiHandle, xpath + "/timestamp")) { + m_timestamp = tixi::TixiGetElement(tixiHandle, xpath + "/timestamp"); } else { - LOG(ERROR) << "Required element version is missing at xpath " << xpath; + LOG(ERROR) << "Required element timestamp is missing at xpath " << xpath; } - // read element cpacsVersion - if (tixi::TixiCheckElement(tixiHandle, xpath + "/cpacsVersion")) { - m_cpacsVersion = tixi::TixiGetElement(tixiHandle, xpath + "/cpacsVersion"); - if (m_cpacsVersion.empty()) { - LOG(WARNING) << "Required element cpacsVersion is empty at xpath " << xpath; + // read element creator + if (tixi::TixiCheckElement(tixiHandle, xpath + "/creator")) { + m_creator = tixi::TixiGetElement(tixiHandle, xpath + "/creator"); + if (m_creator.empty()) { + LOG(WARNING) << "Required element creator is empty at xpath " << xpath; } } else { - LOG(ERROR) << "Required element cpacsVersion is missing at xpath " << xpath; + LOG(ERROR) << "Required element creator is missing at xpath " << xpath; } } - void CPACSUpdate::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + void CPACSVersionInfo::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const { - // write element modification - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/modification"); - tixi::TixiSaveElement(tixiHandle, xpath + "/modification", m_modification); + // write attribute version + tixi::TixiSaveAttribute(tixiHandle, xpath, "version", m_version); - // write element creator - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/creator"); - tixi::TixiSaveElement(tixiHandle, xpath + "/creator", m_creator); + // write element cpacsVersion + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/cpacsVersion"); + tixi::TixiSaveElement(tixiHandle, xpath + "/cpacsVersion", m_cpacsVersion); + + // write element description + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/description"); + tixi::TixiSaveElement(tixiHandle, xpath + "/description", m_description); // write element timestamp tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/timestamp"); tixi::TixiSaveElement(tixiHandle, xpath + "/timestamp", m_timestamp); - // write element version - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/version"); - tixi::TixiSaveElement(tixiHandle, xpath + "/version", m_version); - - // write element cpacsVersion - tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/cpacsVersion"); - tixi::TixiSaveElement(tixiHandle, xpath + "/cpacsVersion", m_cpacsVersion); + // write element creator + tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/creator"); + tixi::TixiSaveElement(tixiHandle, xpath + "/creator", m_creator); } - const std::string& CPACSUpdate::GetModification() const + const std::string& CPACSVersionInfo::GetVersion() const { - return m_modification; + return m_version; } - void CPACSUpdate::SetModification(const std::string& value) + void CPACSVersionInfo::SetVersion(const std::string& value) { - m_modification = value; + m_version = value; } - const std::string& CPACSUpdate::GetCreator() const + const std::string& CPACSVersionInfo::GetCpacsVersion() const { - return m_creator; + return m_cpacsVersion; } - void CPACSUpdate::SetCreator(const std::string& value) + void CPACSVersionInfo::SetCpacsVersion(const std::string& value) { - m_creator = value; + m_cpacsVersion = value; } - const std::time_t& CPACSUpdate::GetTimestamp() const + const std::string& CPACSVersionInfo::GetDescription() const { - return m_timestamp; + return m_description; } - void CPACSUpdate::SetTimestamp(const std::time_t& value) + void CPACSVersionInfo::SetDescription(const std::string& value) { - m_timestamp = value; + m_description = value; } - const std::string& CPACSUpdate::GetVersion() const + const std::time_t& CPACSVersionInfo::GetTimestamp() const { - return m_version; + return m_timestamp; } - void CPACSUpdate::SetVersion(const std::string& value) + void CPACSVersionInfo::SetTimestamp(const std::time_t& value) { - m_version = value; + m_timestamp = value; } - const std::string& CPACSUpdate::GetCpacsVersion() const + const std::string& CPACSVersionInfo::GetCreator() const { - return m_cpacsVersion; + return m_creator; } - void CPACSUpdate::SetCpacsVersion(const std::string& value) + void CPACSVersionInfo::SetCreator(const std::string& value) { - m_cpacsVersion = value; + m_creator = value; } } // namespace generated diff --git a/src/generated/CPACSUpdate.h b/src/generated/CPACSVersionInfo.h similarity index 64% rename from src/generated/CPACSUpdate.h rename to src/generated/CPACSVersionInfo.h index 85b452313..4705c5f01 100644 --- a/src/generated/CPACSUpdate.h +++ b/src/generated/CPACSVersionInfo.h @@ -28,26 +28,24 @@ class CTiglUIDObject; namespace generated { - class CPACSUpdates; + class CPACSVersionInfos; // This class is used in: - // CPACSUpdates + // CPACSVersionInfos - /// @brief updateType + /// @brief Version Information /// - /// Update type, containing a datablock for each update of - /// the CPACS dataset /// - class CPACSUpdate + class CPACSVersionInfo { public: - TIGL_EXPORT CPACSUpdate(CPACSUpdates* parent); + TIGL_EXPORT CPACSVersionInfo(CPACSVersionInfos* parent); - TIGL_EXPORT virtual ~CPACSUpdate(); + TIGL_EXPORT virtual ~CPACSVersionInfo(); - TIGL_EXPORT CPACSUpdates* GetParent(); + TIGL_EXPORT CPACSVersionInfos* GetParent(); - TIGL_EXPORT const CPACSUpdates* GetParent() const; + TIGL_EXPORT const CPACSVersionInfos* GetParent() const; TIGL_EXPORT virtual CTiglUIDObject* GetNextUIDParent(); TIGL_EXPORT virtual const CTiglUIDObject* GetNextUIDParent() const; @@ -55,50 +53,48 @@ namespace generated TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; - TIGL_EXPORT virtual const std::string& GetModification() const; - TIGL_EXPORT virtual void SetModification(const std::string& value); - - TIGL_EXPORT virtual const std::string& GetCreator() const; - TIGL_EXPORT virtual void SetCreator(const std::string& value); - - TIGL_EXPORT virtual const std::time_t& GetTimestamp() const; - TIGL_EXPORT virtual void SetTimestamp(const std::time_t& value); - TIGL_EXPORT virtual const std::string& GetVersion() const; TIGL_EXPORT virtual void SetVersion(const std::string& value); TIGL_EXPORT virtual const std::string& GetCpacsVersion() const; TIGL_EXPORT virtual void SetCpacsVersion(const std::string& value); - protected: - CPACSUpdates* m_parent; + TIGL_EXPORT virtual const std::string& GetDescription() const; + TIGL_EXPORT virtual void SetDescription(const std::string& value); - /// Description of Modification of CPACS data - std::string m_modification; + TIGL_EXPORT virtual const std::time_t& GetTimestamp() const; + TIGL_EXPORT virtual void SetTimestamp(const std::time_t& value); - /// Creator of CPACS modification - std::string m_creator; + TIGL_EXPORT virtual const std::string& GetCreator() const; + TIGL_EXPORT virtual void SetCreator(const std::string& value); - /// Timestamp of CPACS modification - std::time_t m_timestamp; + protected: + CPACSVersionInfos* m_parent; - /// New version number of CPACS dataset after - /// modification std::string m_version; - /// CPACS version that the dataset is valid to + /// CPACS version of the dataset std::string m_cpacsVersion; + /// Description of CPACS dataset + std::string m_description; + + /// Timestamp of initial CPACS dataset creation + std::time_t m_timestamp; + + /// Creator of initial CPACS dataset + std::string m_creator; + private: - CPACSUpdate(const CPACSUpdate&) = delete; - CPACSUpdate& operator=(const CPACSUpdate&) = delete; + CPACSVersionInfo(const CPACSVersionInfo&) = delete; + CPACSVersionInfo& operator=(const CPACSVersionInfo&) = delete; - CPACSUpdate(CPACSUpdate&&) = delete; - CPACSUpdate& operator=(CPACSUpdate&&) = delete; + CPACSVersionInfo(CPACSVersionInfo&&) = delete; + CPACSVersionInfo& operator=(CPACSVersionInfo&&) = delete; }; } // namespace generated // Aliases in tigl namespace -using CCPACSUpdate = generated::CPACSUpdate; -using CCPACSUpdates = generated::CPACSUpdates; +using CCPACSVersionInfo = generated::CPACSVersionInfo; +using CCPACSVersionInfos = generated::CPACSVersionInfos; } // namespace tigl diff --git a/src/generated/CPACSVersionInfos.cpp b/src/generated/CPACSVersionInfos.cpp new file mode 100644 index 000000000..5158462fa --- /dev/null +++ b/src/generated/CPACSVersionInfos.cpp @@ -0,0 +1,111 @@ +// Copyright (c) 2020 RISC Software GmbH +// +// This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). +// Do not edit, all changes are lost when files are re-generated. +// +// 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 +#include "CPACSHeader.h" +#include "CPACSVersionInfo.h" +#include "CPACSVersionInfos.h" +#include "CTiglError.h" +#include "CTiglLogging.h" +#include "CTiglUIDObject.h" +#include "TixiHelper.h" + +namespace tigl +{ +namespace generated +{ + CPACSVersionInfos::CPACSVersionInfos(CPACSHeader* parent) + { + //assert(parent != NULL); + m_parent = parent; + } + + CPACSVersionInfos::~CPACSVersionInfos() + { + } + + const CPACSHeader* CPACSVersionInfos::GetParent() const + { + return m_parent; + } + + CPACSHeader* CPACSVersionInfos::GetParent() + { + return m_parent; + } + + const CTiglUIDObject* CPACSVersionInfos::GetNextUIDParent() const + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + CTiglUIDObject* CPACSVersionInfos::GetNextUIDParent() + { + if (m_parent) { + return m_parent->GetNextUIDParent(); + } + return nullptr; + } + + void CPACSVersionInfos::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) + { + // read element versionInfo + if (tixi::TixiCheckElement(tixiHandle, xpath + "/versionInfo")) { + tixi::TixiReadElements(tixiHandle, xpath + "/versionInfo", m_versionInfos, 1, tixi::xsdUnbounded, this); + } + + } + + void CPACSVersionInfos::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const + { + // write element versionInfo + tixi::TixiSaveElements(tixiHandle, xpath + "/versionInfo", m_versionInfos); + + } + + const std::vector>& CPACSVersionInfos::GetVersionInfos() const + { + return m_versionInfos; + } + + std::vector>& CPACSVersionInfos::GetVersionInfos() + { + return m_versionInfos; + } + + CPACSVersionInfo& CPACSVersionInfos::AddVersionInfo() + { + m_versionInfos.push_back(make_unique(this)); + return *m_versionInfos.back(); + } + + void CPACSVersionInfos::RemoveVersionInfo(CPACSVersionInfo& ref) + { + for (std::size_t i = 0; i < m_versionInfos.size(); i++) { + if (m_versionInfos[i].get() == &ref) { + m_versionInfos.erase(m_versionInfos.begin() + i); + return; + } + } + throw CTiglError("Element not found"); + } + +} // namespace generated +} // namespace tigl diff --git a/src/generated/CPACSUpdates.h b/src/generated/CPACSVersionInfos.h similarity index 65% rename from src/generated/CPACSUpdates.h rename to src/generated/CPACSVersionInfos.h index 451c443cf..cfc5915da 100644 --- a/src/generated/CPACSUpdates.h +++ b/src/generated/CPACSVersionInfos.h @@ -29,23 +29,21 @@ class CTiglUIDObject; namespace generated { - class CPACSUpdate; + class CPACSVersionInfo; class CPACSHeader; // This class is used in: // CPACSHeader - /// @brief updatesType + /// @brief Version Informations /// - /// Updates type, containing update data for the CPACS - /// dataset /// - class CPACSUpdates + class CPACSVersionInfos { public: - TIGL_EXPORT CPACSUpdates(CPACSHeader* parent); + TIGL_EXPORT CPACSVersionInfos(CPACSHeader* parent); - TIGL_EXPORT virtual ~CPACSUpdates(); + TIGL_EXPORT virtual ~CPACSVersionInfos(); TIGL_EXPORT CPACSHeader* GetParent(); @@ -57,28 +55,28 @@ namespace generated TIGL_EXPORT virtual void ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath); TIGL_EXPORT virtual void WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const; - TIGL_EXPORT virtual const std::vector>& GetUpdates() const; - TIGL_EXPORT virtual std::vector>& GetUpdates(); + TIGL_EXPORT virtual const std::vector>& GetVersionInfos() const; + TIGL_EXPORT virtual std::vector>& GetVersionInfos(); - TIGL_EXPORT virtual CPACSUpdate& AddUpdate(); - TIGL_EXPORT virtual void RemoveUpdate(CPACSUpdate& ref); + TIGL_EXPORT virtual CPACSVersionInfo& AddVersionInfo(); + TIGL_EXPORT virtual void RemoveVersionInfo(CPACSVersionInfo& ref); protected: CPACSHeader* m_parent; - std::vector> m_updates; + std::vector> m_versionInfos; private: - CPACSUpdates(const CPACSUpdates&) = delete; - CPACSUpdates& operator=(const CPACSUpdates&) = delete; + CPACSVersionInfos(const CPACSVersionInfos&) = delete; + CPACSVersionInfos& operator=(const CPACSVersionInfos&) = delete; - CPACSUpdates(CPACSUpdates&&) = delete; - CPACSUpdates& operator=(CPACSUpdates&&) = delete; + CPACSVersionInfos(CPACSVersionInfos&&) = delete; + CPACSVersionInfos& operator=(CPACSVersionInfos&&) = delete; }; } // namespace generated // Aliases in tigl namespace -using CCPACSUpdates = generated::CPACSUpdates; -using CCPACSUpdate = generated::CPACSUpdate; +using CCPACSVersionInfos = generated::CPACSVersionInfos; +using CCPACSVersionInfo = generated::CPACSVersionInfo; using CCPACSHeader = generated::CPACSHeader; } // namespace tigl diff --git a/tests/unittests/TestData/testversion_new_header.xml b/tests/unittests/TestData/testversion_new_header.xml new file mode 100644 index 000000000..da1d9613b --- /dev/null +++ b/tests/unittests/TestData/testversion_new_header.xml @@ -0,0 +1,28 @@ + + +
+ Cpacs2Test + Test file to check versioning according to new CPACS header + 2.0.0 + + + Test for version 2.0.0 + 3.5 + Marko Alder + 2024-05-31T10:00:00 + + + Test for version 1.0.0 + 3.3 + Marko Alder + 2024-05-30T10:00:00 + + +
+ + + + + + +
diff --git a/tests/unittests/testCpacsVersion.cpp b/tests/unittests/testCpacsVersion.cpp index 7ecf89e0a..8c9a0e64f 100644 --- a/tests/unittests/testCpacsVersion.cpp +++ b/tests/unittests/testCpacsVersion.cpp @@ -60,3 +60,13 @@ TEST(CPACSVersion, noCPACSVersion) tiglCloseCPACSConfiguration(tiglHandle); } + +TEST(CPACSVersion, newCPACSHeader) +{ + TixiHandleWrapper tixihandle("TestData/testversion_new_header.xml"); + + TiglCPACSConfigurationHandle tiglHandle = -1; + EXPECT_EQ(TIGL_SUCCESS, tiglOpenCPACSConfiguration(tixihandle, "", &tiglHandle)); + + tiglCloseCPACSConfiguration(tiglHandle); +}