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
19#include <QVector>
20#include <QMap>
21
22class MemoryBlockBase;
23class AddressSpace;
24class Segment;
26class MemoryBlockValidator;
28class Component;
29
30//-----------------------------------------------------------------------------
32//-----------------------------------------------------------------------------
34{
35
36public:
37
46 MemoryBlockInterface(QSharedPointer<ExpressionParser> expressionParser,
47 QSharedPointer<ExpressionFormatter> expressionFormatter,
48 BusInterfaceInterface* busInterface,
49 ParametersInterface* parameterInterface);
50
54 virtual ~MemoryBlockInterface() = default;
55
61 void setMemoryBlocks(QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > newMemoryBlocks);
62
68 void setupSubInterfaces(QSharedPointer<Component> newComponent);
69
76
84 virtual bool acceptBlock(std::string const& blockName) const = 0;
85
93 virtual int getItemIndex(std::string const& itemName) const override final;
94
102 std::string getIndexedItemName(int itemIndex) const final;
103
109 virtual int itemCount() const override final;
110
116 virtual std::vector<std::string> getItemNames() const override final;
117
126 virtual bool setName(std::string const& currentName, std::string const& newName) override final;
127
136 std::string getBaseAddressValue(std::string const& blockName, int const& baseNumber = 0) const;
137
145 std::string getBaseAddressFormattedExpression(std::string const& blockName) const;
146
154 std::string getBaseAddressExpression(std::string const& blockName) const;
155
164 bool setBaseAddress(std::string const& blockName, std::string const& newBaseAdress) const;
165
174 std::string getIsPresentValue(std::string const& blockName, int const& baseNumber = 0) const;
175
183 std::string getIsPresentFormattedExpression(std::string const& blockName) const;
184
192 std::string getIsPresentExpression(std::string const& blockName) const;
193
202 bool setIsPresent(std::string const& blockName, std::string const& newIsPresent) const;
203
212 std::string getRangeValue(std::string const& blockName, int const& baseNumber = 0) const;
213
222 virtual int getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const override;
223
229 virtual bool validateItems() const override = 0;
230
238 bool itemHasValidName(std::string const& itemName) const;
239
247 bool hasValidBaseAddress(std::string const& itemName) const;
248
256 bool hasValidIsPresent(std::string const& itemName) const;
257
264 virtual void addBlock(int const& row, std::string const& newBlockName = std::string("")) = 0;
265
272 virtual void addBlock(std::string const& newBlockName = std::string(""));
273
281 bool removeBlock(std::string const& blockName);
282
288 void copyRows(std::vector<int> selectedRows);
289
295 std::vector<std::string> pasteRows();
296
302 int getPasteRowCount() const;
303
311 virtual std::vector<std::string> getExpressionsInSelectedItems(std::vector<std::string> const& itemNames) const = 0;
312
318 void setAddressUnitBits(std::string const& newAddressUnitbits);
319
320protected:
321
327 QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > getBlocksData();
328
334 QString getNewBlockBaseAddress() const;
335
343 QSharedPointer<MemoryBlockBase> getBlock(std::string const& itemName) const;
344
350 QString getAddressUnitBits() const;
351
359 QSharedPointer<AddressSpace> getReferencedAddressSpace(QString const& masterBusReference) const;
360
361private:
362
368 virtual std::string getDefaultName() const = 0;
369
377 virtual QList<QSharedPointer<MemoryBlockBase> > getCopiedBlocks(std::vector<int> const& selectedRows) const = 0;
378
384 virtual QString getMimeType() const = 0;
385
393 virtual QSharedPointer<MemoryBlockBase> createCopyBlock(QSharedPointer<MemoryBlockBase> copiedItem) const = 0;
394
402 virtual int countItems(QList<QSharedPointer<MemoryBlockBase> > itemList) const = 0;
403
409 virtual QSharedPointer<MemoryBlockValidator> getValidator() const = 0;
410
420 QSharedPointer<Segment> getReferencedSegment(QSharedPointer<AddressSpace> referencedSpace,
421 QString const& segmentReference) const;
422
423 //-----------------------------------------------------------------------------
424 // Data.
425 //-----------------------------------------------------------------------------
426
428 QSharedPointer<QList<QSharedPointer<AddressSpace> > > availableAddressSpaces_{ nullptr };
429
431 BusInterfaceInterface* busInterfaceInterface_{ nullptr };
432
434 QSharedPointer<QList<QSharedPointer<MemoryBlockBase> > > blockData_{ nullptr };
435
437 QString addressUnitBits_;
438
440 ParametersInterface* parameterInterface_{ nullptr };
441};
442
443#endif // MEMORYBLOCKINTERFACE_H
ArrayableMemoryInterface(QSharedPointer< ExpressionParser > expressionParser, QSharedPointer< ExpressionFormatter > formatter)
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
Interface for editing parameters.