Skip to content

Commit

Permalink
[CORRECTIVE] Added ItemNamesGetterInterface class (forgot to do it in…
Browse files Browse the repository at this point in the history
… the previous commit).
  • Loading branch information
VasiliiFeshchenko committed Aug 4, 2024
1 parent c521a21 commit 7cd90e5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
21 changes: 21 additions & 0 deletions KactusAPI/include/ItemNamesGetterInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef ITEMNAMESGETTER_H
#define ITEMNAMESGETTER_H
#include "CommonInterface.h"
#include <QSharedPointer>
#include <QList>
template <typename T>
class KACTUS2_API ItemNamesGetterInterface : public CommonInterface
{
public:
ItemNamesGetterInterface(QSharedPointer<QList<QSharedPointer<T>>> reservedNames);
virtual ~ItemNamesGetterInterface() = default;

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

int itemCount() const override;

bool validateItems() const override;
private:
QSharedPointer<QList<QSharedPointer<T>>> reservedNames_;
};
#endif // ITEMNAMESGETTER_H
40 changes: 40 additions & 0 deletions KactusAPI/interfaces/common/ItemNamesGetterInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "ItemNamesGetterInterface.h"
#include <IPXACTmodels/Component/DesignInstantiation.h>


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

}

template <typename T>
std::vector<std::string> ItemNamesGetterInterface<T>::getItemNames() const
{
std::vector<std::string> names;
for (auto item : *reservedNames_)
{
names.push_back(item->name().toStdString());
}

return names;
}

template <typename T>
int ItemNamesGetterInterface<T>::itemCount() const
{
return -1;
}


template <typename T>
bool ItemNamesGetterInterface<T>::validateItems() const
{
return false;
}
template class ItemNamesGetterInterface<DesignInstantiation>;

0 comments on commit 7cd90e5

Please sign in to comment.