Kactus2
Kactus2 reference guide
Loading...
Searching...
No Matches
PythonAPI Class Reference

Interface for accessing Kactus2 data using Python. More...

#include <PythonAPI.h>

Public Types

enum  StdRev { Std14 , Std22 }
 

Public Member Functions

 PythonAPI ()
 
 ~PythonAPI ()=default
 
bool addComponentInstance (std::string const &vlnvString, std::string const &instanceName)
 
void addLibraryPath (std::string const &path, bool isActive=true)
 
void closeOpenComponent ()
 
void closeOpenDesign ()
 
bool createAdHocConnection (std::string const &startInstanceName, std::string const &startPort, std::string const &endInstanceName, std::string const &endPort)
 
bool createComponent (std::string const &vendor, std::string const &library, std::string const &name, std::string const &version, StdRev revision=StdRev::Std22)
 
bool createConnection (std::string const &startInstanceName, std::string const &startBus, std::string const &endInstanceName, std::string const &endBus)
 
bool createDesign (std::string const &vendor, std::string const &library, std::string const &name, std::string const &version, StdRev revision=StdRev::Std22)
 
bool createHierarchicalAdHocConnection (std::string const &instanceName, std::string const &instancePort, std::string const &topPort)
 
bool createHierarchicalConnection (std::string const &instanceName, std::string const &instanceBus, std::string const &topBus)
 
void generate (std::string const &format, std::string const &vlnv, std::string const &viewName, std::string const &outputDirectory) const
 
std::vector< std::string > getActiveLibraryPaths () const
 
std::vector< std::string > getAllLibraryPaths () const
 
BusInterfaceInterfacegetBusInterface ()
 
std::string getComponentDescription () const
 
std::string getComponentName () const
 
ParametersInterfacegetComponentParameterInterface () const
 
std::string getComponentStdRevision () const
 
std::string getDefaultLibraryPath () const
 
std::string getDesignStdRevision () const
 
int getFileCount () const
 
FileSetInterfacegetFileSetInterface ()
 
std::string getFirstViewName () const
 
MemoryMapInterfacegetMapInterface ()
 
PortsInterfacegetPortsInterface () const
 
std::string getVersion () const
 
std::string getVLNVDirectory (std::string const &vendor, std::string const &library, std::string const &name, std::string const &version) const
 
int importFile (std::string const &path, std::string const &vlnv, bool overwrite=false) const
 
std::vector< std::string > listComponentVLNVs () const
 
std::vector< std::string > listVLNVs (std::string const &vendor=std::string()) const
 
bool openComponent (std::string const &vlnvString)
 
bool openDesign (std::string const &vlnvString)
 
bool removeComponentInstance (std::string const &instanceName)
 
bool removeHierarchicalAdHocConnection (std::string const &instanceName, std::string const &instancePort, std::string const &topPort)
 
bool removeHierarchicalConnection (std::string const &instanceName, std::string const &instanceBus, std::string const &topBus)
 
bool removeInstanceAdHocConnection (std::string const &startInstanceName, std::string const &startPort, std::string const &endInstanceName, std::string const &endPort)
 
bool removeInstanceAdHocConnections (std::string const &instanceName)
 
bool removeInstanceConnection (std::string const &startInstanceName, std::string const &startBus, std::string const &endInstanceName, std::string const &endBus)
 
bool removeInstanceConnections (std::string const &instanceName)
 
void removeLibraryPath (std::string const &path)
 
bool renameAdHocConnection (std::string const &currentName, std::string const &newName)
 
bool renameConnection (std::string const &currentName, std::string const &newName)
 
bool renameInstance (std::string const &currentName, std::string const &newName)
 
void saveComponent ()
 
void saveDesign ()
 
void setBlocksForInterface (std::string const &mapName)
 
void setDefaultLibraryPath (std::string const &path) const
 
void setFieldsForInterface (std::string const &mapName, std::string const &blockName, std::string const &registerName)
 
void setFileBuildersForInterface (std::string const &setName)
 
