Skip to content

Commit

Permalink
[CORRECTIVE] Working version with MemoryMapInterface inherited from I…
Browse files Browse the repository at this point in the history
…temNamesGetterInterface (that is inherited from NameGroupInterface). The commit is only for saving the working version of the program.
  • Loading branch information
VasiliiFeshchenko committed Aug 7, 2024
1 parent 7cd90e5 commit a0ff034
Show file tree
Hide file tree
Showing 18 changed files with 199 additions and 63 deletions.
6 changes: 4 additions & 2 deletions KactusAPI/KactusAPI.pri
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ message("You are running qmake on a generated .pro file. This may not work!")

HEADERS += ./KactusAPI.h \
./KactusAPIGlobal.h \
./include/ItemNamesGetterInterface.h \
./include/AbstractionTypeInterface.h \
./include/AbstractParameterInterface.h \
./include/AccessPolicyInterface.h \
Expand Down Expand Up @@ -96,7 +97,7 @@ HEADERS += ./KactusAPI.h \
./include/LibraryItem.h \
./include/LibraryTreeModel.h \
./include/ParameterCache.h \
../../temp/31.07.24/ItemNamesGetterInterface.h
./include/AddressSpaceInterface.h
SOURCES += ./KactusAPI.cpp \
./expressions/AddressBlockExpressionsGatherer.cpp \
./expressions/AddressSpaceExpressionsGatherer.cpp \
Expand Down Expand Up @@ -142,6 +143,7 @@ SOURCES += ./KactusAPI.cpp \
./interfaces/component/ResetInterface.cpp \
./interfaces/component/SubspaceMapInterface.cpp \
./interfaces/component/TransparentBridgeInterface.cpp \
./interfaces/common/ItemNamesGetterInterface.cpp \
./interfaces/common/AbstractParameterInterface.cpp \
./interfaces/common/CommonInterface.cpp \
./interfaces/common/NameGroupInterface.cpp \
Expand All @@ -167,4 +169,4 @@ SOURCES += ./KactusAPI.cpp \
./library/LibraryLoader.cpp \
./library/LibraryTreeModel.cpp \
./library/TagManager.cpp \
../../temp/31.07.24/ItemNamesGetterInterface.cpp
./interfaces/component/AddressSpaceInterface.cpp
2 changes: 2 additions & 0 deletions KactusAPI/KactusAPI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\AddressSpaceInterface.h" />
<ClInclude Include="include\ItemNamesGetterInterface.h" />
<ClInclude Include="include\AbstractionTypeInterface.h" />
<ClInclude Include="include\AbstractParameterInterface.h" />
Expand Down Expand Up @@ -136,6 +137,7 @@
<ClCompile Include="interfaces\common\ParametersInterface.cpp" />
<ClCompile Include="interfaces\component\AccessPolicyInterface.cpp" />
<ClCompile Include="interfaces\component\AddressBlockInterface.cpp" />
<ClCompile Include="interfaces\component\AddressSpaceInterface.cpp" />
<ClCompile Include="interfaces\component\BusInterfaceInterface.cpp" />
<ClCompile Include="interfaces\component\BusInterfaceInterfaceFactory.cpp" />
<ClCompile Include="interfaces\component\BusInterfaceUtilities.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions KactusAPI/KactusAPI.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@
<ClInclude Include="include\ItemNamesGetterInterface.h">
<Filter>Header Files\include</Filter>
</ClInclude>
<ClInclude Include="include\AddressSpaceInterface.h">
<Filter>Header Files\include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="utilities\ConsoleMediator.cpp">
Expand Down Expand Up @@ -518,6 +521,9 @@
<ClCompile Include="interfaces\common\ItemNamesGetterInterface.cpp">
<Filter>Source Files\interfaces\common</Filter>
</ClCompile>
<ClCompile Include="interfaces\component\AddressSpaceInterface.cpp">
<Filter>Source Files\interfaces\component</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\ComponentInstanceInterface.h">
Expand Down
35 changes: 35 additions & 0 deletions KactusAPI/include/AddressSpaceInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@


