Kactus2
Kactus2 reference guide
Loading...
Searching...
No Matches
MemoryBlockInterface.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// File: MemoryBlockInterface.h
3//-----------------------------------------------------------------------------
4// Project: Kactus2
5// Author: Mikko Teuho
6// Date: 31.01.2022
7//
8// Description:
9// Parent interface for editing memory blocks.
10//-----------------------------------------------------------------------------
11
12#ifndef MEMORYBLOCKINTERFACE_H
13#define MEMORYBLOCKINTERFACE_H
14
15#include <KactusAPI/KactusAPIGlobal.h>
16
18#include <NameGroupInterface.h>
19
20#include <QVector>
21#include <QMap>
22
23class MemoryBlockBase;
24class AddressSpace;
25class Segment;
27class MemoryBlockValidator;
29class Component;
30
31//-----------------------------------------------------------------------------
33//-----------------------------------------------------------------------------
35{
36
37public:
38
47 MemoryBlockInterface(QSharedPointer<ExpressionParser> expressionParser,
48 QSharedPointer<ExpressionFormatter> expressionFormatter,
49 BusInterfaceInterface* busInterface,
50 ParametersInterface* parameterInterface);
51
55 virtual ~MemoryBlockInterface() = default;
56
62 void setMemoryBlocks(QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > newMemoryBlocks);
63
69 void setupSubInterfaces(QSharedPointer<Component> newComponent);
70
77
85 virtual bool acceptBlock(std::string const& blockName) const = 0;
86
94 virtual int getItemIndex(std::string const& itemName) const override final;
95
103 std::string getIndexedItemName(int itemIndex) const final;
104
110 virtual int itemCount() const override final;
111
117 virtual std::vector<std::string> getItemNames() const override final;
118
127 virtual bool setName(std::string const& currentName, std::string const& newName) override final;
128
137 std::string getBaseAddressValue(std::string const& blockName, int const& baseNumber = 0) const;
138
146 std::string getBaseAddressFormattedExpression(std::string const& blockName) const;
147
155 std::string getBaseAddressExpression(std::string const& blockName) const;
156
165 bool setBaseAddress(std::string const& blockName, std::string const& newBaseAdress) const;
166
175 std::string getIsPresentValue(std::string const& blockName, int const& baseNumber = 0) const;
176
184 std::string getIsPresentFormattedExpression(std::string const& blockName) const;
185
193 std::string getIsPresentExpression(std::string const& blockName) const;
194
203 bool setIsPresent(std::string const& blockName, std::string const& newIsPresent) const;
204
213 std::string getRangeValue(std::string const& blockName, int const& baseNumber = 0) const;
214
223 virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const override;
224
230 virtual bool validateItems() const override = 0;
231
239 bool itemHasValidName(std::string const& itemName) const;
240
248 bool hasValidBaseAddress(std::string const& itemName) const;
249
257 bool hasValidIsPresent(std::string const& itemName) const;
258
265 virtual void addBlock(int const& row, std::string const& newBlockName = std::string("")) = 0;
266
273 virtual void addBlock(std::string const& newBlockName = std::string(""));
274
282 bool removeBlock(std::string const& blockName);
283
289 void copyRows(std::vector<int> selectedRows);
290
296 std::vector<std::string> pasteRows();
297
303 int getPasteRowCount() const;
304
312 virtual std::vector<std::string> getExpressionsInSelectedItems(std::vector<std::string> const& itemNames) const = 0;
313
319 void setAddressUnitBits(std::string const& newAddressUnitbits);
320
321protected:
322
328 QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > getBlocksData();
329
335 QString getNewBlockBaseAddress() const;
336
344 QSharedPointer<MemoryBlockBase> getBlock(std::string const& itemName) const;
345
351 QString getAddressUnitBits() const;
352
360 QSharedPointer<AddressSpace> getReferencedAddressSpace(QString const& masterBusReference) const;
361
362private:
363
369 virtual std::string getDefaultName() const = 0;
370
378 virtual QList<QSharedPointer<MemoryBlockBase> > getCopiedBlocks(std::vector<int> const& selectedRows) const = 0;
379
385 virtual QString getMimeType() const = 0;
386
394 virtual QSharedPointer<MemoryBlockBase> createCopyBlock(QSharedPointer<MemoryBlockBase> copiedItem) const = 0;
395
403 virtual int countItems(QList<QSharedPointer<MemoryBlockBase> > itemList) const = 0;
404
410 virtual QSharedPointer<MemoryBlockValidator> getValidator() const = 0;
411
421 QSharedPointer<Segment> getReferencedSegment(QSharedPointer<AddressSpace> referencedSpace,
422 QString const& segmentReference) const;
423
424 //-----------------------------------------------------------------------------
425 // Data.
426 //-----------------------------------------------------------------------------
427
429 QSharedPointer<QList<QSharedPointer<AddressSpace> > > availableAddressSpaces_{ nullptr };
430
432 BusInterfaceInterface* busInterfaceInterface_{ nullptr };
433
435 QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > blockData_{ nullptr };
436
438 QString addressUnitBits_;
439
441 ParametersInterface* parameterInterface_{ nullptr };
442};
443
444#endif // MEMORYBLOCKINTERFACE_H
Interface for accessing bus interfaces.
bool itemHasValidName(std::string const &itemName) const
virtual ~MemoryBlockInterface()=default
std::string getIsPresentFormattedExpression(std::string const &blockName) const
virtual std::vector< std::string > getItemNames() const override final
void setupSubInterfaces(QSharedPointer< Component > newComponent)
bool setIsPresent(std::string const &blockName, std::string const &newIsPresent) const
std::string getIsPresentValue(std::string const &blockName, int const &baseNumber=0) const
QSharedPointer< AddressSpace > getReferencedAddressSpace(QString const &masterBusReference) const
virtual std::vector< std::string > getExpressionsInSelectedItems(std::vector< std::string > const &itemNames) const =0
std::string getIndexedItemName(int itemIndex) const final
std::string getBaseAddressFormattedExpression(std::string const &blockName) const
std::string getBaseAddressValue(std::string const &blockName, int const &baseNumber=0) const
virtual int itemCount() const override final
std::string getBaseAddressExpression(std::string const &blockName) const
void setAddressUnitBits(std::string const &newAddressUnitbits)
std::string getIsPresentExpression(std::string const &blockName) const
BusInterfaceInterface * getBusInterface() const
MemoryBlockInterface(QSharedPointer< ExpressionParser > expressionParser, QSharedPointer< ExpressionFormatter > expressionFormatter, BusInterfaceInterface *busInterface, ParametersInterface *parameterInterface)
virtual void addBlock(int const &row, std::string const &newBlockName=std::string(""))=0
int getPasteRowCount() const
bool setBaseAddress(std::string const &blockName, std::string const &newBaseAdress) const
bool hasValidBaseAddress(std::string const &itemName) const
virtual int getAllReferencesToIdInItem(const std::string &itemName, std::string const &valueID) const override
virtual bool acceptBlock(std::string const &blockName) const =0
QString getNewBlockBaseAddress() const
std::string getRangeValue(std::string const &blockName, int const &baseNumber=0) const
virtual bool setName(std::string const &currentName, std::string const &newName) override final
QSharedPointer< MemoryBlockBase > getBlock(std::string const &itemName) const
bool hasValidIsPresent(std::string const &itemName) const
void copyRows(std::vector< int > selectedRows)
QSharedPointer< QList< QSharedPointer< MemoryBlockBase > > > getBlocksData()
void setMemoryBlocks(QSharedPointer< QList< QSharedPointer< MemoryBlockBase > > > newMemoryBlocks)
bool removeBlock(std::string const &blockName)
virtual int getItemIndex(std::string const &itemName) const override final
QString getAddressUnitBits() const
std::vector< std::string > pasteRows()
virtual bool validateItems() const override=0
ParameterizableInterface(QSharedPointer< ExpressionParser > expressionParser, QSharedPointer< ExpressionFormatter > expressionFormatter)
Interface for editing parameters.