void setFilesForInterface (std::string const &setName)
 
void setLibraryPathActive (std::string const &path, bool isActive)
 
void setLibraryPaths (std::vector< std::string > const &paths) const
 
void setRegistersForInterface (std::string const &mapName, std::string const &blockName)
 
void setResetsForInterface (std::string const &mapName, std::string const &blockName, std::string const &registerName, std::string const &fieldName)
 
void setupLibrary (std::string const &settingsFileString)
 
bool vlnvExistsInLibrary (std::string const &vendor, std::string const &library, std::string const &name, std::string const &version) const
 

Detailed Description

Interface for accessing Kactus2 data using Python.

Definition at line 65 of file PythonAPI.h.

Member Enumeration Documentation

◆ StdRev

IP-XACT std revision for use in python.

Enumerator
Std14 
Std22 

Definition at line 72 of file PythonAPI.h.

Constructor & Destructor Documentation

◆ PythonAPI()

PythonAPI::PythonAPI ( )

The constructor.

Definition at line 68 of file PythonAPI.cpp.

◆ ~PythonAPI()

PythonAPI::~PythonAPI ( )
default

The destructor.

Member Function Documentation

◆ addComponentInstance()

bool PythonAPI::addComponentInstance ( std::string const & vlnvString,
std::string const & instanceName )

Add the selected component instance to the active design.

Parameters
[in]vlnvStringVLNV of the component within the selected component instance.
[in]instanceNameName for the new component instance.
Returns
True, if successful, false otherwise.

Definition at line 1098 of file PythonAPI.cpp.

◆ addLibraryPath()

void PythonAPI::addLibraryPath ( std::string const & path,
bool isActive = true )

Add a new library path and set as active by default.

Parameters
[in]pathThe path to add.
[in]isActiveIndicates if the new path should be set active or not.

Definition at line 118 of file PythonAPI.cpp.

◆ closeOpenComponent()

void PythonAPI::closeOpenComponent ( )

Remove the active component.

Definition at line 483 of file PythonAPI.cpp.

◆ closeOpenDesign()

void PythonAPI::closeOpenDesign ( )

Remove the active design.

Definition at line 1065 of file PythonAPI.cpp.

◆ createAdHocConnection()

bool PythonAPI::createAdHocConnection ( std::string const & startInstanceName,
std::string const & startPort,
std::string const & endInstanceName,
std::string const & endPort )

Create an ad hoc connection between two ports.

Parameters
[in]startInstanceNameName of the component instance containing the first port.
[in]startPortName of the first port.
[in]endInstanceNameName of the component instance containing the second port.
[in]endPortName of the second port.
Returns
True, if the connection was created, false otherwise.

Definition at line 1460 of file PythonAPI.cpp.

◆ createComponent()

bool PythonAPI::createComponent ( std::string const & vendor,
std::string const & library,
std::string const & name,
std::string const & version,
StdRev revision = StdRev::Std22 )

Create a new component with the selected VLNV. Defaults to IP-XACT 2022.

Parameters
[in]vendorVendor of the selected VLNV.
[in]libraryLibrary of the selected VLNV.
[in]nameName of the selected VLNV.
[in]versionVersion of the selected VLNV.
[in]revisionIP-XACT standard revision to use.
Returns
True, if the component was created successfully, false otherwise.

Definition at line 334 of file PythonAPI.cpp.

◆ createConnection()

bool PythonAPI::createConnection ( std::string const & startInstanceName,
std::string const & startBus,
std::string const & endInstanceName,
std::string const & endBus )

Create an interconnection between two bus interfaces.

Parameters
[in]startInstanceNameName of the component instance containing the first bus interface.
[in]startBusName of the first bus interface.
[in]endInstanceNameName of the component instance containing the second bus interface.
[in]endBusName of the second bus interface.
Returns
True, if the connection was created, false otherwise.

Definition at line 1178 of file PythonAPI.cpp.

◆ createDesign()