#ifndef ADDRESSSPACEINTERFACE_H
#define ADDRESSSPACEINTERFACE_H

#include <KactusAPI/KactusAPIGlobal.h>

#include <MemoryBlockInterface.h>

#include <IPXACTmodels/generaldeclarations.h>
#include <IPXACTmodels/common/AccessTypes.h>

class AddressBlock;
class MemoryBlockBase;
class AddressBlockValidator;
class RegisterInterface;
class BusInterfaceInterface;

#include <QVector>
#include <QMap>
#include <ItemNamesGetterInterface.h>

template <typename T>
class KACTUS2_API AddressSpaceInterface : public ItemNamesGetterInterface<T>
{

public:
AddressSpaceInterface();
using ItemNamesGetterInterface<T>::ItemNamesGetterInterface;

virtual int getItemIndex(std::string const& itemName) const override final;

};

#endif // ADDRESSSPACEINTERFACE_H
20 changes: 15 additions & 5 deletions KactusAPI/include/ItemNamesGetterInterface.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
#ifndef ITEMNAMESGETTER_H
#define ITEMNAMESGETTER_H
#include "CommonInterface.h"
#include "NameGroupInterface.h"
#include <QSharedPointer>
#include <QList>
template <typename T>
class KACTUS2_API ItemNamesGetterInterface : public CommonInterface
class KACTUS2_API ItemNamesGetterInterface : public NameGroupInterface
{
public:
ItemNamesGetterInterface(QSharedPointer<QList<QSharedPointer<T>>> reservedNames);
ItemNamesGetterInterface(QSharedPointer<QList<QSharedPointer<T>>> existingItems);
ItemNamesGetterInterface();
virtual ~ItemNamesGetterInterface() = default;

std::vector<std::string> getItemNames() const override;

int itemCount() const override;
int itemCount() const override; // Implemented only as a placeholder to make a class not abstract

bool validateItems() const override;
bool validateItems() const override; // Implemented only as a placeholder to make a class not abstract

int getItemIndex(std::string const& itemName) const override; // Implemented only as a placeholder to make a class not abstract
std::string getIndexedItemName(int itemIndex) const override; // Implemented only as a placeholder to make a class not abstract
bool setName(std::string const& currentName, std::string const& newName) override; // Implemented only as a placeholder to make a class not abstract

bool itemHasValidName(std::string const& itemName) const override;
protected:
QSharedPointer<QList<QSharedPointer<T>>> existingItems_;
private:
QSharedPointer<QList<QSharedPointer<T>>> reservedNames_;
QSharedPointer<NameGroup> getItem(std::string const& itemName) const override;
};
#endif // ITEMNAMESGETTER_H
23 changes: 13 additions & 10 deletions KactusAPI/include/MemoryMapInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <ParameterizableInterface.h>
#include <NameGroupInterface.h>
#include <ItemNamesGetterInterface.h>

class Component;
class MemoryMap;
Expand All @@ -30,11 +31,11 @@ class ModeReference;
//-----------------------------------------------------------------------------
//! Interface for editing memory maps and remaps.
//-----------------------------------------------------------------------------
class KACTUS2_API MemoryMapInterface : public ParameterizableInterface, public NameGroupInterface

