Skip to content

Commit

Permalink
[CORRECTIVE] Fix file set references in component instantiations and …
Browse files Browse the repository at this point in the history
…bus interfaces.
  • Loading branch information
hagantsa committed Sep 6, 2023
1 parent 9a0d89c commit 564730c
Show file tree
Hide file tree
Showing 33 changed files with 594 additions and 247 deletions.
7 changes: 3 additions & 4 deletions IPXACTmodels/Component/BusInterfaceReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,10 @@ void BusinterfaceReader::Details::parseTargetInterface(QDomElement const& target
QDomNode groupNode = fileSetRefElement.firstChildElement(QStringLiteral("ipxact:group"));
fileSetGroup->group_ = XmlUtils::removeWhiteSpace(groupNode.firstChild().nodeValue());

QDomNodeList filesetNodes = fileSetRefElement.elementsByTagName(QStringLiteral("ipxact:fileSetRef"));
int filesetNodeCount = filesetNodes.count();
for (int j = 0; j < filesetNodeCount; j++)
if (auto fileSetRefs = CommonItemsReader::parseFileSetReferences(fileSetRefElement, docRevision);
fileSetRefs->isEmpty() == false)
{
fileSetGroup->fileSetRefs_.append(filesetNodes.at(j).firstChild().nodeValue());
fileSetGroup->fileSetRefs_ = fileSetRefs;
}

// Another file set ref group is extracted.
Expand Down
5 changes: 1 addition & 4 deletions IPXACTmodels/Component/BusInterfaceWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,7 @@ void BusInterfaceWriter::Details::writeTargetInterface(QXmlStreamWriter& writer,
writer.writeTextElement(QStringLiteral("ipxact:group"), group->group_);

// Write all the fileSetRefs for this group.
for (QString const& filesetRef : group->fileSetRefs_)
{
writer.writeTextElement(QStringLiteral("ipxact:fileSetRef"), filesetRef);
}
CommonItemsWriter::writeFileSetReferences(writer, group->fileSetRefs_, docRevision);

writer.writeEndElement(); // ipxact:fileSetRefGroup
}
Expand Down
108 changes: 27 additions & 81 deletions IPXACTmodels/Component/ComponentInstantiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ libraryName_(),
packageName_(),
moduleName_(),
architectureName_(),
configurationName_(),
moduleParameters_(new QList<QSharedPointer<ModuleParameter> > ()),
defaultFileBuilders_(new QList<QSharedPointer<FileBuilder> > ()),
fileSetReferences_(new QStringList()),
parameters_(new QList<QSharedPointer<Parameter> > ())
configurationName_()
{

}
Expand All @@ -47,16 +43,12 @@ libraryName_(other.libraryName_),
packageName_(other.packageName_),
moduleName_(other.moduleName_),
architectureName_(other.architectureName_),
configurationName_(other.configurationName_),
moduleParameters_(new QList<QSharedPointer<ModuleParameter> > ()),
defaultFileBuilders_(new QList<QSharedPointer<FileBuilder> > ()),
fileSetReferences_(new QStringList),
parameters_(new QList<QSharedPointer<Parameter> > ())
configurationName_(other.configurationName_)
{
copyModuleParameters(other);
copyDefaultFileBuilders(other);
copyFileSetReferences(other);
copyParameters(other);
Utilities::copyList(moduleParameters_, other.moduleParameters_);
Utilities::copyList(defaultFileBuilders_, other.defaultFileBuilders_);
Utilities::copyList(fileSetReferences_, other.fileSetReferences_);
Utilities::copyList(parameters_, other.parameters_);
}

//-----------------------------------------------------------------------------
Expand All @@ -78,14 +70,10 @@ ComponentInstantiation& ComponentInstantiation::operator=(const ComponentInstant
architectureName_ = other.architectureName_;
configurationName_ = other.configurationName_;

moduleParameters_->clear();
copyModuleParameters(other);
defaultFileBuilders_->clear();
copyDefaultFileBuilders(other);
fileSetReferences_->clear();
copyFileSetReferences(other);
parameters_->clear();
copyParameters(other);
Utilities::copyList(moduleParameters_, other.moduleParameters_);
Utilities::copyList(defaultFileBuilders_, other.defaultFileBuilders_);
Utilities::copyList(fileSetReferences_, other.fileSetReferences_);
Utilities::copyList(parameters_, other.parameters_);
}

return *this;
Expand Down Expand Up @@ -269,15 +257,30 @@ void ComponentInstantiation::setDefaultFileBuilders(
//-----------------------------------------------------------------------------
// Function: ComponentInstantiation::getFileSetReferences()
//-----------------------------------------------------------------------------
QSharedPointer<QStringList> ComponentInstantiation::getFileSetReferences() const
QSharedPointer<QList<QSharedPointer<FileSetRef> > > ComponentInstantiation::getFileSetReferences() const
{
return fileSetReferences_;
}

//-----------------------------------------------------------------------------
// Function: ComponentInstantiation::getFileSetReferenceStrings()
//-----------------------------------------------------------------------------
QStringList ComponentInstantiation::getFileSetReferenceStrings() const
{
QStringList referenceStrings;
std::transform(fileSetReferences_->cbegin(), fileSetReferences_->cend(), std::back_inserter(referenceStrings),
[](QSharedPointer<FileSetRef> fileSetRef)
{
return fileSetRef->getReference();
});

return referenceStrings;
}

//-----------------------------------------------------------------------------
// Function: ComponentInstantiation::setFileSetReferences()
//-----------------------------------------------------------------------------
void ComponentInstantiation::setFileSetReferences(QSharedPointer<QStringList> newFileSetReferences)
void ComponentInstantiation::setFileSetReferences(QSharedPointer<QList<QSharedPointer<FileSetRef> > > newFileSetReferences)
{
fileSetReferences_ = newFileSetReferences;
}
Expand All @@ -298,60 +301,3 @@ void ComponentInstantiation::setParameters(QSharedPointer<QList<QSharedPointer<P
parameters_->clear();
parameters_ = newParameters;
}

//-----------------------------------------------------------------------------
// Function: ComponentInstantiation::copyModuleParameters()
//-----------------------------------------------------------------------------
void ComponentInstantiation::copyModuleParameters(const ComponentInstantiation& other) const
{
foreach (QSharedPointer<ModuleParameter> moduleParameter, *other.moduleParameters_)
{
if (moduleParameter)
{
QSharedPointer<ModuleParameter> copy =
QSharedPointer<ModuleParameter>(new ModuleParameter(*moduleParameter.data()));
moduleParameters_->append(copy);
}
}
}

//-----------------------------------------------------------------------------
// Function: ComponentInstantiation::copyDefaultFileBuilders()
//-----------------------------------------------------------------------------
void ComponentInstantiation::copyDefaultFileBuilders(const ComponentInstantiation& other) const
{
foreach (QSharedPointer<FileBuilder> fileBuilder, *other.defaultFileBuilders_)
{
if (fileBuilder)
{
QSharedPointer<FileBuilder> copy = QSharedPointer<FileBuilder>(new FileBuilder(*fileBuilder.data()));
defaultFileBuilders_->append(copy);
}
}
}

//-----------------------------------------------------------------------------
// Function: ComponentInstantiation::copyFileSetReferences()
//-----------------------------------------------------------------------------
void ComponentInstantiation::copyFileSetReferences(const ComponentInstantiation& other) const
{
foreach (QString reference, *other.fileSetReferences_)
{
fileSetReferences_->append(reference);
}
}

//-----------------------------------------------------------------------------
// Function: ComponentInstantiation::copyParameters()
//-----------------------------------------------------------------------------
void ComponentInstantiation::copyParameters(const ComponentInstantiation& other) const
{
foreach (QSharedPointer<Parameter> parameter, *other.parameters_)
{
if (parameter)
{
QSharedPointer<Parameter> copy = QSharedPointer<Parameter>(new Parameter(*parameter.data()));
parameters_->append(copy);
}
}
}
49 changes: 21 additions & 28 deletions IPXACTmodels/Component/ComponentInstantiation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#ifndef COMPONENTINSTANTIATION_H
#define COMPONENTINSTANTIATION_H

#include "FileSetRef.h"

#include <IPXACTmodels/common/NameGroup.h>
#include <IPXACTmodels/common/Extendable.h>
#include <IPXACTmodels/common/Parameter.h>
Expand Down Expand Up @@ -198,16 +200,23 @@ class IPXACTMODELS_EXPORT ComponentInstantiation : public NameGroup, public Exte
/*!
* Get the file set references.
*
* @return Pointer to a list containing referenced file set names.
* @return Pointer to a list containing referenced file sets.
*/
QSharedPointer<QList<QSharedPointer<FileSetRef> > > getFileSetReferences() const;

/*!
* Get the file set references as a list of strings.
*
* @return The file set references as strings.
*/
QSharedPointer<QStringList> getFileSetReferences() const;
QStringList getFileSetReferenceStrings() const;

/*!
* Set the file set references.
*
* @param [in] newFileSetReferences The names of the referenced file sets.
* @param [in] newFileSetReferences The new file set references.
*/
void setFileSetReferences(QSharedPointer<QStringList> newFileSetReferences);
void setFileSetReferences(QSharedPointer<QList<QSharedPointer<FileSetRef> > > newFileSetReferences);

/*!
* Get the parameters.
Expand All @@ -225,26 +234,6 @@ class IPXACTMODELS_EXPORT ComponentInstantiation : public NameGroup, public Exte

private:

/*!
* Copy module parameters.
*/
void copyModuleParameters(const ComponentInstantiation& other) const;

/*!
* Copy default file builders.
*/
void copyDefaultFileBuilders(const ComponentInstantiation& other) const;

/*!
* Copy file set references.
*/
void copyFileSetReferences(const ComponentInstantiation& other) const;

/*!
* Copy parameters.
*/
void copyParameters(const ComponentInstantiation& other) const;

//-----------------------------------------------------------------------------
// Data.
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -274,16 +263,20 @@ class IPXACTMODELS_EXPORT ComponentInstantiation : public NameGroup, public Exte
QString configurationName_;

//! A list of module parameters.
QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters_;
QSharedPointer<QList<QSharedPointer<ModuleParameter> > > moduleParameters_ =
QSharedPointer<QList<QSharedPointer<ModuleParameter> > >(new QList<QSharedPointer<ModuleParameter> > ());

//! A list of default file builders.
QSharedPointer<QList<QSharedPointer<FileBuilder> > > defaultFileBuilders_;
QSharedPointer<QList<QSharedPointer<FileBuilder> > > defaultFileBuilders_ =
QSharedPointer<QList<QSharedPointer<FileBuilder> > >(new QList<QSharedPointer<FileBuilder> > ());

//! A list of file set references.
QSharedPointer<QStringList> fileSetReferences_;
QSharedPointer<QList<QSharedPointer<FileSetRef> > > fileSetReferences_ =
QSharedPointer<QList<QSharedPointer<FileSetRef> > >(new QList<QSharedPointer<FileSetRef> >());

//! A list of instantiation parameters.
QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_;
QSharedPointer<QList<QSharedPointer<Parameter> > > parameters_ =
QSharedPointer<QList<QSharedPointer<Parameter> > >(new QList<QSharedPointer<Parameter> > ());
};

#endif // DESIGNINSTANTIATION_H
78 changes: 78 additions & 0 deletions IPXACTmodels/Component/FileSetRef.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//-----------------------------------------------------------------------------
// File: FileSetRef.cpp
//-----------------------------------------------------------------------------
// Project: Kactus 2
// Author: Anton Hagqvist
// Date: 4.9.2023
//
// Description:
// Describes the ipxact:fileSetRef element.
//-----------------------------------------------------------------------------

#include "FileSetRef.h"

//-----------------------------------------------------------------------------
// Function: FileSetRef::FileSetRef()
//-----------------------------------------------------------------------------
FileSetRef::FileSetRef(FileSetRef const& other) :
Extendable(other),
localName_(other.localName_),
isPresent_(other.isPresent_)
{

}

//-----------------------------------------------------------------------------
// Function: FileSetRef::FileSetRef()
//-----------------------------------------------------------------------------
FileSetRef::FileSetRef() : Extendable()
{

}

//-----------------------------------------------------------------------------
// Function: FileSetRef::getLocalName()
//-----------------------------------------------------------------------------
QString FileSetRef::getReference() const
{
return localName_;
}

//-----------------------------------------------------------------------------
// Function: FileSetRef::setLocalName()
//-----------------------------------------------------------------------------
void FileSetRef::setReference(QString const& newName)
{
localName_ = newName;
}

//-----------------------------------------------------------------------------
// Function: FileSetRef::getIsPresent()
//-----------------------------------------------------------------------------
QString FileSetRef::getIsPresent() const
{
return isPresent_;
}

//-----------------------------------------------------------------------------
// Function: FileSetRef::setIsPresent()
//-----------------------------------------------------------------------------
void FileSetRef::setIsPresent(QString const& newIsPresent)
{
isPresent_ = newIsPresent;
}

//-----------------------------------------------------------------------------
// Function: FileSetRef::operator=()
//-----------------------------------------------------------------------------
FileSetRef& FileSetRef::operator=(FileSetRef const& other)
{
if (this != &other)
{
Extendable::operator=(other);
localName_ = other.localName_;
isPresent_ = other.isPresent_;
}

return *this;
}
Loading

0 comments on commit 564730c

Please sign in to comment.