bool PythonAPI::createDesign ( std::string const & vendor,
std::string const & library,
std::string const & name,
std::string const & version,
StdRev revision = StdRev::Std22 )

Create a new design with the selected VLNV. Defaults to IP-XACT 2022.

Parameters
[in]vendorVendor of the selected VLNV.
[in]libraryLibrary of the selected VLNV.
[in]nameName of the selected VLNV.
[in]versionVersion of the selected VLNV.
[in]revisionIP-XACT standard revision to use.
Returns
True, if the design was created successfully, false otherwise.

Definition at line 899 of file PythonAPI.cpp.

◆ createHierarchicalAdHocConnection()

bool PythonAPI::createHierarchicalAdHocConnection ( std::string const & instanceName,
std::string const & instancePort,
std::string const & topPort )

Create a hierarchical ad hoc connection between two ports.

Parameters
[in]instanceNameName of the component instance containing the selected port.
[in]instancePortName of the component instance port.
[in]topPortName of the top component port.
Returns
True, if successful, false otherwise.

Definition at line 1482 of file PythonAPI.cpp.

◆ createHierarchicalConnection()

bool PythonAPI::createHierarchicalConnection ( std::string const & instanceName,
std::string const & instanceBus,
std::string const & topBus )

Create a hierarchical interconnection between two bus interfaces.

Parameters
[in]instanceNameName of the component instance containing the selected bus interface.
[in]instanceBusName of the component instance bus interface.
[in]topBusName of the top component bus interface.
Returns
True, if the connection was created, false otherwise.

Definition at line 1200 of file PythonAPI.cpp.

◆ generate()

void PythonAPI::generate ( std::string const & format,
std::string const & vlnv,
std::string const & viewName,
std::string const & outputDirectory ) const

Run a file generation for a component.

Parameters
[in]formatThe requested output format.
[in]vlnvThe component VLNV to run the generation for.
[in]viewNameThe component view to run the generation for.
[in]outputDirectoryThe output directory for the generation results.

Definition at line 233 of file PythonAPI.cpp.

◆ getActiveLibraryPaths()

std::vector< std::string > PythonAPI::getActiveLibraryPaths ( ) const

Get configured active library paths.

Returns
The configured active library paths.

Definition at line 137 of file PythonAPI.cpp.

◆ getAllLibraryPaths()

std::vector< std::string > PythonAPI::getAllLibraryPaths ( ) const

Get all configured active and inactive library paths.

Returns
All of the configured library paths.

Definition at line 94 of file PythonAPI.cpp.

◆ getBusInterface()

BusInterfaceInterface * PythonAPI::getBusInterface ( )

Get the interface for accessing bus interfaces.

Returns
Interface for accessing bus interfaces.

Definition at line 185 of file PythonAPI.cpp.

◆ getComponentDescription()

std::string PythonAPI::getComponentDescription ( ) const

Get the description of the active component.

Definition at line 511 of file PythonAPI.cpp.

◆ getComponentName()

std::string PythonAPI::getComponentName ( ) const

Get the name of the active component.

Definition at line 496 of file PythonAPI.cpp.

◆ getComponentParameterInterface()

ParametersInterface * PythonAPI::getComponentParameterInterface ( ) const

Get the interface for accessing the component parameters.

Returns
Interface for accessing the component parameters.

Definition at line 161 of file PythonAPI.cpp.

◆ getComponentStdRevision()

std::string PythonAPI::getComponentStdRevision ( ) const

Get the IP-XACT standard revision of the active component

Definition at line 526 of file PythonAPI.cpp.

◆ getDefaultLibraryPath()

std::string PythonAPI::getDefaultLibraryPath ( ) const

Get the default library path for IP-XACT files.

Returns
The default path for IP-XACT files.

Definition at line 207 of file PythonAPI.cpp.

◆ getDesignStdRevision()

std::string PythonAPI::getDesignStdRevision ( ) const

Get the IP-XACT standard revision of the active design.

Definition at line 969 of file PythonAPI.cpp.

◆ getFileCount()

int PythonAPI::getFileCount ( ) const