class KACTUS2_API MemoryMapInterface : public ParameterizableInterface, public ItemNamesGetterInterface<MemoryMap>
{

public:

/*!
* The constructor.
*
Expand Down Expand Up @@ -126,12 +127,12 @@ class KACTUS2_API MemoryMapInterface : public ParameterizableInterface, public N
*/
int remapCount(std::string const& mapName) const;

/*!
* Get the names of the available items.
*
* @return Names of the available items.
*/
virtual std::vector<std::string> getItemNames() const override final;
///*!
// * Get the names of the available items.
// *
// * @return Names of the available items.
// */
//virtual std::vector<std::string> getItemNames() const override final;

/*!
* Get the names of available memory remaps in the selected memory map.
Expand Down Expand Up @@ -652,8 +653,8 @@ class KACTUS2_API MemoryMapInterface : public ParameterizableInterface, public N
//! Component containing the memory maps.
QSharedPointer<Component> component_;

//! List of the contained memory maps.
QSharedPointer<QList<QSharedPointer<MemoryMap> > > mapData_;
////! List of the contained memory maps.
//QSharedPointer<QList<QSharedPointer<MemoryMap> > > mapData_;

//! Validator for memory maps.
QSharedPointer<MemoryMapValidator> validator_;
Expand All @@ -666,6 +667,8 @@ class KACTUS2_API MemoryMapInterface : public ParameterizableInterface, public N

//! Interface for accessing remap mode references.
ModeReferenceInterface* modeReferenceInterface_;


};

#endif // MEMORYMAPINTERFACE_H
43 changes: 38 additions & 5 deletions KactusAPI/interfaces/common/ItemNamesGetterInterface.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#include "ItemNamesGetterInterface.h"
#include <IPXACTmodels/Component/DesignInstantiation.h>
#include <IPXACTmodels/Component/MemoryMap.h>


//-----------------------------------------------------------------------------
// Function: ItemNamesGetterInterface::ItemNamesGetterInterface()
//-----------------------------------------------------------------------------
template <typename T>
ItemNamesGetterInterface<T>::ItemNamesGetterInterface(QSharedPointer<QList<QSharedPointer<T>>> reservedNames)
: CommonInterface(),
reservedNames_(reservedNames)
ItemNamesGetterInterface<T>::ItemNamesGetterInterface(QSharedPointer<QList<QSharedPointer<T>>> existingItems)
: NameGroupInterface(),
existingItems_(existingItems)
{

}
template <typename T>
ItemNamesGetterInterface<T>::ItemNamesGetterInterface()
: NameGroupInterface()
{

}
Expand All @@ -17,7 +24,7 @@ template <typename T>
std::vector<std::string> ItemNamesGetterInterface<T>::getItemNames() const
{
std::vector<std::string> names;
for (auto item : *reservedNames_)
for (auto item : *existingItems_)
{
names.push_back(item->name().toStdString());
}
Expand All @@ -37,4 +44,30 @@ bool ItemNamesGetterInterface<T>::validateItems() const
{
return false;
}
template class ItemNamesGetterInterface<DesignInstantiation>;

template <typename T>
int ItemNamesGetterInterface<T> ::getItemIndex(std::string const& itemName) const {
return -1;
}

template <typename T>
std::string ItemNamesGetterInterface<T> ::getIndexedItemName(int itemIndex) const {
return std::string();
}

template <typename T>
bool ItemNamesGetterInterface<T> ::setName(std::string const& currentName, std::string const& newName) {
return false;
}
template<typename T>
bool ItemNamesGetterInterface<T>::itemHasValidName(std::string const& itemName) const
{
return false;
}
template<typename T>
QSharedPointer<NameGroup> ItemNamesGetterInterface<T>::getItem(std::string const& itemName) const
{
return QSharedPointer<NameGroup>();
}
template class ItemNamesGetterInterface<DesignInstantiation>;
template class ItemNamesGetterInterface<MemoryMap>;
31 changes: 31 additions & 0 deletions KactusAPI/interfaces/component/AddressSpaceInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


#include "AddressSpaceInterface.h"

#include <AddressBlockExpressionsGatherer.h>

#include <IPXACTmodels/Component/MemoryBlockBase.h>
#include <IPXACTmodels/Component/AddressBlock.h>
#include <IPXACTmodels/Component/AccessPolicy.h>
#include <IPXACTmodels/Component/validators/AddressBlockValidator.h>

template <typename T>
AddressSpaceInterface<T>::AddressSpaceInterface() {

}

template <typename T>
int AddressSpaceInterface<T>::getItemIndex(std::string const& itemName) const
{
QString itemNameQ = QString::fromStdString(itemName);

int index = 0;
for (const auto& item : *this->existingItems_) {
if (item->getName() == itemNameQ) {
return index;
}
++index;
}

return -1;
}
Loading

0 comments on commit a0ff034

Please sign in to comment.