text: // 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 <cassert>
  #include "CCPACSLongFloorBeamPosition.h"
  #include "CPACSAlignmentStructMember.h"
  #include "CTiglError.h"
  #include "CTiglLogging.h"
  #include "CTiglUIDManager.h"
  #include "TixiHelper.h"
  
  namespace tigl
  {
  namespace generated
  {
      CPACSAlignmentStructMember::CPACSAlignmentStructMember(CCPACSLongFloorBeamPosition* parent, CTiglUIDManager* uidMgr)
          : m_uidMgr(uidMgr)
      {
          //assert(parent != NULL);
          m_parent = parent;
      }
  
      CPACSAlignmentStructMember::~CPACSAlignmentStructMember()
      {
          if (m_uidMgr) m_uidMgr->TryUnregisterObject(m_uID);
      }
  
      const CCPACSLongFloorBeamPosition* CPACSAlignmentStructMember::GetParent() const
      {
          return m_parent;
      }
  
      CCPACSLongFloorBeamPosition* CPACSAlignmentStructMember::GetParent()
      {
          return m_parent;
      }
  
      const CTiglUIDObject* CPACSAlignmentStructMember::GetNextUIDParent() const
      {
          return m_parent;
      }
  
      CTiglUIDObject* CPACSAlignmentStructMember::GetNextUIDParent()
      {
          return m_parent;
      }
  
      CTiglUIDManager& CPACSAlignmentStructMember::GetUIDManager()
      {
          return *m_uidMgr;
      }
  
      const CTiglUIDManager& CPACSAlignmentStructMember::GetUIDManager() const
      {
          return *m_uidMgr;
      }
  
      void CPACSAlignmentStructMember::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath)
      {
          // read attribute uID
          if (tixi::TixiCheckAttribute(tixiHandle, xpath, "uID")) {
              m_uID = tixi::TixiGetAttribute<std::string>(tixiHandle, xpath, "uID");
              if (m_uID.empty()) {
                  LOG(WARNING) << "Required attribute uID is empty at xpath " << xpath;
              }
          }
          else {
              LOG(ERROR) << "Required attribute uID is missing at xpath " << xpath;
          }
  
          // read element offsetLocX
          if (tixi::TixiCheckElement(tixiHandle, xpath + "/offsetLocX")) {
              m_offsetLocX = tixi::TixiGetElement<double>(tixiHandle, xpath + "/offsetLocX");
          }
  
          // read element rotationLocX
          if (tixi::TixiCheckElement(tixiHandle, xpath + "/rotationLocX")) {
              m_rotationLocX = tixi::TixiGetElement<double>(tixiHandle, xpath + "/rotationLocX");
          }
  
          // read element translationLocY
          if (tixi::TixiCheckElement(tixiHandle, xpath + "/translationLocY")) {
              m_translationLocY = tixi::TixiGetElement<double>(tixiHandle, xpath + "/translationLocY");
          }
  
          // read element translationLocZ
          if (tixi::TixiCheckElement(tixiHandle, xpath + "/translationLocZ")) {
              m_translationLocZ = tixi::TixiGetElement<double>(tixiHandle, xpath + "/translationLocZ");
          }
  
          if (m_uidMgr && !m_uID.empty()) m_uidMgr->RegisterObject(m_uID, *this);
      }
  
      void CPACSAlignmentStructMember::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const
      {
          // write attribute uID
          tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", m_uID);
  
          // write element offsetLocX
          if (m_offsetLocX) {
              tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/offsetLocX");
              tixi::TixiSaveElement(tixiHandle, xpath + "/offsetLocX", *m_offsetLocX);
          }
          else {
              if (tixi::TixiCheckElement(tixiHandle, xpath + "/offsetLocX")) {
                  tixi::TixiRemoveElement(tixiHandle, xpath + "/offsetLocX");
              }
          }
  
          // write element rotationLocX
          if (m_rotationLocX) {
              tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/rotationLocX");
              tixi::TixiSaveElement(tixiHandle, xpath + "/rotationLocX", *m_rotationLocX);
          }
          else {
              if (tixi::TixiCheckElement(tixiHandle, xpath + "/rotationLocX")) {
                  tixi::TixiRemoveElement(tixiHandle, xpath + "/rotationLocX");
              }
          }
  
          // write element translationLocY
          if (m_translationLocY) {
              tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/translationLocY");
              tixi::TixiSaveElement(tixiHandle, xpath + "/translationLocY", *m_translationLocY);
          }
          else {
              if (tixi::TixiCheckElement(tixiHandle, xpath + "/translationLocY")) {
                  tixi::TixiRemoveElement(tixiHandle, xpath + "/translationLocY");
              }
          }
  
          // write element translationLocZ
          if (m_translationLocZ) {
              tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/translationLocZ");
              tixi::TixiSaveElement(tixiHandle, xpath + "/translationLocZ", *m_translationLocZ);
          }
          else {
              if (tixi::TixiCheckElement(tixiHandle, xpath + "/translationLocZ")) {
                  tixi::TixiRemoveElement(tixiHandle, xpath + "/translationLocZ");
              }
          }
  
      }
  
      const std::string& CPACSAlignmentStructMember::GetUID() const
      {
          return m_uID;
      }
  
      void CPACSAlignmentStructMember::SetUID(const std::string& value)
      {
          if (m_uidMgr && value != m_uID) {
              if (m_uID.empty()) {
                  m_uidMgr->RegisterObject(value, *this);
              }
              else {
                  m_uidMgr->UpdateObjectUID(m_uID, value);
              }
          }
          m_uID = value;
      }
  
      const boost::optional<double>& CPACSAlignmentStructMember::GetOffsetLocX() const
      {
          return m_offsetLocX;
      }
  
      void CPACSAlignmentStructMember::SetOffsetLocX(const boost::optional<double>& value)
      {
          m_offsetLocX = value;
      }
  
      const boost::optional<double>& CPACSAlignmentStructMember::GetRotationLocX() const
      {
          return m_rotationLocX;
      }
  
      void CPACSAlignmentStructMember::SetRotationLocX(const boost::optional<double>& value)
      {
          m_rotationLocX = value;
      }
  
      const boost::optional<double>& CPACSAlignmentStructMember::GetTranslationLocY() const
      {
          return m_translationLocY;
      }
  
      void CPACSAlignmentStructMember::SetTranslationLocY(const boost::optional<double>& value)
      {
          m_translationLocY = value;
      }
  
      const boost::optional<double>& CPACSAlignmentStructMember::GetTranslationLocZ() const
      {
          return m_translationLocZ;
      }
  
      void CPACSAlignmentStructMember::SetTranslationLocZ(const boost::optional<double>& value)
      {
          m_translationLocZ = value;
      }
  
  } // namespace generated
  } // namespace tigl
  