Get the number of files in the library.

Returns
The number of files in the library.

Definition at line 274 of file PythonAPI.cpp.

◆ getFileSetInterface()

FileSetInterface * PythonAPI::getFileSetInterface ( )

Get the interface for accessing file sets.

Returns
Interface for accessing file sets.

Definition at line 177 of file PythonAPI.cpp.

◆ getFirstViewName()

std::string PythonAPI::getFirstViewName ( ) const

Get the name of the first view contained within the active component.

Returns
Name of the first view contained within the active component.

Definition at line 400 of file PythonAPI.cpp.

◆ getMapInterface()

MemoryMapInterface * PythonAPI::getMapInterface ( )

Get the interface for accessing component memory maps.

Returns
Interface for accessing component memory maps.

Definition at line 169 of file PythonAPI.cpp.

◆ getPortsInterface()

PortsInterface * PythonAPI::getPortsInterface ( ) const

Get the interface for accessing the component ports.

Returns
Interface for accessing the component ports.

Definition at line 153 of file PythonAPI.cpp.

◆ getVersion()

std::string PythonAPI::getVersion ( ) const

Get Kactus2 version.

Returns
The current Kactus2 version.

Definition at line 86 of file PythonAPI.cpp.

◆ getVLNVDirectory()

std::string PythonAPI::getVLNVDirectory ( std::string const & vendor,
std::string const & library,
std::string const & name,
std::string const & version ) const

Get the directory path of the selected VLNV document.

Parameters
[in]vendorVendor of the selected VLNV.
[in]libraryLibrary of the selected VLNV.
[in]nameName of the selected VLNV.
[in]versionVersion of the selected VLNV.
Returns
Path of the selected VLNV document.

Definition at line 385 of file PythonAPI.cpp.

◆ importFile()

int PythonAPI::importFile ( std::string const & path,
std::string const & vlnv,
bool overwrite = false ) const

Import a source file (RTL) into the library as a component.

Parameters
[in]filePathThe path to the file to import.
[in]targetVLNVThe VLNV to use for the imported component.
[in]overwriteOverwrite the component in the library, if it already exists.
Returns
The number of imported IP-XACT components.

Definition at line 223 of file PythonAPI.cpp.

◆ listComponentVLNVs()

std::vector< std::string > PythonAPI::listComponentVLNVs ( ) const

List all the component VLNVs in the library.

Returns
List of component VLNVs in Vendor:Library:Name:Version format.

Definition at line 297 of file PythonAPI.cpp.

◆ listVLNVs()

std::vector< std::string > PythonAPI::listVLNVs ( std::string const & vendor = std::string()) const

List all the VLNVs in the library.

Parameters
[in]vendorThe desired vendor.
Returns
List of VLNVs in Vendor:Library:Name:Version format.

Definition at line 282 of file PythonAPI.cpp.

◆ openComponent()

bool PythonAPI::openComponent ( std::string const & vlnvString)

Set the selected component as active component.

Parameters
[in]componentVLNVVLNV of the selected component.
Returns
True, if the component exists, false otherwise.

Definition at line 423 of file PythonAPI.cpp.

◆ openDesign()

bool PythonAPI::openDesign ( std::string const & vlnvString)

Set the selected design as active design.

Parameters
[in]vlnvStringVLNV of the selected design.
Returns
True, if the design exists, false otherwise.

Definition at line 1031 of file PythonAPI.cpp.

◆ removeComponentInstance()

bool PythonAPI::removeComponentInstance ( std::string const & instanceName)

Remove the selected component instance from the active design.

Parameters
[in]instanceNameName of the selected component instance.
Returns
True, if successful, false otherwise.

Definition at line 1140 of file PythonAPI.cpp.

◆ removeHierarchicalAdHocConnection()

bool PythonAPI::removeHierarchicalAdHocConnection ( std::string const & instanceName,
std::string const & instancePort,
std::string const & topPort )

Remove a hierarchical ad hoc connection between two ports.

Parameters
[in]instanceNameName of the component instance containing the selected port.
[in]instancePortName of the component instance port.
[in]topPortName of the top component port.
Returns
True, if successful, false otherwise.

Definition at line 1529 of file PythonAPI.cpp.

◆ removeHierarchicalConnection()

bool PythonAPI::removeHierarchicalConnection ( std::string const & instanceName,
std::string const & instanceBus,
std::string const & topBus )

Remove an interconnection between two bus interfaces.

Parameters
[in]instanceNameName of the component instance containing the selected bus interface.
[in]instanceBusName of the component instance bus interface.
[in]topBusName of the top component bus interface.
Returns
True, if successful, false otherwise.

Definition at line 1424 of file PythonAPI.cpp.

◆ removeInstanceAdHocConnection()

bool PythonAPI::removeInstanceAdHocConnection ( std::string const & startInstanceName,
std::string const & startPort,
std::string const & endInstanceName,
std::string const & endPort )

Remove an ad hoc connection between two ports.

Parameters
[in]startInstanceNameName of the component instance containing the first port.
[in]startPortName of the first port.
[in]endInstanceNameName of the component instance containing the second port.
[in]endPortName of the second port.
Returns
True, if the ad hoc connection was removed, false otherwise.

Definition at line 1502 of file PythonAPI.cpp.

◆ removeInstanceAdHocConnections()

bool PythonAPI::removeInstanceAdHocConnections ( std::string const & instanceName)

Remove ad hoc connections from the selected component instance.

Parameters
[in]instanceNameName of the selected component instance.
Returns
True, if successful, false otherwise.

Definition at line 1162 of file PythonAPI.cpp.

◆ removeInstanceConnection()

bool PythonAPI::removeInstanceConnection ( std::string const & startInstanceName,
std::string const & startBus,
std::string const & endInstanceName,
std::string const & endBus )

Remove an interconnection between two bus interfaces.

Parameters
[in]startInstanceNameName of the component instance containing the first bus interface.
[in]startBusName of the first bus interface.
[in]endInstanceNameName of the component instance containing the second bus interface.
[in]endBusName of the second bus interface.
Returns
True, if the connection was removed, false otherwise.

Definition at line 1412 of file PythonAPI.cpp.

◆ removeInstanceConnections()

bool PythonAPI::removeInstanceConnections ( std::string const & instanceName)

Remove connections from the selected component instance.

Parameters
[in]instanceNameName of the selected component instance.
Returns
True, if successful, false otherwise.

Definition at line 1154 of file PythonAPI.cpp.

◆ removeLibraryPath()

void PythonAPI::removeLibraryPath ( std::string const & path)

Remove a library path. Prints error if trying to remove default path.

Parameters
[in]pathThe path to remove.

Definition at line 126 of file PythonAPI.cpp.

◆ renameAdHocConnection()

bool PythonAPI::renameAdHocConnection ( std::string const & currentName,
std::string const & newName )

Set a new name for the selected ad hoc connection.

Parameters
[in]currentNameName of the selected ad hoc connection.
[in]newNameNew name for the ad hoc connection.
Returns
True, if successful, false otherwise.

Definition at line 1541 of file PythonAPI.cpp.

◆ renameConnection()

bool PythonAPI::renameConnection ( std::string const & currentName,
std::string const & newName )

Set a new name for the selected interconnection.

Parameters
[in]currentNameName of the selected interconnection.
[in]newNameNew name for the interconnection.
Returns
True, if successful, false otherwise.

Definition at line 1452 of file PythonAPI.cpp.

◆ renameInstance()

bool PythonAPI::renameInstance ( std::string const & currentName,
std::string const & newName )

Set a new name for the selected component instance.

Parameters
[in]currentNameName of the selected component instance.
[in]newNameNew name for the component instance.
Returns
True, if successful, false otherwise.

Definition at line 1170 of file PythonAPI.cpp.

◆ saveComponent()

void PythonAPI::saveComponent ( )

Save the component to the library.

Definition at line 539 of file PythonAPI.cpp.

◆ saveDesign()

void PythonAPI::saveDesign ( )

Save the design to the library.

Definition at line 1078 of file PythonAPI.cpp.

◆ setBlocksForInterface()

void PythonAPI::setBlocksForInterface ( std::string const & mapName)

Set the available address blocks for the address block interface.

Parameters
[in]mapNameName of the memory map containing the desired address blocks.

Definition at line 622 of file PythonAPI.cpp.

◆ setDefaultLibraryPath()

void PythonAPI::setDefaultLibraryPath ( std::string const & path) const

Set the default library path for IP-XACT files.

Parameters
[in]pathThe default path to set for IP-XACT files.

Definition at line 215 of file PythonAPI.cpp.

◆ setFieldsForInterface()

void PythonAPI::setFieldsForInterface ( std::string const & mapName,
std::string const & blockName,
std::string const & registerName )

Set the available fields for the field interface.

Parameters
[in]mapNameName of the memory map containing the desired address blocks.
[in]blockNameName of the address block containing the desired registers.
[in]registerNameName of the register containing the desired fields.

Definition at line 672 of file PythonAPI.cpp.

◆ setFileBuildersForInterface()

void PythonAPI::setFileBuildersForInterface ( std::string const & setName)

Set the available file builders for the file interface.

Parameters
[in]setNameName of the file set containing the available file builders.

Definition at line 881 of file PythonAPI.cpp.

◆ setFilesForInterface()

void PythonAPI::setFilesForInterface ( std::string const & setName)

Set the available files for the file interface.

Parameters
[in]setNameName of the file set containing the available files.

Definition at line 847 of file PythonAPI.cpp.

◆ setLibraryPathActive()

void PythonAPI::setLibraryPathActive ( std::string const & path,
bool isActive )

Set a given library path as active or inactive. If set as active, also add the path if not found.

Parameters
[in]pathThe path to set active.
[in]isActiveIndicates if the path should be set active or inactive.

Definition at line 110 of file PythonAPI.cpp.

◆ setLibraryPaths()

void PythonAPI::setLibraryPaths ( std::vector< std::string > const & paths) const

Sets new active library paths. First path is set as default.

Parameters
[in]pathsThe new locations that are currently available to store the files.

Definition at line 193 of file PythonAPI.cpp.

◆ setRegistersForInterface()

void PythonAPI::setRegistersForInterface ( std::string const & mapName,
std::string const & blockName )

Set the available registers for the register interface.

Parameters
[in]mapNameName of the memory map containing the desired address blocks.
[in]blockNameName of the address block containing the desired registers.

Definition at line 641 of file PythonAPI.cpp.

◆ setResetsForInterface()

void PythonAPI::setResetsForInterface ( std::string const & mapName,
std::string const & blockName,
std::string const & registerName,
std::string const & fieldName )

Set the available resets for the reset interface.

Parameters
[in]mapNameName of the memory map containing the desired address blocks.
[in]blockNameName of the address block containing the desired registers.
[in]registerNameName of the register containing the desired fields.
[in]fieldNameName of the field containing the desired resets.

Definition at line 712 of file PythonAPI.cpp.

◆ setupLibrary()

void PythonAPI::setupLibrary ( std::string const & settingsFileString)

Gets the paths where IP-XACT files are stored.

Returns
The paths where IP-XACT files are stored.

Definition at line 78 of file PythonAPI.cpp.

◆ vlnvExistsInLibrary()

bool PythonAPI::vlnvExistsInLibrary ( std::string const & vendor,
std::string const & library,
std::string const & name,
std::string const & version ) const

Check if the selected VLNV exists in the library.

Parameters
[in]vendorVendor of the selected VLNV.
[in]libraryLibrary of the selected VLNV.
[in]nameName of the selected VLNV.
[in]versionVersion of the selected VLNV.
Returns
True, if the VLNV exists in the library, false otherwise.

Definition at line 315 of file PythonAPI.cpp.


The documentation for this class was generated from the following files: